|
|
|
|
|
|
if (value != GetShowOnStartup(name)) EditorPrefs.SetBool($"{name}.ShowAtStartup", value); |
|
|
|
} |
|
|
|
|
|
|
|
public static void SelectDiscover(Discover discover) |
|
|
|
{ |
|
|
|
foreach(var window in s_Windows) |
|
|
|
{ |
|
|
|
foreach(var categoryKvp in window.discoverObjects) |
|
|
|
{ |
|
|
|
if (categoryKvp.Value.Contains(discover)) |
|
|
|
{ |
|
|
|
window.SetSelectedDiscover(discover); |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public static void Reload() |
|
|
|
{ |
|
|
|
EditorApplication.update -= ShowAtStartup; |
|
|
|
|
|
|
static void InitShowAtStartup() |
|
|
|
{ |
|
|
|
string[] guids = AssetDatabase.FindAssets("t:DiscoverAsset"); |
|
|
|
foreach(var guid in guids) |
|
|
|
foreach (var guid in guids) |
|
|
|
if(asset.EnableShowAtStartup) |
|
|
|
if (asset.EnableShowAtStartup) |
|
|
|
{ |
|
|
|
if (s_StartupDiscoverAssets == null) |
|
|
|
s_StartupDiscoverAssets = new List<DiscoverAsset>(); |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(s_StartupDiscoverAssets != null && s_StartupDiscoverAssets.Count > 0) |
|
|
|
if (s_StartupDiscoverAssets != null && s_StartupDiscoverAssets.Count > 0) |
|
|
|
EditorApplication.update += ShowAtStartup; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
foreach(var discoverAsset in s_StartupDiscoverAssets) |
|
|
|
foreach (var discoverAsset in s_StartupDiscoverAssets) |
|
|
|
if(GetShowOnStartup(discoverAsset.PreferenceName)) |
|
|
|
if (GetShowOnStartup(discoverAsset.PreferenceName)) |
|
|
|
ShowDiscoverWindow(discoverAsset); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
static List<DiscoverWindow> s_Windows; |
|
|
|
|
|
|
|
if(discoverAsset != null) |
|
|
|
if (discoverAsset != null) |
|
|
|
{ |
|
|
|
var window = GetWindow<DiscoverWindow>(true); |
|
|
|
window.SetDiscoverAsset(discoverAsset); |
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public DiscoverAsset discoverAsset { get; private set; } |
|
|
|
DiscoverAsset discoverAsset; |
|
|
|
bool forceGlobal; |
|
|
|
|
|
|
|
void SetDiscoverAsset(DiscoverAsset discover) |
|
|
|
|
|
|
EditorSceneManager.newSceneCreated += UpdateDiscoverObjectsOnCreate; |
|
|
|
EditorSceneManager.sceneOpened += UpdateDiscoverObjectsOnLoad; |
|
|
|
EditorSceneSetup.onSetupLoaded += UpdateDiscoverObjectsOnLoadSetup; |
|
|
|
|
|
|
|
if (s_Windows == null) |
|
|
|
s_Windows = new List<DiscoverWindow>(); |
|
|
|
|
|
|
|
if(!s_Windows.Contains(this)) |
|
|
|
s_Windows.Add(this); |
|
|
|
} |
|
|
|
|
|
|
|
private void OnDisable() |
|
|
|
|
|
|
EditorSceneSetup.onSetupLoaded -= UpdateDiscoverObjectsOnLoadSetup; |
|
|
|
|
|
|
|
if (s_Windows.Contains(this)) |
|
|
|
s_Windows.Remove(this); |
|
|
|
} |
|
|
|
|
|
|
|
Dictionary<string, List<Discover>> discoverObjects = null; |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// Ensure something is selected is possible
|
|
|
|
|
|
|
|
if (selectedDiscover == null) // Try Fetching a default
|
|
|
|
{ |
|
|
|
foreach (var categoryKvp in discoverObjects) |
|
|
|
{ |
|
|
|
selectedDiscover = categoryKvp.Value.FirstOrDefault(o => o.DefaultSelected == true); |
|
|
|
if (selectedDiscover != null) |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
Repaint(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
foreach (var category in discoverObjects.Keys.OrderBy((x) => x.ToString())) |
|
|
|
{ |
|
|
|
GUILayout.Label(category, EditorStyles.boldLabel); |
|
|
|
if(!string.IsNullOrEmpty(category)) |
|
|
|
GUILayout.Label(category, EditorStyles.boldLabel); |
|
|
|
|
|
|
|
foreach (var item in discoverObjects[category]) |
|
|
|
{ |
|
|
|
|
|
|
if (discoverAsset.Debug) |
|
|
|
Selection.activeObject = item; |
|
|
|
|
|
|
|
if (SceneView.lastActiveSceneView != null && item.AlignViewToTransform) |
|
|
|
{ |
|
|
|
SceneView.lastActiveSceneView.AlignViewToObject(item.transform); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (selectedDiscover.ObjectsToToggle != null) |
|
|
|
{ |
|
|
|
// Reverse Toggle previous GameObjects state
|
|
|
|
foreach (var go in selectedDiscover.ObjectsToToggle) |
|
|
|
{ |
|
|
|
if (go.GameObject == null) |
|
|
|
continue; |
|
|
|
|
|
|
|
switch (go.State) |
|
|
|
{ |
|
|
|
case Actions.ToggleGameObjectAction.GameObjectToggle.GameObjectToggleState.Disable: |
|
|
|
go.GameObject.SetActive(true); |
|
|
|
break; |
|
|
|
case Actions.ToggleGameObjectAction.GameObjectToggle.GameObjectToggleState.Enable: |
|
|
|
go.GameObject.SetActive(false); |
|
|
|
break; |
|
|
|
case Actions.ToggleGameObjectAction.GameObjectToggle.GameObjectToggleState.Toggle: |
|
|
|
go.GameObject.SetActive(go.GameObject.activeSelf); |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// Set the new item
|
|
|
|
selectedDiscover = item; |
|
|
|
|
|
|
|
if (selectedDiscover.ObjectsToToggle != null) |
|
|
|
{ |
|
|
|
// Toggle Next GameObjects State
|
|
|
|
foreach (var go in selectedDiscover.ObjectsToToggle) |
|
|
|
{ |
|
|
|
if (go.GameObject == null) |
|
|
|
continue; |
|
|
|
|
|
|
|
switch (go.State) |
|
|
|
{ |
|
|
|
case Actions.ToggleGameObjectAction.GameObjectToggle.GameObjectToggleState.Disable: |
|
|
|
go.GameObject.SetActive(false); |
|
|
|
break; |
|
|
|
case Actions.ToggleGameObjectAction.GameObjectToggle.GameObjectToggleState.Enable: |
|
|
|
go.GameObject.SetActive(true); |
|
|
|
break; |
|
|
|
case Actions.ToggleGameObjectAction.GameObjectToggle.GameObjectToggleState.Toggle: |
|
|
|
go.GameObject.SetActive(go.GameObject.activeSelf); |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
SetSelectedDiscover(item); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
GUILayout.EndScrollView(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void SetSelectedDiscover(Discover newSelection) |
|
|
|
{ |
|
|
|
|
|
|
|
if (SceneView.lastActiveSceneView != null && newSelection.AlignViewToTransform) |
|
|
|
{ |
|
|
|
SceneView.lastActiveSceneView.AlignViewToObject(newSelection.transform); |
|
|
|
} |
|
|
|
|
|
|
|
if (selectedDiscover.ObjectsToToggle != null) |
|
|
|
{ |
|
|
|
// Reverse Toggle previous GameObjects state
|
|
|
|
foreach (var go in selectedDiscover.ObjectsToToggle) |
|
|
|
{ |
|
|
|
if (go.GameObject == null) |
|
|
|
continue; |
|
|
|
|
|
|
|
switch (go.State) |
|
|
|
{ |
|
|
|
case Actions.ToggleGameObjectAction.GameObjectToggle.GameObjectToggleState.Disable: |
|
|
|
go.GameObject.SetActive(true); |
|
|
|
break; |
|
|
|
case Actions.ToggleGameObjectAction.GameObjectToggle.GameObjectToggleState.Enable: |
|
|
|
go.GameObject.SetActive(false); |
|
|
|
break; |
|
|
|
case Actions.ToggleGameObjectAction.GameObjectToggle.GameObjectToggleState.Toggle: |
|
|
|
go.GameObject.SetActive(go.GameObject.activeSelf); |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// Set the new item
|
|
|
|
selectedDiscover = newSelection; |
|
|
|
|
|
|
|
if (selectedDiscover.ObjectsToToggle != null) |
|
|
|
{ |
|
|
|
// Toggle Next GameObjects State
|
|
|
|
foreach (var go in selectedDiscover.ObjectsToToggle) |
|
|
|
{ |
|
|
|
if (go.GameObject == null) |
|
|
|
continue; |
|
|
|
|
|
|
|
switch (go.State) |
|
|
|
{ |
|
|
|
case Actions.ToggleGameObjectAction.GameObjectToggle.GameObjectToggleState.Disable: |
|
|
|
go.GameObject.SetActive(false); |
|
|
|
break; |
|
|
|
case Actions.ToggleGameObjectAction.GameObjectToggle.GameObjectToggleState.Enable: |
|
|
|
go.GameObject.SetActive(true); |
|
|
|
break; |
|
|
|
case Actions.ToggleGameObjectAction.GameObjectToggle.GameObjectToggleState.Toggle: |
|
|
|
go.GameObject.SetActive(go.GameObject.activeSelf); |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
contentScroll = Vector2.zero; |
|
|
|
} |
|
|
|
|
|
|
|
void LoadSceneSetup(EditorSceneSetup setup) |
|
|
|