Пример #1
0
 IEnumerator ClearRoutine()
 {
     _ready = false;
     if (usePathGeneratorInstance && overridePathGenerator != null)
     {
         Destroy(overridePathGenerator);
     }
     overridePathGenerator = null;
     while (isLoadingLevel)
     {
         yield return(null);
     }
     LevelSegment.ResetGenerationState();
     SegmentExtruder.instance.Stop();
     for (int i = 0; i < levels.Length; i++)
     {
         if (levels[i].remoteSequence && levels[i].isReady)
         {
             yield return(StartCoroutine(UnloadRemoteLevel(levels[i], ThreadPriority.High)));
         }
     }
     for (int i = 0; i < _segments.Count; i++)
     {
         _segments[i].DestroyImmediate();
     }
     ResourceManagement.UnloadResources();
     _segments.Clear();
     enteredLevel    = null;
     _enteredSegment = -1;
 }
Пример #2
0
 public void Start()
 {
     //Register unique resources to be unloaded when the segment is destroyed
     for (int i = 0; i < uniqueResources.Length; i++)
     {
         ResourceManagement.RegisterUnloadableResource(uniqueResources[i], index);
     }
     SegmentExtruder.instance.AddToBuildQueue(this);
 }
Пример #3
0
 protected virtual void OnDestroy()
 {
     //Destroy generated resources
     for (int i = 0; i < objectProperties.Length; i++)
     {
         objectProperties[i].Dispose();
     }
     //Unload assets used only by this segment and no upcoming segments
     ResourceManagement.UnloadResources(index);
     if (_generationState == GenerationState.Destroying)
     {
         _generationState = GenerationState.Idle;
     }
 }
Пример #4
0
        public void EditorPack()
        {
            UpdateReferences();
            List <Builder>   builderList = new List <Builder>();
            List <Transform> allChildren = new List <Transform>();

            SceneUtility.GetChildrenRecursively(transform, ref allChildren);
            editorChildCount = allChildren.Count;
            List <Object> unique = new List <Object>();

            for (int i = 0; i < allChildren.Count; i++)
            {
                #region Extract Unique Resources
                ResourceManagement.ExtractUniqueResources(allChildren[i].gameObject, unique);
                #endregion

                #region Find Builders
                Builder[] builders = allChildren[i].GetComponents <Builder>();
                for (int j = 0; j < builders.Length; j++)
                {
                    builders[j].OnPack();
                    builderList.Add(builders[j]);
                }
                #endregion

                EditorUtility.DisplayProgressBar("Caching segment", "Caching objects for faster generation.", ((float)i / (allChildren.Count - 1)));
            }
            uniqueResources = unique.ToArray();
            EditorUtility.ClearProgressBar();
            builders = builderList.ToArray();
            if (builders.Length > 1)
            {
                SortBuilders(0, builders.Length);
            }
            unpacked = false;
        }
Пример #5
0
 void Awake()
 {
     instance = this;
     active   = true;
 }