// Copyright | Raumgleiter AG | 2019 | All Rights Reserved //*********************************************************************************************************************** //Headers using System.Collections; using System.Collections.Generic; using UnityEngine; using Raumgleiter.BaseRGDK; using Raumgleiter.BaseRGDK.Data; using Raumgleiter.BaseRGDK.Data.Geometry; using Raumgleiter.ArchStructureRGDK; using Raumgleiter.ArchRGDK.Project; using System; //*********************************************************************************************************************** namespace Raumgleiter.RGDKDevLab { public class WorldManager : MonoBehaviour { //Singleton Pattern private static WorldManager _inst; public static WorldManager Instance { get { if (!_inst) _inst = UnityEngine.Object.FindObjectOfType(); if (!_inst) _inst = new GameObject(typeof(WorldManager).ToString()).AddComponent(); return _inst; } } public static bool GetHasInstance() { return _inst != null; } internal void LoadModel() { throw new NotImplementedException(); } //------------------------------------------------------------------------------------------------------------------ //Connections [Header("Connections")] public Transform ProjectParent; protected ProjectInstance Project; public GameObject PaintedObject; //Resources //[Header("Resources")] //Attributes //[Header("Attributes")] //Stats //[Header("Stats")] //protected bool IsSetUp = false; //Getter //Delegates //------------------------------------------------------------------------------------------------------------------ //awake //------------------------------------------------------------------------------------------------------------------ //start private void Start() { //LoadProject(); } //------------------------------------------------------------------------------------------------------------------ //setup //public void SetUp() //{ // IsSetUp = true; //} //------------------------------------------------------------------------------------------------------------------ //destroy //*********************************************************************************************************************** //update //*********************************************************************************************************************** //refresh //------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------ //*********************************************************************************************************************** //events public void OnProjectSpawned(ProjectInstance instance) { Project = instance; StartCoroutine(LoadProject(Project)); } //------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------ //*********************************************************************************************************************** //private, protected public IEnumerator LoadProject(ProjectInstance instance) { //yield break; yield return StartCoroutine( instance.Load( ProjectDataAccessLevel.Full, reload: true)); PaintedObject = instance.GetLayerController(new Id(9)).GetSceneTransform().gameObject; string MaterialNameFacade = "solar_00"; string MaterialNameGrass = "Grass V02"; } //------------------------------------------------------------------------------------------------------------------ public GameObject GetThisGameObject() { return PaintedObject; } //------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------ //*********************************************************************************************************************** //private //------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------ //*********************************************************************************************************************** //protected public void LoadProject() { Raumgleiter.ArchRGDK.Resource.Feature.FeatureLibrary.Instance.SetUp(); GeometryTransformData.SetScaleDisplayOverride(Vector3.one); ProjectInstanceMetadata ProjectData = new ProjectInstanceMetadata(); ProjectData.Database = ArchDatabase.RGL; ProjectData.Description = "Ein Beispielprojekt"; ProjectData.Id = new Id(153); ProjectData.Name = "Amt für Energie und Umwelt"; ProjectData.Tags = new List(new string[] { "AUE" }); ProjectData.Version = ProjectVersionType.Live; ProjectData.GeoLocation = ScriptableObject.CreateInstance(); ProjectSpawner.AddProject( ProjectData, PathsLocal.GetCACHE(), ProjectParent, OnProjectSpawned); } //------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------ //*********************************************************************************************************************** //internal //------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------ //*********************************************************************************************************************** //public //------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------ //*********************************************************************************************************************** //public static //------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------ //*********************************************************************************************************************** //getter, setter //------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------ } }