protected override TreeViewItem BuildRoot() { var id = 0; var worlds = AssetFinder.ListMainAssets <World>(); var rootItem = new TreeViewItem { id = id++, depth = -1, displayName = "Root" }; foreach (var world in worlds) { var worldItem = new WorldItem { World = world, id = id++, displayName = world.name }; rootItem.AddChild(worldItem); foreach (var zone in world.Zones) { var name = worlds.Count > 1 ? string.Format("{0}/{1}", world.name, zone.name) : zone.name; var zoneItem = new ZoneItem { Zone = zone, id = id++, displayName = name }; rootItem.AddChild(zoneItem); } } rootItem.children.Sort((left, right) => left.displayName.CompareTo(right.displayName)); SetupDepthsFromParentsAndChildren(rootItem); return(rootItem); }
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); }
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); }
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); }
private void OnEnable() { if (!CollisionTile) { CollisionTile = AssetFinder.GetMainAsset <CollisionTile>(); if (!CollisionTile) { CollisionTile = CreateInstance <CollisionTile>(); CollisionTile.name = "CollisionTile"; CollisionTile.hideFlags = HideFlags.HideInHierarchy; AssetDatabase.CreateAsset(CollisionTile, "Assets/CollisionTile.asset"); AssetDatabase.SaveAssets(); } } }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { label.tooltip = EditorHelper.GetTooltip(fieldInfo); var dropRect = new Rect(position.x, position.y, position.width * 0.8f, EditorGUIUtility.singleLineHeight); var loadRect = new Rect(dropRect.xMax + 5, position.y, position.width - dropRect.width - 5, dropRect.height); var pathProperty = property.FindPropertyRelative("Path"); var paths = AssetFinder.ListScenes().ToArray(); var names = paths.Select(path => path.Replace('/', ' ')).ToArray(); var selected = Array.IndexOf(paths, pathProperty.stringValue); selected = EditorGUI.Popup(dropRect, label.text, selected, names); pathProperty.stringValue = selected >= 0 && selected < paths.Length ? paths[selected] : ""; if (GUI.Button(loadRect, EditorHelper.LoadContent)) { EditorSceneManager.OpenScene(pathProperty.stringValue, OpenSceneMode.Additive); } }
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); }
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); }
private static List <PopupData> GetPopups() { if (_popups == null) { _popups = new List <PopupData>(); _popups.Add(new PopupData { Set = null }); var sets = AssetFinder.FindMainAssets <InstructionSet>().OrderBy(s => s.name); foreach (var set in sets) { _popups.Add(new PopupData { Set = set }); } } return(_popups); }
protected override void FindAssets() { _assets = AssetFinder.ListSubAssets <ParentType, AssetType>(); }
protected virtual void FindAssets() { _assets = AssetFinder.ListMainAssets <AssetType>(); }