public void Update () { //checking if instance already exists and disabling if it is another mm if (instance != null && instance != this) { Debug.LogError("MapMagic object already present in scene. Disabling duplicate"); this.enabled = false; return; } //loading old non-asset data if (gens == null) { if (serializer != null && serializer.entities != null && serializer.entities.Count != 0) { Debug.Log("MapMagic: Loading outdated scene format. Please check node consistency and re-save the scene."); LoadOldNonAssetData(); serializer = null; } else Debug.Log("MapMagic: Could not find the proper graph data. Please assign it manually."); } //checking gens asset if (gens == null) gens = ScriptableObject.CreateInstance<GeneratorsAsset>(); //finding camera positions Vector3[] camPoses = GetCamPoses(); if (camPoses.Length==0) return; //displaying debug range if (guiDebug && !isEditor) for (int c=0; c<camPoses.Length; c++) transform.TransformPoint(camPoses[c]).DrawDebug(generateRange, Color.green); //deploying terrain matrix if (!isEditor && generateInfinite) terrains.Deploy(camPoses, allowMove:true); //enabling/disabling, switching lods, starting threads terrains.SwitchState(camPoses); //transforming cam poses to coords Coord[] camCoords = GetCamCoords(); if (camCoords.Length==0) return; //calculating number of running threads and checking a need to prepare generators runningThreadsCount = 0; bool prepareGenerators = false; foreach (Chunk tw in terrains.Objects()) { if (tw.running) runningThreadsCount++; if (tw.start) prepareGenerators = true; //if any of chunks started this frame } //preparing generators if (prepareGenerators) { foreach (TextureInput tin in gens.GeneratorsOfType<TextureInput>()) tin.CheckLoadTexture(); } //updating chunks foreach (Chunk tw in terrains.ObjectsFromCoords(camCoords)) tw.Update(); }