Beispiel #1
0
        private static string FindStartZone(WorldManager manager)
        {
            if (WorldPreferences.Instance.StartingZone != null)
            {
                return(WorldPreferences.Instance.StartingZone.name);
            }

            var zones = AssetFinder.ListSubAssets <World, Zone>();
            var scene = SceneManager.GetActiveScene();
            var zone  = GetZone(zones, scene);

            if (zone != null)
            {
                return(zone.name);
            }

            for (var i = 0; i < SceneManager.sceneCount; i++)
            {
                scene = SceneManager.GetSceneAt(i);
                zone  = GetZone(zones, scene);

                if (zone != null)
                {
                    return(zone.name);
                }
            }

            if (manager != null && manager.World != null && manager.World.Zones.Count > 0)
            {
                return(manager.World.Zones[0].name);
            }

            return(null);
        }
Beispiel #2
0
        private static AssetMoveResult OnWillMoveAsset(string sourcePath, string destinationPath)
        {
            var zones = AssetFinder.ListSubAssets <World, Zone>();

            foreach (var zone in zones)
            {
                if (zone.Scene.Path == sourcePath)
                {
                    zone.Scene.Path = destinationPath;
                    EditorUtility.SetDirty(zone);
                }
            }

            return(AssetMoveResult.DidNotMove);
        }
Beispiel #3
0
        private static AssetDeleteResult OnWillDeleteAsset(string path, RemoveAssetOptions options)
        {
            var zones = AssetFinder.ListSubAssets <World, Zone>();

            foreach (var zone in zones)
            {
                if (zone.Scene.Path == path)
                {
                    zone.Scene.Path = "";
                    EditorUtility.SetDirty(zone);
                }
            }

            return(AssetDeleteResult.DidNotDelete);
        }
Beispiel #4
0
        public static AssetList GetSubAssetList(Type type, Type parentType)
        {
            AssetList list;

            if (!_subAssetLists.TryGetValue(type, out list))
            {
                list = new AssetList {
                    Type = type
                };
                _subAssetLists.Add(type, list);
            }

            if (list.Assets == null)
            {
                var assets = AssetFinder.ListSubAssets(type, parentType);
                BuildAssetList(list, assets);
            }

            return(list);
        }
Beispiel #5
0
        public static AssetList GetSubAssetList <P, T>() where P : ScriptableObject where T : ScriptableObject
        {
            AssetList list;

            if (!_subAssetLists.TryGetValue(typeof(T), out list))
            {
                list = new AssetList {
                    Type = typeof(T)
                };
                _subAssetLists.Add(typeof(T), list);
            }

            if (list.Assets == null)
            {
                var assets = AssetFinder.ListSubAssets <P, T>();
                BuildAssetList(list, assets);
            }

            return(list);
        }
Beispiel #6
0
 protected override void FindAssets()
 {
     _assets = AssetFinder.ListSubAssets <ParentType, AssetType>();
 }