升级6.4.升级水,升级天气
This commit is contained in:
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6bb3cca4ed9b24b4c9c97a95f6cafba8
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
@@ -1,7 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 842468ccf23564770b4b1cb9f7eca30e
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,16 +0,0 @@
|
||||
{
|
||||
"name": "VFavorites",
|
||||
"rootNamespace": "",
|
||||
"references": [],
|
||||
"includePlatforms": [
|
||||
"Editor"
|
||||
],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d8266c7db84a045d3b706b23e60aa197
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6651039474d594cdd91489768cf293f6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,225 +0,0 @@
|
||||
#if UNITY_EDITOR
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
using UnityEditor;
|
||||
using UnityEditor.ShortcutManagement;
|
||||
using System.Reflection;
|
||||
using System.Linq;
|
||||
using UnityEngine.UIElements;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEditor.SceneManagement;
|
||||
using Type = System.Type;
|
||||
using static VFavorites.VFavoritesState;
|
||||
using static VFavorites.Libs.VUtils;
|
||||
using static VFavorites.Libs.VGUI;
|
||||
|
||||
|
||||
|
||||
namespace VFavorites
|
||||
{
|
||||
public class VFavoritesData : ScriptableObject
|
||||
{
|
||||
public List<Page> pages = new List<Page>();
|
||||
|
||||
public Page curPage
|
||||
{
|
||||
get
|
||||
{
|
||||
while (curPageIndex >= pages.Count - 1)
|
||||
pages.Add(new Page("Page " + (pages.Count + 1)));
|
||||
|
||||
return pages[curPageIndex];
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public int curPageIndex { get => VFavoritesState.instance.curPageIndex; set => VFavoritesState.instance.curPageIndex = value; }
|
||||
|
||||
public float rowScale = 1;
|
||||
|
||||
|
||||
[System.Serializable]
|
||||
public class Page
|
||||
{
|
||||
public List<Item> items = new List<Item>();
|
||||
|
||||
public string name = "";
|
||||
|
||||
public Page(string name) => this.name = name;
|
||||
|
||||
|
||||
|
||||
|
||||
[System.NonSerialized]
|
||||
public List<float> _rowGaps = new List<float>();
|
||||
public List<float> rowGaps
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_rowGaps == null)
|
||||
_rowGaps = new List<float>();
|
||||
|
||||
while (_rowGaps.Count < items.Count + 1) _rowGaps.Add(0);
|
||||
while (_rowGaps.Count > items.Count + 1) _rowGaps.RemoveLast();
|
||||
|
||||
return _rowGaps;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public float scrollPos { get => state.scrollPos; set => state.scrollPos = value; }
|
||||
|
||||
public long lastItemSelectTime_ticks { get => state.lastItemSelectTime_ticks; set => state.lastItemSelectTime_ticks = value; }
|
||||
public long lastItemDragTime_ticks { get => state.lastItemDragTime_ticks; set => state.lastItemDragTime_ticks = value; }
|
||||
|
||||
|
||||
public PageState state
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!VFavoritesState.instance.pageStates_byPageId.ContainsKey(id))
|
||||
VFavoritesState.instance.pageStates_byPageId[id] = new PageState();
|
||||
|
||||
return VFavoritesState.instance.pageStates_byPageId[id];
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public int id
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_id == 0)
|
||||
_id = Random.value.GetHashCode();
|
||||
|
||||
return _id;
|
||||
|
||||
}
|
||||
}
|
||||
public int _id = 0;
|
||||
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class Item
|
||||
{
|
||||
public GlobalID globalId;
|
||||
|
||||
|
||||
public Type type => Type.GetType(_typeString) ?? typeof(DefaultAsset);
|
||||
public string _typeString;
|
||||
|
||||
public Object obj => _obj != null ? _obj : (_obj = globalId.GetObject());
|
||||
public Object _obj;
|
||||
|
||||
|
||||
public bool isSceneGameObject;
|
||||
public bool isFolder;
|
||||
public bool isAsset;
|
||||
|
||||
|
||||
public bool isLoadable => obj != null;
|
||||
|
||||
public bool isDeleted
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!isSceneGameObject)
|
||||
return !isLoadable;
|
||||
|
||||
if (isLoadable)
|
||||
return false;
|
||||
|
||||
if (!AssetDatabase.LoadAssetAtPath<SceneAsset>(globalId.guid.ToPath()))
|
||||
return true;
|
||||
|
||||
for (int i = 0; i < EditorSceneManager.sceneCount; i++)
|
||||
if (EditorSceneManager.GetSceneAt(i).path == globalId.guid.ToPath())
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public string assetPath => globalId.guid.ToPath();
|
||||
|
||||
|
||||
public Item(Object o)
|
||||
{
|
||||
globalId = o.GetGlobalID();
|
||||
|
||||
|
||||
isSceneGameObject = o is GameObject go && go.scene.rootCount != 0;
|
||||
isFolder = AssetDatabase.IsValidFolder(o.GetPath());
|
||||
isAsset = !isSceneGameObject && !isFolder;
|
||||
|
||||
_typeString = o.GetType().AssemblyQualifiedName;
|
||||
|
||||
_name = o.name;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public string name
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!isLoadable) return _name;
|
||||
|
||||
if (assetPath.GetExtension() == ".cs")
|
||||
_name = obj.name.Decamelcase();
|
||||
else
|
||||
_name = obj.name;
|
||||
|
||||
return _name;
|
||||
|
||||
}
|
||||
}
|
||||
public string _name { get => state._name; set => state._name = value; }
|
||||
|
||||
public string sceneGameObjectIconName { get => state.sceneGameObjectIconName; set => state.sceneGameObjectIconName = value; }
|
||||
|
||||
public long lastSelectTime_ticks { get => state.lastSelectTime_ticks; set => state.lastSelectTime_ticks = value; }
|
||||
public bool isSelected { get => state.isSelected; set => state.isSelected = value; }
|
||||
|
||||
|
||||
|
||||
public ItemState state
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!VFavoritesState.instance.itemStates_byItemId.ContainsKey(id))
|
||||
VFavoritesState.instance.itemStates_byItemId[id] = new ItemState();
|
||||
|
||||
return VFavoritesState.instance.itemStates_byItemId[id];
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public int id
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_id == 0)
|
||||
_id = Random.value.GetHashCode();
|
||||
|
||||
return _id;
|
||||
|
||||
}
|
||||
}
|
||||
public int _id = 0;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 066cf82f8f80d408c856e48fc8f1127b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 38092f82a4c054086826261d88277942
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,137 +0,0 @@
|
||||
#if UNITY_EDITOR
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using static VFavorites.Libs.VUtils;
|
||||
using static VFavorites.Libs.VGUI;
|
||||
|
||||
|
||||
|
||||
namespace VFavorites
|
||||
{
|
||||
public class VFavoritesMenu
|
||||
{
|
||||
|
||||
public static bool pageScrollEnabled { get => EditorPrefsCached.GetBool("vFavorites-pageScrollEnabled", true); set => EditorPrefsCached.SetBool("vFavorites-pageScrollEnabled", value); }
|
||||
public static bool numberKeysEnabled { get => EditorPrefsCached.GetBool("vFavorites-numberKeysEnabled", true); set => EditorPrefsCached.SetBool("vFavorites-numberKeysEnabled", value); }
|
||||
public static bool arrowKeysEnabled { get => EditorPrefsCached.GetBool("vFavorites-arrowKeysEnabled", true); set => EditorPrefsCached.SetBool("vFavorites-arrowKeysEnabled", value); }
|
||||
|
||||
public static bool fadeAnimationsEnabled { get => EditorPrefsCached.GetBool("vFavorites-fadeAnimationsEnabled", true); set => EditorPrefsCached.SetBool("vFavorites-fadeAnimationsEnabled", value); }
|
||||
public static bool pageScrollAnimationEnabled { get => EditorPrefsCached.GetBool("vFavorites-pageScrollAnimationEnabled", true); set => EditorPrefsCached.SetBool("vFavorites-pageScrollAnimationEnabled", value); }
|
||||
|
||||
public static int activeOnKeyCombination { get => EditorPrefsCached.GetInt("vFavorites-activeOnKeyCombination", 0); set => EditorPrefsCached.SetInt("vFavorites-activeOnKeyCombination", value); }
|
||||
public static bool activeOnAltEnabled { get => activeOnKeyCombination == 0; set => activeOnKeyCombination = 0; }
|
||||
public static bool activeOnAltShiftEnabled { get => activeOnKeyCombination == 1; set => activeOnKeyCombination = 1; }
|
||||
public static bool activeOnCtrlAltEnabled { get => activeOnKeyCombination == 2; set => activeOnKeyCombination = 2; }
|
||||
|
||||
public static bool pluginDisabled { get => EditorPrefsCached.GetBool("vFavorites-pluginDisabled", false); set => EditorPrefsCached.SetBool("vFavorites-pluginDisabled", value); }
|
||||
|
||||
|
||||
|
||||
|
||||
const string dir = "Tools/vFavorites/";
|
||||
|
||||
const string pageScroll = dir + "Scroll to change page";
|
||||
const string numberKeys = dir + "1-9 keys to change page";
|
||||
const string arrowKeys = dir + "Arrow keys to change page or selection ";
|
||||
|
||||
const string fadeAnimations = dir + "Fade animations";
|
||||
const string pageScrollAnimation = dir + "Page scroll animation";
|
||||
|
||||
const string activeOnAlt = dir + "Holding Alt";
|
||||
const string activeOnAltShift = dir + "Holding Alt and Shift";
|
||||
#if UNITY_EDITOR_OSX
|
||||
const string activeOnCtrlAlt = dir + "Holding Cmd and Alt";
|
||||
#else
|
||||
const string activeOnCtrlAlt = dir + "Holding Ctrl and Alt";
|
||||
|
||||
#endif
|
||||
|
||||
const string disablePlugin = dir + "Disable vFavorites";
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
[MenuItem(dir + "Shortcuts", false, 1)] static void dadsas() { }
|
||||
[MenuItem(dir + "Shortcuts", true, 1)] static bool dadsas123() => false;
|
||||
|
||||
[MenuItem(pageScroll, false, 2)] static void dadsadasadsdadsas() => pageScrollEnabled = !pageScrollEnabled;
|
||||
[MenuItem(pageScroll, true, 2)] static bool dadsadasdadsdasadsas() { Menu.SetChecked(pageScroll, pageScrollEnabled); return !pluginDisabled; }
|
||||
|
||||
[MenuItem(numberKeys, false, 4)] static void dadsadadsas() => numberKeysEnabled = !numberKeysEnabled;
|
||||
[MenuItem(numberKeys, true, 4)] static bool dadsaddasadsas() { Menu.SetChecked(numberKeys, numberKeysEnabled); return !pluginDisabled; }
|
||||
|
||||
[MenuItem(arrowKeys, false, 5)] static void dadsadaddassas() => arrowKeysEnabled = !arrowKeysEnabled;
|
||||
[MenuItem(arrowKeys, true, 5)] static bool dadadssaddasadsas() { Menu.SetChecked(arrowKeys, arrowKeysEnabled); return !pluginDisabled; }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
[MenuItem(dir + "Animations", false, 101)] static void dadsadsas() { }
|
||||
[MenuItem(dir + "Animations", true, 101)] static bool dadadssas123() => false;
|
||||
|
||||
[MenuItem(fadeAnimations, false, 102)] static void dadsdasadadsas() => fadeAnimationsEnabled = !fadeAnimationsEnabled;
|
||||
[MenuItem(fadeAnimations, true, 102)] static bool dadsadadsadsdasadsas() { Menu.SetChecked(fadeAnimations, fadeAnimationsEnabled); return !pluginDisabled; }
|
||||
|
||||
[MenuItem(pageScrollAnimation, false, 103)] static void dadsdasdasadadsas() => pageScrollAnimationEnabled = !pageScrollAnimationEnabled;
|
||||
[MenuItem(pageScrollAnimation, true, 103)] static bool dadsadaddassadsdasadsas() { Menu.SetChecked(pageScrollAnimation, pageScrollAnimationEnabled); return !pluginDisabled; }
|
||||
|
||||
|
||||
|
||||
|
||||
[MenuItem(dir + "Open when", false, 1001)] static void dadsaddssas() { }
|
||||
[MenuItem(dir + "Open when", true, 1001)] static bool dadadsssas123() => false;
|
||||
|
||||
[MenuItem(activeOnAlt, false, 1002)] static void dadsdasasdadsas() => activeOnAltEnabled = !activeOnAltEnabled;
|
||||
[MenuItem(activeOnAlt, true, 1002)] static bool dadsadadssdadsdasadsas() { Menu.SetChecked(activeOnAlt, activeOnAltEnabled); return !pluginDisabled; }
|
||||
|
||||
[MenuItem(activeOnAltShift, false, 1003)] static void dadsdasasdadsadsas() => activeOnAltShiftEnabled = !activeOnAltShiftEnabled;
|
||||
[MenuItem(activeOnAltShift, true, 1003)] static bool dadsadadssdasdadsdasadsas() { Menu.SetChecked(activeOnAltShift, activeOnAltShiftEnabled); return !pluginDisabled; }
|
||||
|
||||
[MenuItem(activeOnCtrlAlt, false, 1004)] static void dadsdasadasadssdadsas() => activeOnCtrlAltEnabled = !activeOnCtrlAltEnabled;
|
||||
[MenuItem(activeOnCtrlAlt, true, 1004)] static bool dadsadadsadssdadsdasadsas() { Menu.SetChecked(activeOnCtrlAlt, activeOnCtrlAltEnabled); return !pluginDisabled; }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
[MenuItem(dir + "More", false, 10001)] static void daasadsddsas() { }
|
||||
[MenuItem(dir + "More", true, 10001)] static bool dadsadsdasas123() => false;
|
||||
|
||||
[MenuItem(dir + "Open manual", false, 10002)]
|
||||
static void dadadssadsas() => AssetDatabase.OpenAsset(AssetDatabase.LoadAssetAtPath<Object>(GetScriptPath("VFavorites").GetParentPath().CombinePath("Manual.pdf")));
|
||||
|
||||
[MenuItem(dir + "Join our Discord", false, 10003)]
|
||||
static void dadasdsas() => Application.OpenURL("https://discord.gg/pUektnZeJT");
|
||||
|
||||
|
||||
// [MenuItem(dir + "Check out vInspector 2", false, 10003)]
|
||||
// static void dadadssadsas() => Application.OpenURL("https://assetstore.unity.com/packages/slug/252297?aid=1100lGLBn&pubref=checkoutvfav");
|
||||
|
||||
// [MenuItem(dir + "Get more Editor Enhancers/Get vHierarchy 2", false, 10003)]
|
||||
// static void dadadssadsas() => Application.OpenURL("https://assetstore.unity.com/packages/slug/251320?aid=1100lGLBn&pubref=menucheckout");
|
||||
|
||||
// [MenuItem(dir + "Get more Editor Enhancers/Get vFolders 2", false, 10004)]
|
||||
// static void dadadssaasddsas() => Application.OpenURL("https://assetstore.unity.com/packages/slug/263644?aid=1100lGLBn&pubref=menucheckout");
|
||||
|
||||
// [MenuItem(dir + "Get more Editor Enhancers/Get vTabs 2", false, 10005)]
|
||||
// static void dadadsadssaasddsas() => Application.OpenURL("https://assetstore.unity.com/packages/slug/263645?aid=1100lGLBn&pubref=menucheckout");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
[MenuItem(disablePlugin, false, 100001)] static void dadsadsdasadasdasdsadadsas() { pluginDisabled = !pluginDisabled; UnityEditor.Compilation.CompilationPipeline.RequestScriptCompilation(); }
|
||||
[MenuItem(disablePlugin, true, 100001)] static bool dadsaddssdaasadsadadsdasadsas() { Menu.SetChecked(disablePlugin, pluginDisabled); return true; }
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 65f8f6586ea4740238f667f8337cf6fb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,6 +0,0 @@
|
||||
|
||||
|
||||
// this file was present in a previus version and is supposed to be deleted now
|
||||
// but asset store update delivery system doesn't allow deleting files
|
||||
// so instead this file is now emptied
|
||||
// feel free to delete it if you want
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e1b1b30cd63e14da9a295742be768842
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,57 +0,0 @@
|
||||
#if UNITY_EDITOR
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
using UnityEditor;
|
||||
using UnityEditor.ShortcutManagement;
|
||||
using System.Reflection;
|
||||
using System.Linq;
|
||||
using UnityEngine.UIElements;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEditor.SceneManagement;
|
||||
using Type = System.Type;
|
||||
using static VFavorites.Libs.VUtils;
|
||||
using static VFavorites.Libs.VGUI;
|
||||
|
||||
|
||||
namespace VFavorites
|
||||
{
|
||||
[FilePath("Library/vFavorites State.asset", FilePathAttribute.Location.ProjectFolder)]
|
||||
public class VFavoritesState : ScriptableSingleton<VFavoritesState>
|
||||
{
|
||||
public int curPageIndex;
|
||||
|
||||
public SerializableDictionary<int, PageState> pageStates_byPageId = new SerializableDictionary<int, PageState>();
|
||||
|
||||
public SerializableDictionary<int, ItemState> itemStates_byItemId = new SerializableDictionary<int, ItemState>();
|
||||
|
||||
|
||||
[System.Serializable]
|
||||
public class PageState
|
||||
{
|
||||
public long lastItemSelectTime_ticks;
|
||||
public long lastItemDragTime_ticks;
|
||||
|
||||
public float scrollPos;
|
||||
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class ItemState
|
||||
{
|
||||
public string _name;
|
||||
|
||||
public string sceneGameObjectIconName;
|
||||
|
||||
public long lastSelectTime_ticks;
|
||||
public bool isSelected;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static void Save() => instance.Save(true);
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 362e220c378db4e97ae41fa35a6fb58f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,16 +0,0 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 066cf82f8f80d408c856e48fc8f1127b, type: 3}
|
||||
m_Name: vFavorites Data
|
||||
m_EditorClassIdentifier:
|
||||
pages: []
|
||||
rowScale: 1
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d87c77a488f1b9a438e7202836e4f5df
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e3f2ed9170013ed43ba2f91354f93f65
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
@@ -1,7 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d8e44b0f278584fbfa8ae00d01b2ce3f
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,16 +0,0 @@
|
||||
{
|
||||
"name": "VHierarchy",
|
||||
"rootNamespace": "",
|
||||
"references": [],
|
||||
"includePlatforms": [
|
||||
"Editor"
|
||||
],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2c3f48364a5004fd3a152fbdf5fea703
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 67e949be20d3641adbc9494ed5bd764e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,62 +0,0 @@
|
||||
#if UNITY_EDITOR
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using UnityEditor.ShortcutManagement;
|
||||
using System.Reflection;
|
||||
using System.Linq;
|
||||
using UnityEngine.UIElements;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEditor.SceneManagement;
|
||||
using Type = System.Type;
|
||||
using static VHierarchy.VHierarchyData;
|
||||
using static VHierarchy.Libs.VUtils;
|
||||
using static VHierarchy.Libs.VGUI;
|
||||
|
||||
|
||||
|
||||
namespace VHierarchy
|
||||
{
|
||||
[FilePath("Library/vHierarchy Cache.asset", FilePathAttribute.Location.ProjectFolder)]
|
||||
public class VHierarchyCache : ScriptableSingleton<VHierarchyCache>
|
||||
{
|
||||
// used for finding SceneData and SceneIdMap for objects that were moved out of their original scene
|
||||
public SerializableDictionary<int, string> originalSceneGuids_byInstanceId = new SerializableDictionary<int, string>();
|
||||
|
||||
// used as cache for converting GlobalID to InstanceID and as a way to find GameObjectData for prefabs in playmode (when prefabs produce invalid GlobalIDs)
|
||||
public SerializableDictionary<string, SceneIdMap> sceneIdMaps_bySceneGuid = new SerializableDictionary<string, SceneIdMap>();
|
||||
|
||||
// used for fetching icons set inside prefab instances in playmode (when prefabs produce invalid GlobalIDs)
|
||||
public SerializableDictionary<int, GlobalID> prefabInstanceGlobalIds_byInstanceIds = new SerializableDictionary<int, GlobalID>();
|
||||
|
||||
|
||||
[System.Serializable]
|
||||
public class SceneIdMap
|
||||
{
|
||||
public SerializableDictionary<int, GlobalID> globalIds_byInstanceId = new SerializableDictionary<int, GlobalID>();
|
||||
|
||||
public int instanceIdsHash;
|
||||
public int globalIdsHash;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static void Clear()
|
||||
{
|
||||
instance.originalSceneGuids_byInstanceId.Clear();
|
||||
instance.sceneIdMaps_bySceneGuid.Clear();
|
||||
|
||||
instance.Save(true);
|
||||
|
||||
}
|
||||
|
||||
// public static void Save() => instance.Save(true); // cache is never saved to disk, it just needs to survive domain reloads
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3fd3b966dd497472d86df0d7c9271088
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,6 +0,0 @@
|
||||
|
||||
|
||||
// this file was present in a previus version and is supposed to be deleted now
|
||||
// but asset store update delivery system doesn't allow deleting files
|
||||
// so instead this file is now emptied
|
||||
// feel free to delete it if you want
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d51d8117d96b64eaa9a83667bf4297d6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,575 +0,0 @@
|
||||
#if UNITY_EDITOR
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using UnityEditor.ShortcutManagement;
|
||||
using System.Reflection;
|
||||
using System.Linq;
|
||||
using UnityEngine.UIElements;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEditor.SceneManagement;
|
||||
using Type = System.Type;
|
||||
using static VHierarchy.VHierarchyData;
|
||||
using static VHierarchy.Libs.VUtils;
|
||||
using static VHierarchy.Libs.VGUI;
|
||||
|
||||
|
||||
|
||||
namespace VHierarchy
|
||||
{
|
||||
public class VHierarchyComponentWindow : EditorWindow
|
||||
{
|
||||
void OnGUI()
|
||||
{
|
||||
if (!component) { Close(); return; } // todo script components break on playmode
|
||||
|
||||
|
||||
void background()
|
||||
{
|
||||
position.SetPos(0, 0).Draw(GUIColors.windowBackground);
|
||||
}
|
||||
void outline()
|
||||
{
|
||||
if (Application.platform == RuntimePlatform.OSXEditor) return;
|
||||
|
||||
position.SetPos(0, 0).DrawOutline(Greyscale(.1f));
|
||||
|
||||
}
|
||||
void header()
|
||||
{
|
||||
var headerRect = ExpandWidthLabelRect(18).Resize(-1).AddWidthFromMid(6);
|
||||
var pinButtonRect = headerRect.SetWidthFromRight(17).SetHeightFromMid(17).Move(-21, .5f);
|
||||
var closeButtonRect = headerRect.SetWidthFromRight(16).SetHeightFromMid(16).Move(-3, .5f);
|
||||
|
||||
var backgroundColor = isDarkTheme ? Greyscale(.25f) : GUIColors.windowBackground;
|
||||
|
||||
void startDragging()
|
||||
{
|
||||
if (isResizingVertically) return;
|
||||
if (isResizingHorizontally) return;
|
||||
if (isDragged) return;
|
||||
if (!curEvent.isMouseDrag) return;
|
||||
if (!headerRect.IsHovered()) return;
|
||||
|
||||
|
||||
isDragged = true;
|
||||
|
||||
dragStartMousePos = EditorGUIUtility.GUIToScreenPoint(curEvent.mousePosition);
|
||||
dragStartWindowPos = position.position;
|
||||
|
||||
|
||||
isPinned = true;
|
||||
|
||||
if (floatingInstance == this)
|
||||
floatingInstance = null;
|
||||
|
||||
EditorApplication.RepaintHierarchyWindow();
|
||||
|
||||
|
||||
}
|
||||
void updateDragging()
|
||||
{
|
||||
if (!isDragged) return;
|
||||
|
||||
|
||||
var draggedPosition = dragStartWindowPos + EditorGUIUtility.GUIToScreenPoint(curEvent.mousePosition) - dragStartMousePos;
|
||||
|
||||
if (!curEvent.isRepaint)
|
||||
position = position.SetPos(draggedPosition);
|
||||
|
||||
|
||||
EditorGUIUtility.hotControl = EditorGUIUtility.GetControlID(FocusType.Passive);
|
||||
|
||||
}
|
||||
void stopDragging()
|
||||
{
|
||||
if (!isDragged) return;
|
||||
if (!curEvent.isMouseUp) return;
|
||||
|
||||
|
||||
isDragged = false;
|
||||
|
||||
EditorGUIUtility.hotControl = 0;
|
||||
|
||||
}
|
||||
|
||||
void background()
|
||||
{
|
||||
headerRect.Draw(backgroundColor);
|
||||
|
||||
headerRect.SetHeightFromBottom(1).Draw(isDarkTheme ? Greyscale(.2f) : Greyscale(.7f));
|
||||
|
||||
}
|
||||
void icon()
|
||||
{
|
||||
var iconRect = headerRect.SetWidth(20).MoveX(14).MoveY(-1);
|
||||
|
||||
GUI.Label(iconRect, VHierarchy.GetComponentIcon(component));
|
||||
|
||||
}
|
||||
void toggle()
|
||||
{
|
||||
var toggleRect = headerRect.MoveX(36).SetSize(20, 20);
|
||||
|
||||
|
||||
var pi_enabled = component.GetType().GetProperty("enabled") ??
|
||||
component.GetType().BaseType?.GetProperty("enabled") ??
|
||||
component.GetType().BaseType?.BaseType?.GetProperty("enabled") ??
|
||||
component.GetType().BaseType?.BaseType?.BaseType?.GetProperty("enabled");
|
||||
|
||||
|
||||
if (pi_enabled == null) return;
|
||||
|
||||
var enabled = (bool)pi_enabled.GetValue(component);
|
||||
|
||||
|
||||
if (GUI.Toggle(toggleRect, enabled, "") == enabled) return;
|
||||
|
||||
component.RecordUndo();
|
||||
pi_enabled.SetValue(component, !enabled);
|
||||
|
||||
}
|
||||
void name()
|
||||
{
|
||||
var nameRect = headerRect.MoveX(54).MoveY(-1);
|
||||
|
||||
var s = VHierarchy.GetComponentName(component);
|
||||
|
||||
if (isPinned)
|
||||
s += " of " + component.gameObject.name;
|
||||
|
||||
|
||||
SetLabelBold();
|
||||
|
||||
GUI.Label(nameRect, s);
|
||||
|
||||
ResetLabelStyle();
|
||||
|
||||
}
|
||||
void nameCurtain()
|
||||
{
|
||||
var flatColorRect = headerRect.SetX(pinButtonRect.x + 3).SetXMax(headerRect.xMax);
|
||||
var gradientRect = headerRect.SetXMax(flatColorRect.x).SetWidthFromRight(30);
|
||||
|
||||
flatColorRect.Draw(backgroundColor);
|
||||
gradientRect.DrawCurtainLeft(backgroundColor);
|
||||
|
||||
}
|
||||
void pinButton()
|
||||
{
|
||||
if (!isPinned && closeButtonRect.IsHovered()) return;
|
||||
|
||||
|
||||
var normalColor = isDarkTheme ? Greyscale(.65f) : Greyscale(.8f);
|
||||
var hoveredColor = isDarkTheme ? Greyscale(.9f) : normalColor;
|
||||
var activeColor = Color.white;
|
||||
|
||||
|
||||
|
||||
SetGUIColor(isPinned ? activeColor : pinButtonRect.IsHovered() ? hoveredColor : normalColor);
|
||||
|
||||
GUI.Label(pinButtonRect, EditorGUIUtility.IconContent("pinned"));
|
||||
|
||||
ResetGUIColor();
|
||||
|
||||
|
||||
SetGUIColor(Color.clear);
|
||||
|
||||
var clicked = GUI.Button(pinButtonRect, "");
|
||||
|
||||
ResetGUIColor();
|
||||
|
||||
|
||||
if (!clicked) return;
|
||||
|
||||
isPinned = !isPinned;
|
||||
|
||||
if (isPinned && floatingInstance == this)
|
||||
floatingInstance = null;
|
||||
|
||||
if (!isPinned && !floatingInstance)
|
||||
floatingInstance = this;
|
||||
|
||||
EditorApplication.RepaintHierarchyWindow();
|
||||
|
||||
|
||||
}
|
||||
void closeButton()
|
||||
{
|
||||
|
||||
SetGUIColor(Color.clear);
|
||||
|
||||
if (GUI.Button(closeButtonRect, ""))
|
||||
Close();
|
||||
|
||||
ResetGUIColor();
|
||||
|
||||
|
||||
var normalColor = isDarkTheme ? Greyscale(.65f) : Greyscale(.35f);
|
||||
var hoveredColor = isDarkTheme ? Greyscale(.9f) : normalColor;
|
||||
|
||||
|
||||
SetGUIColor(closeButtonRect.IsHovered() ? hoveredColor : normalColor);
|
||||
|
||||
GUI.Label(closeButtonRect, EditorGUIUtility.IconContent("CrossIcon"));
|
||||
|
||||
ResetGUIColor();
|
||||
|
||||
|
||||
if (isPinned) return;
|
||||
|
||||
var escRect = closeButtonRect.Move(-22, -1).SetWidth(70);
|
||||
|
||||
SetGUIEnabled(false);
|
||||
|
||||
if (closeButtonRect.IsHovered())
|
||||
GUI.Label(escRect, "Esc");
|
||||
|
||||
ResetGUIEnabled();
|
||||
|
||||
}
|
||||
|
||||
startDragging();
|
||||
updateDragging();
|
||||
stopDragging();
|
||||
|
||||
background();
|
||||
icon();
|
||||
toggle();
|
||||
name();
|
||||
nameCurtain();
|
||||
pinButton();
|
||||
closeButton();
|
||||
|
||||
}
|
||||
void body()
|
||||
{
|
||||
EditorGUIUtility.labelWidth = (this.position.width * .4f).Max(120);
|
||||
|
||||
|
||||
scrollPosition = EditorGUILayout.BeginScrollView(Vector2.up * scrollPosition).y;
|
||||
BeginIndent(17);
|
||||
|
||||
|
||||
editor?.OnInspectorGUI();
|
||||
|
||||
updateHeight();
|
||||
|
||||
|
||||
EndIndent(1);
|
||||
EditorGUILayout.EndScrollView();
|
||||
|
||||
|
||||
EditorGUIUtility.labelWidth = 0;
|
||||
|
||||
}
|
||||
|
||||
void updateHeight()
|
||||
{
|
||||
|
||||
ExpandWidthLabelRect(height: -5);
|
||||
|
||||
if (!curEvent.isRepaint) return;
|
||||
if (isResizingVertically) return;
|
||||
|
||||
|
||||
targetHeight = lastRect.y + 30;
|
||||
|
||||
position = position.SetHeight(targetHeight.Min(maxHeight));
|
||||
|
||||
|
||||
prevHeight = position.height;
|
||||
|
||||
}
|
||||
void updatePosition()
|
||||
{
|
||||
if (!curEvent.isLayout) return;
|
||||
|
||||
void calcDeltaTime()
|
||||
{
|
||||
deltaTime = (float)(EditorApplication.timeSinceStartup - lastLayoutTime);
|
||||
|
||||
if (deltaTime > .05f)
|
||||
deltaTime = .0166f;
|
||||
|
||||
lastLayoutTime = EditorApplication.timeSinceStartup;
|
||||
|
||||
}
|
||||
void resetCurPos()
|
||||
{
|
||||
if (currentPosition != default && !isPinned) return;
|
||||
|
||||
currentPosition = position.position; // position.position is always int, which can't be used for lerping
|
||||
|
||||
}
|
||||
void lerpCurPos()
|
||||
{
|
||||
if (isPinned) return;
|
||||
|
||||
var speed = 9;
|
||||
|
||||
SmoothDamp(ref currentPosition, targetPosition, speed, ref positionDeriv, deltaTime);
|
||||
// Lerp(ref currentPosition, targetPosition, speed, deltaTime);
|
||||
|
||||
}
|
||||
void setCurPos()
|
||||
{
|
||||
if (isPinned) return;
|
||||
|
||||
position = position.SetPos(currentPosition);
|
||||
|
||||
}
|
||||
|
||||
calcDeltaTime();
|
||||
resetCurPos();
|
||||
lerpCurPos();
|
||||
setCurPos();
|
||||
|
||||
}
|
||||
void closeOnEscape()
|
||||
{
|
||||
if (!curEvent.isKeyDown) return;
|
||||
if (curEvent.keyCode != KeyCode.Escape) return;
|
||||
|
||||
Close();
|
||||
}
|
||||
|
||||
void horizontalResize()
|
||||
{
|
||||
var showingScrollbar = targetHeight > maxHeight;
|
||||
|
||||
var resizeArea = this.position.SetPos(0, 0).SetWidthFromRight(showingScrollbar ? 3 : 5).AddHeightFromBottom(-20);
|
||||
|
||||
void startResize()
|
||||
{
|
||||
if (isDragged) return;
|
||||
if (isResizingHorizontally) return;
|
||||
if (!curEvent.isMouseDown && !curEvent.isMouseDrag) return;
|
||||
if (!resizeArea.IsHovered()) return;
|
||||
|
||||
isResizingHorizontally = true;
|
||||
|
||||
resizeStartMousePos = curEvent.mousePosition_screenSpace;
|
||||
resizeStartWindowSize = this.position.size;
|
||||
|
||||
}
|
||||
void updateResize()
|
||||
{
|
||||
if (!isResizingHorizontally) return;
|
||||
|
||||
|
||||
var resizedWidth = resizeStartWindowSize.x + curEvent.mousePosition_screenSpace.x - resizeStartMousePos.x;
|
||||
|
||||
var width = resizedWidth.Max(300);
|
||||
|
||||
if (!curEvent.isRepaint)
|
||||
position = position.SetWidth(width);
|
||||
|
||||
|
||||
EditorGUIUtility.hotControl = EditorGUIUtility.GetControlID(FocusType.Passive);
|
||||
// GUI.focused
|
||||
|
||||
}
|
||||
void stopResize()
|
||||
{
|
||||
if (!isResizingHorizontally) return;
|
||||
if (!curEvent.isMouseUp) return;
|
||||
|
||||
isResizingHorizontally = false;
|
||||
|
||||
EditorGUIUtility.hotControl = 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
EditorGUIUtility.AddCursorRect(resizeArea, MouseCursor.ResizeHorizontal);
|
||||
|
||||
startResize();
|
||||
updateResize();
|
||||
stopResize();
|
||||
|
||||
}
|
||||
void verticalResize()
|
||||
{
|
||||
var resizeArea = this.position.SetPos(0, 0).SetHeightFromBottom(5);
|
||||
|
||||
void startResize()
|
||||
{
|
||||
if (isDragged) return;
|
||||
if (isResizingVertically) return;
|
||||
if (!curEvent.isMouseDown && !curEvent.isMouseDrag) return;
|
||||
if (!resizeArea.IsHovered()) return;
|
||||
|
||||
isResizingVertically = true;
|
||||
|
||||
resizeStartMousePos = curEvent.mousePosition_screenSpace;
|
||||
resizeStartWindowSize = this.position.size;
|
||||
|
||||
}
|
||||
void updateResize()
|
||||
{
|
||||
if (!isResizingVertically) return;
|
||||
|
||||
|
||||
var resizedHeight = resizeStartWindowSize.y + curEvent.mousePosition_screenSpace.y - resizeStartMousePos.y;
|
||||
|
||||
var height = resizedHeight.Min(targetHeight).Max(50);
|
||||
|
||||
if (!curEvent.isRepaint)
|
||||
position = position.SetHeight(height);
|
||||
|
||||
maxHeight = height;
|
||||
|
||||
|
||||
EditorGUIUtility.hotControl = EditorGUIUtility.GetControlID(FocusType.Passive);
|
||||
// GUI.focused
|
||||
|
||||
}
|
||||
void stopResize()
|
||||
{
|
||||
if (!isResizingVertically) return;
|
||||
if (!curEvent.isMouseUp) return;
|
||||
|
||||
isResizingVertically = false;
|
||||
|
||||
EditorGUIUtility.hotControl = 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
EditorGUIUtility.AddCursorRect(resizeArea, MouseCursor.ResizeVertical);
|
||||
|
||||
startResize();
|
||||
updateResize();
|
||||
stopResize();
|
||||
|
||||
}
|
||||
|
||||
|
||||
background();
|
||||
outline();
|
||||
|
||||
horizontalResize();
|
||||
verticalResize();
|
||||
|
||||
|
||||
header();
|
||||
|
||||
Space(3);
|
||||
body();
|
||||
|
||||
Space(7);
|
||||
|
||||
|
||||
updatePosition();
|
||||
closeOnEscape();
|
||||
|
||||
if (!isPinned)
|
||||
Repaint();
|
||||
|
||||
}
|
||||
|
||||
public Vector2 targetPosition;
|
||||
public Vector2 currentPosition;
|
||||
Vector2 positionDeriv;
|
||||
float deltaTime;
|
||||
double lastLayoutTime;
|
||||
|
||||
bool isDragged;
|
||||
Vector2 dragStartMousePos;
|
||||
Vector2 dragStartWindowPos;
|
||||
|
||||
public bool isResizingHorizontally;
|
||||
public bool isResizingVertically;
|
||||
public Vector2 resizeStartMousePos;
|
||||
public Vector2 resizeStartWindowSize;
|
||||
|
||||
public float scrollPosition;
|
||||
|
||||
public float targetHeight;
|
||||
public float maxHeight;
|
||||
public float prevHeight;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void OnLostFocus()
|
||||
{
|
||||
if (isPinned) return;
|
||||
|
||||
if (curEvent.holdingAlt && EditorWindow.focusedWindow.GetType().Name == "SceneHierarchyWindow")
|
||||
CloseNextFrameIfNotRefocused();
|
||||
else
|
||||
Close();
|
||||
|
||||
}
|
||||
|
||||
void CloseNextFrameIfNotRefocused()
|
||||
{
|
||||
EditorApplication.delayCall += () => { if (EditorWindow.focusedWindow != this) Close(); };
|
||||
}
|
||||
|
||||
public bool isPinned;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public void Init(Component component)
|
||||
{
|
||||
if (editor)
|
||||
editor.DestroyImmediate();
|
||||
|
||||
this.component = component;
|
||||
this.editor = Editor.CreateEditor(component);
|
||||
|
||||
}
|
||||
|
||||
void OnDestroy()
|
||||
{
|
||||
editor?.DestroyImmediate();
|
||||
|
||||
editor = null;
|
||||
component = null;
|
||||
|
||||
EditorPrefs.SetFloat("vHierarchy-componentWindowWidth", position.width);
|
||||
|
||||
}
|
||||
|
||||
public Component component;
|
||||
public Editor editor;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static void CreateFloatingInstance(Vector2 position)
|
||||
{
|
||||
floatingInstance = ScriptableObject.CreateInstance<VHierarchyComponentWindow>();
|
||||
|
||||
floatingInstance.ShowPopup();
|
||||
|
||||
|
||||
floatingInstance.maxHeight = EditorGUIUtility.GetMainWindowPosition().height * .7f;
|
||||
|
||||
|
||||
var savedWidth = EditorPrefs.GetFloat("vHierarchy-componentWindowWidth", minWidth);
|
||||
|
||||
var width = savedWidth.Max(minWidth);
|
||||
|
||||
floatingInstance.position = Rect.zero.SetPos(position).SetWidth(width).SetHeight(200);
|
||||
floatingInstance.prevHeight = floatingInstance.position.height;
|
||||
|
||||
floatingInstance.targetPosition = position;
|
||||
|
||||
}
|
||||
|
||||
public static VHierarchyComponentWindow floatingInstance;
|
||||
|
||||
public static float minWidth => 300;
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4b48d49a631ab443990f28938cbdedb8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,76 +0,0 @@
|
||||
#if UNITY_EDITOR
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using UnityEditor.ShortcutManagement;
|
||||
using System.Reflection;
|
||||
using System.Linq;
|
||||
using UnityEngine.UIElements;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEditor.SceneManagement;
|
||||
using static VHierarchy.Libs.VUtils;
|
||||
using static VHierarchy.Libs.VGUI;
|
||||
|
||||
|
||||
|
||||
namespace VHierarchy
|
||||
{
|
||||
public class VHierarchyData : ScriptableObject, ISerializationCallbackReceiver
|
||||
{
|
||||
|
||||
public SerializableDictionary<string, SceneData> sceneDatas_byGuid = new SerializableDictionary<string, SceneData>();
|
||||
|
||||
|
||||
[System.Serializable]
|
||||
public class SceneData
|
||||
{
|
||||
public SerializableDictionary<GlobalID, GameObjectData> goDatas_byGlobalId = new SerializableDictionary<GlobalID, GameObjectData>();
|
||||
}
|
||||
|
||||
|
||||
[System.Serializable]
|
||||
public class GameObjectData
|
||||
{
|
||||
public int colorIndex;
|
||||
public string iconNameOrGuid = ""; // name for buildin icons, guid for custom ones
|
||||
|
||||
[System.NonSerialized] // set in GetGameObjectData
|
||||
public SceneData sceneData;
|
||||
|
||||
}
|
||||
|
||||
public void OnBeforeSerialize() => VHierarchy.firstDataCacheLayer.Clear();
|
||||
public void OnAfterDeserialize() => VHierarchy.firstDataCacheLayer.Clear();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
[CustomEditor(typeof(VHierarchyData))]
|
||||
class Editor : UnityEditor.Editor
|
||||
{
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
var style = new GUIStyle(EditorStyles.label) { wordWrap = true };
|
||||
|
||||
|
||||
SetGUIEnabled(false);
|
||||
BeginIndent(0);
|
||||
|
||||
Space(10);
|
||||
EditorGUILayout.LabelField("This file contains data about which icons and colors are assigned to objects", style);
|
||||
|
||||
Space(6);
|
||||
GUILayout.Label("If there are multiple people working on the project, you might want to store this data in scenes to avoid merge conflicts. To do that, create a script that inherits from VHierarchy.VHierarchyDataComponent and add it to any object in the scene", style);
|
||||
|
||||
EndIndent(10);
|
||||
ResetGUIEnabled();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3a9752b0c8e144801967e6897679604b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,95 +0,0 @@
|
||||
#if UNITY_EDITOR
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using UnityEditor.ShortcutManagement;
|
||||
using System.Reflection;
|
||||
using System.Linq;
|
||||
using UnityEngine.UIElements;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEditor.SceneManagement;
|
||||
using UnityEditor.Experimental.SceneManagement;
|
||||
using Type = System.Type;
|
||||
using static VHierarchy.VHierarchyData;
|
||||
using static VHierarchy.Libs.VUtils;
|
||||
using static VHierarchy.Libs.VGUI;
|
||||
|
||||
|
||||
|
||||
namespace VHierarchy
|
||||
{
|
||||
[ExecuteInEditMode]
|
||||
public abstract class VHierarchyDataComponent : MonoBehaviour, ISerializationCallbackReceiver
|
||||
{
|
||||
public void Awake()
|
||||
{
|
||||
void register()
|
||||
{
|
||||
VHierarchy.dataComponents_byScene[gameObject.scene] = this;
|
||||
}
|
||||
void handleSceneDuplication()
|
||||
{
|
||||
if (sceneData == null) return;
|
||||
if (!sceneData.goDatas_byGlobalId.Any()) return;
|
||||
|
||||
|
||||
var curSceneGuid = gameObject.scene.path.ToGuid();
|
||||
var dataSceneGuid = sceneData.goDatas_byGlobalId.Keys.First().guid;
|
||||
|
||||
if (curSceneGuid == dataSceneGuid) return;
|
||||
|
||||
|
||||
var newDic = new SerializableDictionary<GlobalID, GameObjectData>();
|
||||
|
||||
foreach (var kvp in sceneData.goDatas_byGlobalId)
|
||||
newDic[new GlobalID(kvp.Key.ToString().Replace(dataSceneGuid, curSceneGuid))] = kvp.Value;
|
||||
|
||||
|
||||
sceneData.goDatas_byGlobalId = newDic;
|
||||
|
||||
|
||||
EditorSceneManager.MarkSceneDirty(gameObject.scene);
|
||||
EditorSceneManager.SaveScene(gameObject.scene);
|
||||
|
||||
}
|
||||
|
||||
register();
|
||||
handleSceneDuplication();
|
||||
|
||||
}
|
||||
|
||||
public SceneData sceneData;
|
||||
|
||||
|
||||
public void OnBeforeSerialize() => VHierarchy.firstDataCacheLayer.Clear();
|
||||
public void OnAfterDeserialize() => VHierarchy.firstDataCacheLayer.Clear();
|
||||
|
||||
|
||||
|
||||
[CustomEditor(typeof(VHierarchyDataComponent), true)]
|
||||
class Editor : UnityEditor.Editor
|
||||
{
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
var style = EditorStyles.label;
|
||||
style.wordWrap = true;
|
||||
|
||||
|
||||
SetGUIEnabled(false);
|
||||
BeginIndent(0);
|
||||
|
||||
Space(4);
|
||||
EditorGUILayout.LabelField("This component stores vHierarchy icons and colors that are assigned to objects in this scene", style);
|
||||
|
||||
Space(2);
|
||||
|
||||
EndIndent(10);
|
||||
ResetGUIEnabled();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9e20c7ea1a24b4a899ba82e98ad2b375
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,6 +0,0 @@
|
||||
|
||||
|
||||
// this file was present in a previus version and is supposed to be deleted now
|
||||
// but asset store update delivery system doesn't allow deleting files
|
||||
// so instead this file is now emptied
|
||||
// feel free to delete it if you want
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8710ada63f66c4909ab73d206f31e954
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cd278e4ae9a8649f59f016c7d739ce1a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,353 +0,0 @@
|
||||
#if UNITY_EDITOR
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using UnityEditor.ShortcutManagement;
|
||||
using System.Reflection;
|
||||
using System.Linq;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEditor.SceneManagement;
|
||||
using static VHierarchy.Libs.VUtils;
|
||||
using static VHierarchy.Libs.VGUI;
|
||||
|
||||
|
||||
namespace VHierarchy
|
||||
{
|
||||
public class VHierarchyLightingWindow : EditorWindow
|
||||
{
|
||||
void OnGUI()
|
||||
{
|
||||
void updateSize()
|
||||
{
|
||||
var r = ExpandWidthLabelRect();
|
||||
|
||||
if (!curEvent.isRepaint) return;
|
||||
|
||||
var curHeight = r.y;
|
||||
|
||||
this.position = position.SetWidth(initWidth).SetHeight(curHeight);
|
||||
|
||||
this.minSize = Vector2.zero;
|
||||
this.maxSize = Vector2.one * 123212;
|
||||
|
||||
}
|
||||
|
||||
void header()
|
||||
{
|
||||
var height = 22f;
|
||||
|
||||
var headerRect = Rect.zero.SetHeight(height).SetWidth(position.width);
|
||||
var pinButtonRect = headerRect.SetWidthFromRight(17).SetHeightFromMid(17).Move(-21, .5f);
|
||||
var closeButtonRect = headerRect.SetWidthFromRight(16).SetHeightFromMid(16).Move(-3, .5f);
|
||||
|
||||
void startDragging()
|
||||
{
|
||||
if (isDragged) return;
|
||||
if (!curEvent.isMouseDrag) return;
|
||||
if (!headerRect.IsHovered()) return;
|
||||
|
||||
|
||||
isDragged = true;
|
||||
|
||||
dragStartMousePos = EditorGUIUtility.GUIToScreenPoint(curEvent.mousePosition);
|
||||
dragStartWindowPos = position.position;
|
||||
|
||||
|
||||
isPinned = true;
|
||||
|
||||
EditorApplication.RepaintHierarchyWindow();
|
||||
|
||||
|
||||
}
|
||||
void updateDragging()
|
||||
{
|
||||
if (!isDragged) return;
|
||||
|
||||
if (!curEvent.isRepaint) // ??
|
||||
position = position.SetPos(dragStartWindowPos + EditorGUIUtility.GUIToScreenPoint(curEvent.mousePosition) - dragStartMousePos);
|
||||
|
||||
EditorGUIUtility.hotControl = EditorGUIUtility.GetControlID(FocusType.Passive);
|
||||
|
||||
}
|
||||
void stopDragging()
|
||||
{
|
||||
if (!isDragged) return;
|
||||
if (!curEvent.isMouseUp) return;
|
||||
|
||||
isDragged = false;
|
||||
|
||||
EditorGUIUtility.hotControl = 0;
|
||||
|
||||
}
|
||||
|
||||
void background()
|
||||
{
|
||||
headerRect.Draw(EditorGUIUtility.isProSkin ? Greyscale(.185f) : Greyscale(.7f));
|
||||
}
|
||||
void title_()
|
||||
{
|
||||
SetGUIColor(Greyscale(.8f));
|
||||
SetLabelAlignmentCenter();
|
||||
|
||||
GUI.Label(headerRect, "Lighting");
|
||||
|
||||
ResetLabelStyle();
|
||||
ResetGUIColor();
|
||||
|
||||
}
|
||||
void pinButton()
|
||||
{
|
||||
if (!isPinned && closeButtonRect.IsHovered()) return;
|
||||
|
||||
|
||||
var normalColor = isDarkTheme ? Greyscale(.65f) : Greyscale(.8f);
|
||||
var hoveredColor = isDarkTheme ? Greyscale(.9f) : normalColor;
|
||||
var activeColor = Color.white;
|
||||
|
||||
|
||||
|
||||
SetGUIColor(isPinned ? activeColor : pinButtonRect.IsHovered() ? hoveredColor : normalColor);
|
||||
|
||||
GUI.Label(pinButtonRect, EditorGUIUtility.IconContent("pinned"));
|
||||
|
||||
ResetGUIColor();
|
||||
|
||||
|
||||
SetGUIColor(Color.clear);
|
||||
|
||||
var clicked = GUI.Button(pinButtonRect, "");
|
||||
|
||||
ResetGUIColor();
|
||||
|
||||
|
||||
if (!clicked) return;
|
||||
|
||||
isPinned = !isPinned;
|
||||
|
||||
}
|
||||
void closeButton()
|
||||
{
|
||||
|
||||
SetGUIColor(Color.clear);
|
||||
|
||||
if (GUI.Button(closeButtonRect, "") || (curEvent.isKeyDown && curEvent.keyCode == KeyCode.Escape))
|
||||
Close();
|
||||
|
||||
ResetGUIColor();
|
||||
|
||||
|
||||
var normalColor = isDarkTheme ? Greyscale(.65f) : Greyscale(.35f);
|
||||
var hoveredColor = isDarkTheme ? Greyscale(.9f) : normalColor;
|
||||
|
||||
|
||||
SetGUIColor(closeButtonRect.IsHovered() ? hoveredColor : normalColor);
|
||||
|
||||
GUI.Label(closeButtonRect, EditorGUIUtility.IconContent("CrossIcon"));
|
||||
|
||||
ResetGUIColor();
|
||||
|
||||
|
||||
if (isPinned) return;
|
||||
|
||||
var escRect = closeButtonRect.Move(-22, -1).SetWidth(70);
|
||||
|
||||
SetGUIEnabled(false);
|
||||
|
||||
if (closeButtonRect.IsHovered())
|
||||
GUI.Label(escRect, "Esc");
|
||||
|
||||
ResetGUIEnabled();
|
||||
|
||||
}
|
||||
|
||||
|
||||
startDragging();
|
||||
updateDragging();
|
||||
stopDragging();
|
||||
|
||||
background();
|
||||
title_();
|
||||
pinButton();
|
||||
closeButton();
|
||||
|
||||
Space(height);
|
||||
|
||||
}
|
||||
void directionalLight()
|
||||
{
|
||||
var light = FindObjects<Light>().Where(r => r.type == LightType.Directional && r.gameObject.scene == EditorSceneManager.GetActiveScene()).FirstOrDefault();
|
||||
|
||||
if (!light) return;
|
||||
|
||||
light.RecordUndo();
|
||||
light.transform.RecordUndo();
|
||||
|
||||
|
||||
ObjectFieldWidhoutPicker("Directional Light", light);
|
||||
|
||||
|
||||
Space(2);
|
||||
BeginIndent(8);
|
||||
EditorGUIUtility.labelWidth += 2;
|
||||
|
||||
var rotX = light.transform.eulerAngles.x.Loop(-180, 180).Round();
|
||||
var rotY = light.transform.eulerAngles.y.Loop(-180, 180).Round();
|
||||
rotX = EditorGUILayout.Slider("Rotation X", rotX, 0, 90);
|
||||
rotY = EditorGUILayout.Slider("Rotation Y", rotY, -179, 180);
|
||||
if (light.transform.rotation != Quaternion.Euler(rotX, rotY, light.transform.eulerAngles.z))
|
||||
light.transform.rotation = Quaternion.Euler(rotX, rotY, light.transform.eulerAngles.z);
|
||||
|
||||
|
||||
Space(3);
|
||||
light.intensity = EditorGUILayout.Slider("Intensity", light.intensity, 0, 2);
|
||||
light.color = SmallColorField(ExpandWidthLabelRect().AddWidthFromMid(-1).MoveX(-.5f), "Color", light.color, true);
|
||||
|
||||
EndIndent();
|
||||
|
||||
}
|
||||
void ambientLight()
|
||||
{
|
||||
RenderSettings.ambientMode = (UnityEngine.Rendering.AmbientMode)EditorGUILayout.IntPopup("Ambient Light", (int)RenderSettings.ambientMode, new[] { "\u2009Skybox", "\u2009Gradient", "\u2009Color" }, new[] { 0, 1, 3 });
|
||||
|
||||
foreach (var r in FindObjects<RenderSettings>())
|
||||
r.RecordUndo();
|
||||
|
||||
|
||||
Space(2);
|
||||
BeginIndent(8);
|
||||
EditorGUIUtility.labelWidth += 4;
|
||||
|
||||
if (RenderSettings.ambientMode == UnityEngine.Rendering.AmbientMode.Flat)
|
||||
{
|
||||
|
||||
|
||||
Color.RGBToHSV(RenderSettings.ambientSkyColor, out float h, out float s, out float v);
|
||||
v = EditorGUILayout.Slider("Intensity", v, .01f, 2);
|
||||
RenderSettings.ambientSkyColor = Color.HSVToRGB(h, s, v, true);
|
||||
|
||||
RenderSettings.ambientSkyColor = SmallColorField("Color", RenderSettings.ambientSkyColor, false, true);
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (RenderSettings.ambientMode == UnityEngine.Rendering.AmbientMode.Skybox)
|
||||
RenderSettings.ambientIntensity = EditorGUILayout.Slider("Intensity", RenderSettings.ambientIntensity, 0, 2);
|
||||
|
||||
if (RenderSettings.ambientMode == UnityEngine.Rendering.AmbientMode.Trilight)
|
||||
{
|
||||
RenderSettings.ambientSkyColor = SmallColorField("Color Sky", RenderSettings.ambientSkyColor, false, true);
|
||||
RenderSettings.ambientEquatorColor = SmallColorField("Color Horizon", RenderSettings.ambientEquatorColor, false, true);
|
||||
RenderSettings.ambientGroundColor = SmallColorField("Color Ground", RenderSettings.ambientGroundColor, false, true);
|
||||
}
|
||||
|
||||
EndIndent();
|
||||
|
||||
}
|
||||
void fog()
|
||||
{
|
||||
var mode = EditorGUILayout.IntPopup("Fog", RenderSettings.fog ? (int)RenderSettings.fogMode : 0, new[] { "\u2009Off", "\u2009Linear", "\u2009Exponential", "\u2009Exponential Squared" }, new[] { 0, 1, 2, 3 });
|
||||
|
||||
if (RenderSettings.fog = mode != 0)
|
||||
RenderSettings.fogMode = (FogMode)mode;
|
||||
|
||||
if (!RenderSettings.fog) return;
|
||||
|
||||
Space(2);
|
||||
BeginIndent(8);
|
||||
EditorGUIUtility.labelWidth += 4;
|
||||
|
||||
if (RenderSettings.fogMode == FogMode.Linear)
|
||||
{
|
||||
RenderSettings.fogStartDistance = EditorGUILayout.FloatField("Start", RenderSettings.fogStartDistance);
|
||||
RenderSettings.fogEndDistance = EditorGUILayout.FloatField("End", RenderSettings.fogEndDistance);
|
||||
|
||||
}
|
||||
else
|
||||
RenderSettings.fogDensity = ExpSlider(ExpandWidthLabelRect().AddWidthFromRight(1.5f), "Density", RenderSettings.fogDensity, 0, .05f);
|
||||
|
||||
|
||||
RenderSettings.fogColor = SmallColorField("Color", RenderSettings.fogColor, true, false);
|
||||
|
||||
EndIndent();
|
||||
|
||||
}
|
||||
|
||||
|
||||
header();
|
||||
|
||||
|
||||
BeginIndent(6);
|
||||
|
||||
EditorGUIUtility.labelWidth = 115;
|
||||
|
||||
Space(11);
|
||||
directionalLight();
|
||||
|
||||
Space(18);
|
||||
ambientLight();
|
||||
|
||||
Space(18);
|
||||
fog();
|
||||
|
||||
EndIndent(6);
|
||||
|
||||
Space(21);
|
||||
|
||||
updateSize();
|
||||
|
||||
|
||||
if (Application.platform != RuntimePlatform.OSXEditor)
|
||||
position.SetPos(0, 0).DrawOutline(Greyscale(.1f));
|
||||
|
||||
EditorGUIUtility.labelWidth = 0;
|
||||
|
||||
Repaint();
|
||||
|
||||
|
||||
}
|
||||
|
||||
bool isDragged;
|
||||
Vector2 dragStartMousePos;
|
||||
Vector2 dragStartWindowPos;
|
||||
|
||||
|
||||
|
||||
void OnLostFocus()
|
||||
{
|
||||
if (isPinned) return;
|
||||
|
||||
Close();
|
||||
|
||||
}
|
||||
|
||||
public bool isPinned;
|
||||
|
||||
|
||||
|
||||
|
||||
public static void CreateInstance(Vector2 position)
|
||||
{
|
||||
instance = ScriptableObject.CreateInstance<VHierarchyLightingWindow>();
|
||||
|
||||
instance.ShowPopup();
|
||||
|
||||
instance.position = Rect.zero.SetPos(position).SetSize(initWidth, initHeight);
|
||||
|
||||
instance.minSize = Vector2.zero;
|
||||
instance.maxSize = Vector2.one * 123212;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static VHierarchyLightingWindow instance;
|
||||
|
||||
|
||||
|
||||
|
||||
static float initWidth => 250;
|
||||
static float initHeight => 320;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 25324ddc1ebdc4ee5b1d9902a8efafa7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,151 +0,0 @@
|
||||
#if UNITY_EDITOR
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using static VHierarchy.Libs.VUtils;
|
||||
using static VHierarchy.Libs.VGUI;
|
||||
|
||||
|
||||
|
||||
namespace VHierarchy
|
||||
{
|
||||
class VHierarchyMenu
|
||||
{
|
||||
|
||||
public static bool componentMinimapEnabled { get => EditorPrefsCached.GetBool("vHierarchy-componentMinimapEnabled", false); set => EditorPrefsCached.SetBool("vHierarchy-componentMinimapEnabled", value); }
|
||||
public static bool hierarchyLinesEnabled { get => EditorPrefsCached.GetBool("vHierarchy-hierarchyLinesEnabled", false); set => EditorPrefsCached.SetBool("vHierarchy-hierarchyLinesEnabled", value); }
|
||||
public static bool minimalModeEnabled { get => EditorPrefsCached.GetBool("vHierarchy-minimalModeEnabled", false); set => EditorPrefsCached.SetBool("vHierarchy-minimalModeEnabled", value); }
|
||||
public static bool zebraStripingEnabled { get => EditorPrefsCached.GetBool("vHierarchy-zebraStripingEnabled", false); set => EditorPrefsCached.SetBool("vHierarchy-zebraStripingEnabled", value); }
|
||||
public static bool activationToggleEnabled { get => EditorPrefsCached.GetBool("vHierarchy-acctivationToggleEnabled", false); set => EditorPrefsCached.SetBool("vHierarchy-acctivationToggleEnabled", value); }
|
||||
public static bool collapseAllButtonEnabled { get => EditorPrefsCached.GetBool("vHierarchy-collapseAllButtonEnabled", false); set => EditorPrefsCached.SetBool("vHierarchy-collapseAllButtonEnabled", value); }
|
||||
public static bool editLightingButtonEnabled { get => EditorPrefsCached.GetBool("vHierarchy-editLightingButtonEnabled", false); set => EditorPrefsCached.SetBool("vHierarchy-editLightingButtonEnabled", value); }
|
||||
|
||||
public static bool toggleActiveEnabled { get => EditorPrefsCached.GetBool("vHierarchy-toggleActiveEnabled", true); set => EditorPrefsCached.SetBool("vHierarchy-toggleActiveEnabled", value); }
|
||||
public static bool focusEnabled { get => EditorPrefsCached.GetBool("vHierarchy-focusEnabled", true); set => EditorPrefsCached.SetBool("vHierarchy-focusEnabled", value); }
|
||||
public static bool deleteEnabled { get => EditorPrefsCached.GetBool("vHierarchy-deleteEnabled", true); set => EditorPrefsCached.SetBool("vHierarchy-deleteEnabled", value); }
|
||||
public static bool toggleExpandedEnabled { get => EditorPrefsCached.GetBool("vHierarchy-toggleExpandedEnabled", true); set => EditorPrefsCached.SetBool("vHierarchy-toggleExpandedEnabled", value); }
|
||||
public static bool collapseEverythingElseEnabled { get => EditorPrefsCached.GetBool("vHierarchy-collapseEverythingElseEnabled", true); set => EditorPrefsCached.SetBool("vHierarchy-collapseEverythingElseEnabled", value); }
|
||||
public static bool collapseEverythingEnabled { get => EditorPrefsCached.GetBool("vHierarchy-collapseEverythingEnabled", true); set => EditorPrefsCached.SetBool("vHierarchy-collapseEverythingEnabled", value); }
|
||||
|
||||
public static bool pluginDisabled { get => EditorPrefsCached.GetBool("vHierarchy-pluginDisabled", false); set => EditorPrefsCached.SetBool("vHierarchy-pluginDisabled", value); }
|
||||
|
||||
|
||||
|
||||
|
||||
const string dir = "Tools/vHierarchy/";
|
||||
|
||||
const string componentMinimap = dir + "Component minimap";
|
||||
const string hierarchyLines = dir + "Hierarchy lines";
|
||||
const string minimalMode = dir + "Minimal mode";
|
||||
const string zebraStriping = dir + "Zebra striping";
|
||||
const string activationToggle = dir + "Activation toggle";
|
||||
const string collapseAllButton = dir + "Collapse All button";
|
||||
const string editLightingButton = dir + "Edit Lighting button";
|
||||
|
||||
const string toggleActive = dir + "A to toggle active";
|
||||
const string focus = dir + "F to focus";
|
||||
const string delete = dir + "X to delete";
|
||||
const string toggleExpanded = dir + "E to expand or collapse";
|
||||
const string collapseEverythingElse = dir + "Shift-E to isolate";
|
||||
const string collapseEverything = dir + "Ctrl-Shift-E to collapse all";
|
||||
|
||||
const string disablePlugin = dir + "Disable vHierarchy";
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
[MenuItem(dir + "Features", false, 1)] static void daasddsas() { }
|
||||
[MenuItem(dir + "Features", true, 1)] static bool dadsdasas123() => false;
|
||||
|
||||
[MenuItem(componentMinimap, false, 2)] static void daadsdsadasdadsas() { componentMinimapEnabled = !componentMinimapEnabled; EditorApplication.RepaintHierarchyWindow(); }
|
||||
[MenuItem(componentMinimap, true, 2)] static bool dadsadasddasadsas() { Menu.SetChecked(componentMinimap, componentMinimapEnabled); return !pluginDisabled; }
|
||||
|
||||
[MenuItem(hierarchyLines, false, 3)] static void dadsadadsadadasss() { hierarchyLinesEnabled = !hierarchyLinesEnabled; EditorApplication.RepaintHierarchyWindow(); }
|
||||
[MenuItem(hierarchyLines, true, 3)] static bool dadsaddasdasaasddsas() { Menu.SetChecked(hierarchyLines, hierarchyLinesEnabled); return !pluginDisabled; }
|
||||
|
||||
[MenuItem(minimalMode, false, 4)] static void dadsadadasdsdasadadasss() { minimalModeEnabled = !minimalModeEnabled; EditorApplication.RepaintHierarchyWindow(); }
|
||||
[MenuItem(minimalMode, true, 4)] static bool dadsaddadsasdadsasaasddsas() { Menu.SetChecked(minimalMode, minimalModeEnabled); return !pluginDisabled; }
|
||||
|
||||
[MenuItem(zebraStriping, false, 5)] static void dadsadadadssadsadass() { zebraStripingEnabled = !zebraStripingEnabled; EditorApplication.RepaintHierarchyWindow(); }
|
||||
[MenuItem(zebraStriping, true, 5)] static bool dadsaddadaadsssadsaasddsas() { Menu.SetChecked(zebraStriping, zebraStripingEnabled); return !pluginDisabled; }
|
||||
|
||||
[MenuItem(activationToggle, false, 6)] static void daadsdsadadsasdadsas() { activationToggleEnabled = !activationToggleEnabled; EditorApplication.RepaintHierarchyWindow(); }
|
||||
[MenuItem(activationToggle, true, 6)] static bool dadsadasdsaddasadsas() { Menu.SetChecked(activationToggle, activationToggleEnabled); return !pluginDisabled; }
|
||||
|
||||
[MenuItem(collapseAllButton, false, 7)] static void daadsdsadadsadadsas() { collapseAllButtonEnabled = !collapseAllButtonEnabled; EditorApplication.RepaintHierarchyWindow(); }
|
||||
[MenuItem(collapseAllButton, true, 7)] static bool dadsadasdsaddasdsas() { Menu.SetChecked(collapseAllButton, collapseAllButtonEnabled); return !pluginDisabled; }
|
||||
|
||||
[MenuItem(editLightingButton, false, 8)] static void daadsdsasdadadsadadsas() { editLightingButtonEnabled = !editLightingButtonEnabled; EditorApplication.RepaintHierarchyWindow(); }
|
||||
[MenuItem(editLightingButton, true, 8)] static bool dadsadasdsadsaddasdsas() { Menu.SetChecked(editLightingButton, editLightingButtonEnabled); return !pluginDisabled; }
|
||||
|
||||
|
||||
|
||||
|
||||
[MenuItem(dir + "Shortcuts", false, 101)] static void dadsas() { }
|
||||
[MenuItem(dir + "Shortcuts", true, 101)] static bool dadsas123() => false;
|
||||
|
||||
[MenuItem(toggleActive, false, 102)] static void dadsadadsas() => toggleActiveEnabled = !toggleActiveEnabled;
|
||||
[MenuItem(toggleActive, true, 102)] static bool dadsaddasadsas() { Menu.SetChecked(toggleActive, toggleActiveEnabled); return !pluginDisabled; }
|
||||
|
||||
[MenuItem(focus, false, 103)] static void dadsadasdadsas() => focusEnabled = !focusEnabled;
|
||||
[MenuItem(focus, true, 103)] static bool dadsadsaddasadsas() { Menu.SetChecked(focus, focusEnabled); return !pluginDisabled; }
|
||||
|
||||
[MenuItem(delete, false, 104)] static void dadsadsadasdadsas() => deleteEnabled = !deleteEnabled;
|
||||
[MenuItem(delete, true, 104)] static bool dadsaddsasaddasadsas() { Menu.SetChecked(delete, deleteEnabled); return !pluginDisabled; }
|
||||
|
||||
[MenuItem(toggleExpanded, false, 105)] static void dadsadsadasdsadadsas() => toggleExpandedEnabled = !toggleExpandedEnabled;
|
||||
[MenuItem(toggleExpanded, true, 105)] static bool dadsaddsasadadsdasadsas() { Menu.SetChecked(toggleExpanded, toggleExpandedEnabled); return !pluginDisabled; }
|
||||
|
||||
[MenuItem(collapseEverythingElse, false, 106)] static void dadsadsasdadasdsadadsas() => collapseEverythingElseEnabled = !collapseEverythingElseEnabled;
|
||||
[MenuItem(collapseEverythingElse, true, 106)] static bool dadsaddsdasasadadsdasadsas() { Menu.SetChecked(collapseEverythingElse, collapseEverythingElseEnabled); return !pluginDisabled; }
|
||||
|
||||
[MenuItem(collapseEverything, false, 107)] static void dadsadsdasadasdsadadsas() => collapseEverythingEnabled = !collapseEverythingEnabled;
|
||||
[MenuItem(collapseEverything, true, 107)] static bool dadsaddssdaasadadsdasadsas() { Menu.SetChecked(collapseEverything, collapseEverythingEnabled); return !pluginDisabled; }
|
||||
|
||||
|
||||
|
||||
|
||||
[MenuItem(dir + "More", false, 1001)] static void daasadsddsas() { }
|
||||
[MenuItem(dir + "More", true, 1001)] static bool dadsadsdasas123() => false;
|
||||
|
||||
|
||||
[MenuItem(dir + "Open manual", false, 1002)]
|
||||
static void dadadsasdsadsas() => AssetDatabase.OpenAsset(AssetDatabase.LoadAssetAtPath<Object>(GetScriptPath("VHierarchy").GetParentPath().CombinePath("Manual.pdf")));
|
||||
|
||||
|
||||
[MenuItem(dir + "Join our Discord", false, 1003)]
|
||||
static void dadasdsas() => Application.OpenURL("https://discord.gg/4dG9KsbspG");
|
||||
|
||||
|
||||
|
||||
[MenuItem(dir + "Deals ending soon/Get vFolders 2 at 50% off", false, 1004)]
|
||||
static void dadadssadasdsas() => Application.OpenURL("https://assetstore.unity.com/packages/slug/255470?aid=1100lGLBn&pubref=deal50menu");
|
||||
|
||||
[MenuItem(dir + "Deals ending soon/Get vInspector 2 at 50% off", false, 1005)]
|
||||
static void dadadssadsas() => Application.OpenURL("https://assetstore.unity.com/packages/slug/252297?aid=1100lGLBn&pubref=deal50menu");
|
||||
|
||||
[MenuItem(dir + "Deals ending soon/Get vTabs 2 at 50% off", false, 1006)]
|
||||
static void dadadadsssadsas() => Application.OpenURL("https://assetstore.unity.com/packages/slug/263645?aid=1100lGLBn&pubref=deal50menu");
|
||||
|
||||
[MenuItem(dir + "Deals ending soon/Get vFavorites 2 at 50% off", false, 1007)]
|
||||
static void dadadadsssadsadsas() => Application.OpenURL("https://assetstore.unity.com/packages/slug/263643?aid=1100lGLBn&pubref=deal50menu");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
[MenuItem(disablePlugin, false, 10001)] static void dadsadsdasadasdasdsadadsas() { pluginDisabled = !pluginDisabled; UnityEditor.Compilation.CompilationPipeline.RequestScriptCompilation(); }
|
||||
[MenuItem(disablePlugin, true, 10001)] static bool dadsaddssdaasadsadadsdasadsas() { Menu.SetChecked(disablePlugin, pluginDisabled); return true; }
|
||||
|
||||
|
||||
|
||||
|
||||
// [MenuItem(dir + "Clear cache", false, 10001)]
|
||||
// static void dassaadsdc() => VHierarchyCache.Clear();
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4d7f0448bdeda4aad9cfdd9e7c7ee27f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,6 +0,0 @@
|
||||
|
||||
|
||||
// this file was present in a previus version and is supposed to be deleted now
|
||||
// but asset store update delivery system doesn't allow deleting files
|
||||
// so instead this file is now emptied
|
||||
// feel free to delete it if you want
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9ddf1decb62f94768bcaec3173017c87
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,217 +0,0 @@
|
||||
#if UNITY_EDITOR
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using UnityEditor.ShortcutManagement;
|
||||
using System.Reflection;
|
||||
using System.Linq;
|
||||
using UnityEngine.UIElements;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEditor.SceneManagement;
|
||||
using UnityEditorInternal;
|
||||
using static VHierarchy.Libs.VUtils;
|
||||
using static VHierarchy.Libs.VGUI;
|
||||
|
||||
|
||||
|
||||
namespace VHierarchy
|
||||
{
|
||||
public class VHierarchyPalette : ScriptableObject
|
||||
{
|
||||
public List<Color> colors = new List<Color>();
|
||||
|
||||
public bool colorsEnabled;
|
||||
|
||||
public void ResetColors()
|
||||
{
|
||||
colors.Clear();
|
||||
|
||||
for (int i = 0; i < colorsCount; i++)
|
||||
colors.Add(GetDefaultColor(i));
|
||||
|
||||
colorsEnabled = true;
|
||||
|
||||
this.Dirty();
|
||||
|
||||
}
|
||||
|
||||
public static Color GetDefaultColor(int colorIndex)
|
||||
{
|
||||
Color color = default;
|
||||
|
||||
void grey()
|
||||
{
|
||||
if (colorIndex >= greyColorsCount) return;
|
||||
|
||||
#if UNITY_2022_1_OR_NEWER
|
||||
color = Greyscale(isDarkTheme ? .16f : .9f);
|
||||
#else
|
||||
color = Greyscale(isDarkTheme ? .315f : .9f);
|
||||
#endif
|
||||
|
||||
}
|
||||
void rainbowDarkTheme()
|
||||
{
|
||||
if (colorIndex < greyColorsCount) return;
|
||||
if (!isDarkTheme) return;
|
||||
|
||||
color = HSLToRGB((colorIndex - greyColorsCount.ToFloat()) / rainbowColorsCount, .45f, .35f);
|
||||
|
||||
if (colorIndex == 1)
|
||||
color *= 1.2f;
|
||||
|
||||
if (colorIndex == 2)
|
||||
color *= 1.1f;
|
||||
|
||||
if (colorIndex == 6)
|
||||
color *= 1.35f;
|
||||
|
||||
if (colorIndex == 7)
|
||||
color *= 1.3f;
|
||||
|
||||
if (colorIndex == 8)
|
||||
color *= 1.05f;
|
||||
|
||||
|
||||
color.a = .1f;
|
||||
|
||||
}
|
||||
void rainbowLightTheme()
|
||||
{
|
||||
if (colorIndex < greyColorsCount) return;
|
||||
if (isDarkTheme) return;
|
||||
|
||||
color = HSLToRGB((colorIndex - greyColorsCount.ToFloat()) / rainbowColorsCount, .62f, .8f);
|
||||
|
||||
color.a = .1f;
|
||||
|
||||
}
|
||||
|
||||
grey();
|
||||
rainbowDarkTheme();
|
||||
rainbowLightTheme();
|
||||
|
||||
return color;
|
||||
|
||||
}
|
||||
|
||||
public static int greyColorsCount = 1;
|
||||
public static int rainbowColorsCount = 8;
|
||||
public static int colorsCount => greyColorsCount + rainbowColorsCount;
|
||||
|
||||
|
||||
|
||||
|
||||
public List<IconRow> iconRows = new List<IconRow>();
|
||||
|
||||
[System.Serializable]
|
||||
public class IconRow
|
||||
{
|
||||
public List<string> builtinIcons = new List<string>(); // names
|
||||
public List<string> customIcons = new List<string>(); // guids
|
||||
|
||||
public bool enabled = true;
|
||||
|
||||
public bool isCustom => !builtinIcons.Any() || customIcons.Any();
|
||||
public bool isEmpty => !builtinIcons.Any() && !customIcons.Any();
|
||||
public int iconCount => builtinIcons.Count + customIcons.Count;
|
||||
|
||||
public IconRow(string[] builtinIcons) => this.builtinIcons = builtinIcons.ToList();
|
||||
public IconRow() { }
|
||||
|
||||
}
|
||||
|
||||
public void ResetIcons()
|
||||
{
|
||||
iconRows.Clear();
|
||||
|
||||
iconRows.Add(new IconRow(new[]
|
||||
{
|
||||
"Folder Icon",
|
||||
"Canvas Icon",
|
||||
"AvatarMask On Icon",
|
||||
"cs Script Icon",
|
||||
"StandaloneInputModule Icon",
|
||||
"EventSystem Icon",
|
||||
"Terrain Icon",
|
||||
"ScriptableObject Icon",
|
||||
|
||||
}));
|
||||
iconRows.Add(new IconRow(new[]
|
||||
{
|
||||
"Camera Icon",
|
||||
"ParticleSystem Icon",
|
||||
"TrailRenderer Icon",
|
||||
"Material Icon",
|
||||
"ReflectionProbe Icon",
|
||||
|
||||
}));
|
||||
iconRows.Add(new IconRow(new[]
|
||||
{
|
||||
"Light Icon",
|
||||
"DirectionalLight Icon",
|
||||
"LightmapParameters Icon",
|
||||
"LightProbes Icon",
|
||||
|
||||
}));
|
||||
iconRows.Add(new IconRow(new[]
|
||||
{
|
||||
"Rigidbody Icon",
|
||||
"BoxCollider Icon",
|
||||
"SphereCollider Icon",
|
||||
"CapsuleCollider Icon",
|
||||
"WheelCollider Icon",
|
||||
"MeshCollider Icon",
|
||||
|
||||
}));
|
||||
iconRows.Add(new IconRow(new[]
|
||||
{
|
||||
"AudioSource Icon",
|
||||
"AudioClip Icon",
|
||||
"AudioListener Icon",
|
||||
"AudioEchoFilter Icon",
|
||||
"AudioReverbZone Icon",
|
||||
|
||||
}));
|
||||
iconRows.Add(new IconRow(new[]
|
||||
{
|
||||
"PreMatCube",
|
||||
"PreMatSphere",
|
||||
"PreMatCylinder",
|
||||
"PreMatQuad",
|
||||
"Favorite",
|
||||
#if UNITY_2021_3_OR_NEWER
|
||||
"Settings Icon",
|
||||
#endif
|
||||
|
||||
}));
|
||||
|
||||
this.Dirty();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
[ContextMenu("Export palette")]
|
||||
public void Export()
|
||||
{
|
||||
var packagePath = EditorUtility.SaveFilePanel("Export vHierarchy Palette", "", this.GetPath().GetFilename(withExtension: false), "unitypackage");
|
||||
|
||||
var iconPaths = iconRows.SelectMany(r => r.customIcons).Select(r => r.ToPath()).Where(r => !r.IsNullOrEmpty());
|
||||
|
||||
AssetDatabase.ExportPackage(iconPaths.Append(this.GetPath()).ToArray(), packagePath);
|
||||
|
||||
EditorUtility.RevealInFinder(packagePath);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void Reset() { ResetColors(); ResetIcons(); }
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 61290d425f1c94a8cbfb56f754ca6757
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,723 +0,0 @@
|
||||
#if UNITY_EDITOR
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using UnityEditor.ShortcutManagement;
|
||||
using System.Reflection;
|
||||
using System.Linq;
|
||||
using UnityEditorInternal;
|
||||
using UnityEngine.UIElements;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEditor.SceneManagement;
|
||||
using static VHierarchy.Libs.VUtils;
|
||||
using static VHierarchy.Libs.VGUI;
|
||||
using static VHierarchy.VHierarchyPalette;
|
||||
|
||||
|
||||
|
||||
namespace VHierarchy
|
||||
{
|
||||
[CustomEditor(typeof(VHierarchyPalette))]
|
||||
public class VHierarchyPaletteEditor : Editor
|
||||
{
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
void colors()
|
||||
{
|
||||
var rowRect = ExpandWidthLabelRect(cellSize).SetX(rowsOffsetX).SetWidth(rowWidth);
|
||||
|
||||
void backgroundHovered()
|
||||
{
|
||||
if (!rowRect.IsHovered()) return;
|
||||
if (pickingColor) return;
|
||||
if (draggingRow) return;
|
||||
|
||||
rowRect.Draw(hoveredRowBackground);
|
||||
|
||||
}
|
||||
void toggle()
|
||||
{
|
||||
var toggleRect = rowRect.SetWidth(16).MoveX(5);
|
||||
|
||||
var prevEnabled = palette.colorsEnabled;
|
||||
var newEnabled = EditorGUI.Toggle(toggleRect, palette.colorsEnabled);
|
||||
|
||||
if (prevEnabled != newEnabled)
|
||||
palette.RecordUndo();
|
||||
|
||||
palette.colorsEnabled = newEnabled;
|
||||
|
||||
if (prevEnabled != newEnabled)
|
||||
palette.Dirty();
|
||||
|
||||
}
|
||||
void crossIcon()
|
||||
{
|
||||
var crossIconRect = rowRect.SetX(rowsOffsetX + iconsOffsetX + iconSpacing / 2).SetWidth(iconSize).SetHeightFromMid(iconSize);
|
||||
|
||||
SetGUIColor(palette.colorsEnabled ? Color.white : disabledRowTint);
|
||||
SetLabelAlignmentCenter();
|
||||
|
||||
GUI.Label(crossIconRect, EditorGUIUtility.IconContent("CrossIcon"));
|
||||
|
||||
ResetGUIColor();
|
||||
ResetLabelStyle();
|
||||
|
||||
}
|
||||
void color(int i)
|
||||
{
|
||||
var cellRect = rowRect.MoveX(iconsOffsetX + (i + 1) * cellSize).SetWidth(cellSize).SetHeightFromMid(cellSize);
|
||||
|
||||
void backgroundPicking()
|
||||
{
|
||||
if (!pickingColor) return;
|
||||
if (i != pickingColorAtIndex) return;
|
||||
|
||||
cellRect.DrawWithRoundedCorners(pickingBackground, 2);
|
||||
|
||||
}
|
||||
void color()
|
||||
{
|
||||
var tint = palette.colorsEnabled ? Color.white : disabledRowTint;
|
||||
|
||||
var brightness = i < VHierarchyPalette.greyColorsCount ? 1.02f : 1.35f;
|
||||
var outlineColor = i < VHierarchyPalette.greyColorsCount ? Greyscale(.0f, .4f) : Greyscale(.15f, .2f);
|
||||
|
||||
cellRect.Resize(3).DrawWithRoundedCorners(outlineColor * tint, 4);
|
||||
cellRect.Resize(4).DrawWithRoundedCorners(palette.colors[i].SetAlpha(1) * brightness * tint, 3);
|
||||
cellRect.Resize(4).AddWidthFromRight(-2).DrawCurtainLeft(GUIColors.windowBackground.SetAlpha((1 - palette.colors[i].a) * .5f));
|
||||
|
||||
}
|
||||
void startPickingColorButton()
|
||||
{
|
||||
if (!palette.colorsEnabled) return;
|
||||
if (!cellRect.IsHovered()) return;
|
||||
if (pickingColor) return;
|
||||
|
||||
var clicked = GUI.Button(cellRect.Resize(1), "");
|
||||
|
||||
GUI.Label(cellRect.Resize(.5f), EditorGUIUtility.IconContent("Preset.Context"));
|
||||
|
||||
|
||||
if (!clicked) return;
|
||||
|
||||
colorPicker = OpenColorPicker((c) => { palette.RecordUndo(); palette.Dirty(); palette.colors[i] = c; }, palette.colors[i], true, false);
|
||||
|
||||
colorPicker.MoveTo(EditorGUIUtility.GUIToScreenPoint(cellRect.Move(-3, 50).position));
|
||||
|
||||
pickingColor = true;
|
||||
pickingColorAtIndex = i;
|
||||
|
||||
}
|
||||
void updatePickingColor()
|
||||
{
|
||||
if (!pickingColor) return;
|
||||
|
||||
EditorApplication.RepaintHierarchyWindow();
|
||||
|
||||
}
|
||||
void stopPickingColor()
|
||||
{
|
||||
if (!pickingColor) return;
|
||||
if (colorPicker) return;
|
||||
|
||||
pickingColor = false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
cellRect.MarkInteractive();
|
||||
|
||||
backgroundPicking();
|
||||
color();
|
||||
startPickingColorButton();
|
||||
updatePickingColor();
|
||||
stopPickingColor();
|
||||
|
||||
}
|
||||
|
||||
backgroundHovered();
|
||||
toggle();
|
||||
crossIcon();
|
||||
|
||||
for (int i = 0; i < palette.colors.Count; i++)
|
||||
color(i);
|
||||
|
||||
Space(rowSpacing - 2);
|
||||
|
||||
}
|
||||
void icons()
|
||||
{
|
||||
void row(Rect rowRect, IconRow row)
|
||||
{
|
||||
var isLastRow = row == palette.iconRows.Last();
|
||||
var isDraggedRow = row == draggedRow;
|
||||
var spaceForCrossIcon = 0f;
|
||||
|
||||
|
||||
void startPickingIcon(int i, Rect cellRect)
|
||||
{
|
||||
iconPicker = OpenObjectPicker<Texture2D>(AssetDatabase.LoadAssetAtPath<Texture2D>(row.customIcons[i].ToPath()), controlID: 123);
|
||||
|
||||
iconPicker.MoveTo(EditorGUIUtility.GUIToScreenPoint(cellRect.Move(-3, 50).position));
|
||||
|
||||
pickingIcon = true;
|
||||
pickingIconAtIndex = i;
|
||||
pickingIconAtRow = row;
|
||||
|
||||
}
|
||||
void updatePickingIcon()
|
||||
{
|
||||
if (!pickingIcon) return;
|
||||
if (pickingIconAtRow != row) return;
|
||||
if (EditorGUIUtility.GetObjectPickerControlID() != 123) return;
|
||||
if (pickingIconAtIndex >= row.customIcons.Count) return; // somehow happens if RecordUndo is used
|
||||
|
||||
palette.RecordUndo();
|
||||
palette.Dirty();
|
||||
|
||||
row.customIcons[pickingIconAtIndex] = (EditorGUIUtility.GetObjectPickerObject() as Texture2D).GetPath().ToGuid();
|
||||
|
||||
}
|
||||
void stopPickingIcon()
|
||||
{
|
||||
if (!pickingIcon) return;
|
||||
if (pickingIconAtRow != row) return;
|
||||
if (iconPicker) return;
|
||||
|
||||
if (pickingIconAtIndex < row.customIcons.Count)
|
||||
if (row.customIcons[pickingIconAtIndex] == null)
|
||||
row.customIcons.RemoveAt(pickingIconAtIndex);
|
||||
|
||||
pickingIcon = false;
|
||||
|
||||
}
|
||||
void dragndrop()
|
||||
{
|
||||
if (!rowRect.IsHovered()) return;
|
||||
|
||||
if (curEvent.isDragUpdate && DragAndDrop.objectReferences.First() is Texture2D)
|
||||
DragAndDrop.visualMode = DragAndDropVisualMode.Copy;
|
||||
|
||||
if (!curEvent.isDragPerform) return;
|
||||
if (!(DragAndDrop.objectReferences.Any(r => r is Texture2D))) return;
|
||||
|
||||
DragAndDrop.AcceptDrag();
|
||||
|
||||
palette.RecordUndo();
|
||||
palette.Dirty();
|
||||
|
||||
foreach (var icon in DragAndDrop.objectReferences.Where(r => r is Texture2D))
|
||||
row.customIcons.Add(icon.GetPath().ToGuid());
|
||||
|
||||
}
|
||||
|
||||
void calcSpaceForCrossIcon()
|
||||
{
|
||||
if (row == curFirstEnabledRow)
|
||||
spaceForCrossIcon = crossIconAnimationT * cellSize;
|
||||
|
||||
if (row == crossIconAnimationSourceRow)
|
||||
spaceForCrossIcon = (1 - crossIconAnimationT) * cellSize;
|
||||
|
||||
}
|
||||
|
||||
void backgroundHovered()
|
||||
{
|
||||
if (!rowRect.IsHovered()) return;
|
||||
if (pickingColor) return;
|
||||
if (pickingIcon) return;
|
||||
if (draggingRow) return;
|
||||
|
||||
rowRect.Draw(hoveredRowBackground);
|
||||
|
||||
}
|
||||
void backgroundDragged()
|
||||
{
|
||||
if (!isDraggedRow) return;
|
||||
|
||||
rowRect.DrawBlurred(Greyscale(0, .3f), 12);
|
||||
rowRect.Draw(draggedRowBackground);
|
||||
|
||||
}
|
||||
void toggle()
|
||||
{
|
||||
var prevEnabled = row.enabled;
|
||||
var newEnabled = EditorGUI.Toggle(rowRect.SetWidth(16).MoveX(5), row.enabled);
|
||||
|
||||
if (prevEnabled != newEnabled)
|
||||
palette.RecordUndo();
|
||||
|
||||
row.enabled = newEnabled;
|
||||
|
||||
if (prevEnabled != newEnabled)
|
||||
palette.Dirty();
|
||||
|
||||
}
|
||||
void addIconButton()
|
||||
{
|
||||
if (!row.isCustom) return;
|
||||
|
||||
var cellRect = rowRect.MoveX(iconsOffsetX + row.customIcons.Count * cellSize + spaceForCrossIcon).SetWidth(cellSize).SetHeightFromMid(cellSize);
|
||||
|
||||
|
||||
|
||||
SetGUIColor(Greyscale(1, row.enabled ? 1 : .5f));
|
||||
|
||||
var clicked = GUI.Button(cellRect.Resize(1), "");
|
||||
|
||||
ResetGUIColor();
|
||||
|
||||
|
||||
|
||||
SetGUIColor(Greyscale(1, row.enabled ? 1 : .5f));
|
||||
SetLabelAlignmentCenter();
|
||||
|
||||
GUI.Label(cellRect.Resize(1), EditorGUIUtility.IconContent("Toolbar Plus"));
|
||||
|
||||
ResetLabelStyle();
|
||||
ResetGUIColor();
|
||||
|
||||
|
||||
|
||||
if (!clicked) return;
|
||||
|
||||
palette.RecordUndo();
|
||||
|
||||
row.customIcons.Add(null);
|
||||
|
||||
startPickingIcon(row.customIcons.Count - 1, cellRect);
|
||||
|
||||
}
|
||||
void icon(int i)
|
||||
{
|
||||
var cellRect = rowRect.MoveX(iconsOffsetX + spaceForCrossIcon + i * cellSize).SetWidth(cellSize).SetHeightFromMid(cellSize);
|
||||
var isCustomIcon = i > row.builtinIcons.Count - 1;
|
||||
|
||||
void backgroundPicking()
|
||||
{
|
||||
if (!pickingIcon) return;
|
||||
if (row != pickingIconAtRow) return;
|
||||
if (i != pickingIconAtIndex) return;
|
||||
|
||||
cellRect.Resize(1).DrawWithRoundedCorners(pickingBackground, 2);
|
||||
|
||||
}
|
||||
void drawBuiltin()
|
||||
{
|
||||
if (isCustomIcon) return;
|
||||
|
||||
SetLabelAlignmentCenter();
|
||||
SetGUIColor(row.enabled ? Color.white : disabledRowTint);
|
||||
|
||||
GUI.Label(cellRect.SetSizeFromMid(iconSize), EditorGUIUtility.IconContent(row.builtinIcons[i]));
|
||||
|
||||
ResetLabelStyle();
|
||||
ResetGUIColor();
|
||||
|
||||
}
|
||||
void drawCustom()
|
||||
{
|
||||
if (!isCustomIcon) return;
|
||||
if (cellRect.IsHovered()) return;
|
||||
if (!(AssetDatabase.LoadAssetAtPath<Texture2D>(row.customIcons[i - row.builtinIcons.Count].ToPath()) is Texture2D texture)) return;
|
||||
|
||||
SetGUIColor(row.enabled ? Color.white : disabledRowTint);
|
||||
|
||||
GUI.DrawTexture(cellRect.SetSizeFromMid(iconSize), texture);
|
||||
|
||||
ResetGUIColor();
|
||||
|
||||
}
|
||||
void editCustomButton()
|
||||
{
|
||||
if (!isCustomIcon) return;
|
||||
if (!cellRect.IsHovered()) return;
|
||||
if (pickingIcon) return;
|
||||
|
||||
var clicked = GUI.Button(cellRect.Resize(1), "");
|
||||
|
||||
GUI.Label(cellRect.Resize(.5f), EditorGUIUtility.IconContent("Preset.Context"));
|
||||
|
||||
|
||||
|
||||
if (!clicked) return;
|
||||
|
||||
GenericMenu menu = new GenericMenu();
|
||||
|
||||
menu.AddItem(new GUIContent("Replace icon"), false, () => { palette.RecordUndo(); palette.Dirty(); startPickingIcon(i, cellRect.MoveY(75)); });
|
||||
menu.AddItem(new GUIContent("Remove icon"), false, () => { palette.RecordUndo(); row.customIcons.RemoveAt(i); palette.Dirty(); });
|
||||
|
||||
menu.ShowAsContext();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
cellRect.MarkInteractive();
|
||||
|
||||
backgroundPicking();
|
||||
drawBuiltin();
|
||||
drawCustom();
|
||||
editCustomButton();
|
||||
|
||||
}
|
||||
|
||||
|
||||
rowRect.MarkInteractive();
|
||||
|
||||
updatePickingIcon();
|
||||
stopPickingIcon();
|
||||
dragndrop();
|
||||
|
||||
calcSpaceForCrossIcon();
|
||||
backgroundHovered();
|
||||
backgroundDragged();
|
||||
toggle();
|
||||
addIconButton();
|
||||
|
||||
for (int i = 0; i < row.iconCount; i++)
|
||||
icon(i);
|
||||
|
||||
}
|
||||
|
||||
void updateRowsCount()
|
||||
{
|
||||
palette.iconRows.RemoveAll(r => r.isEmpty && r != palette.iconRows.Last());
|
||||
|
||||
if (!palette.iconRows.Last().isEmpty)
|
||||
palette.iconRows.Add(new IconRow());
|
||||
|
||||
}
|
||||
void updateRowGapsCount()
|
||||
{
|
||||
while (rowGaps.Count < palette.iconRows.Count)
|
||||
rowGaps.Add(0);
|
||||
|
||||
while (rowGaps.Count > palette.iconRows.Count)
|
||||
rowGaps.RemoveLast();
|
||||
|
||||
}
|
||||
|
||||
void normalRow(int i)
|
||||
{
|
||||
Space(rowGaps[i] * (cellSize + rowSpacing));
|
||||
|
||||
if (i == 0 && lastRect.y != 0)
|
||||
firstRowY = lastRect.y;
|
||||
|
||||
Space(cellSize + rowSpacing);
|
||||
|
||||
var rowRect = Rect.zero.SetPos(rowsOffsetX, lastRect.y).SetSize(rowWidth, cellSize);
|
||||
|
||||
if (curEvent.isRepaint)
|
||||
if (rowRect.IsHovered())
|
||||
hoveredRow = palette.iconRows[i];
|
||||
|
||||
|
||||
row(rowRect, palette.iconRows[i]);
|
||||
|
||||
}
|
||||
void draggedRow_()
|
||||
{
|
||||
if (!draggingRow) return;
|
||||
|
||||
draggedRowY = (curEvent.mousePosition.y + draggedRowHoldOffset).Clamp(firstRowY, firstRowY + (palette.iconRows.Count - 1) * (cellSize + rowSpacing));
|
||||
|
||||
var rowRect = Rect.zero.SetPos(rowsOffsetX, draggedRowY).SetSize(rowWidth, cellSize);
|
||||
|
||||
row(rowRect, draggedRow);
|
||||
|
||||
}
|
||||
void crossIcon()
|
||||
{
|
||||
if (!palette.iconRows.Any(r => r.enabled)) return;
|
||||
|
||||
var rect = Rect.zero.SetPos(rowsOffsetX + iconsOffsetX, crossIconY).SetSize(cellSize, cellSize).Resize(iconSpacing / 2);
|
||||
|
||||
SetLabelAlignmentCenter();
|
||||
|
||||
GUI.Label(rect, EditorGUIUtility.IconContent("CrossIcon"));
|
||||
|
||||
ResetLabelStyle();
|
||||
|
||||
}
|
||||
|
||||
|
||||
updateRowsCount();
|
||||
updateRowGapsCount();
|
||||
|
||||
|
||||
if (curEvent.isRepaint)
|
||||
hoveredRow = null;
|
||||
|
||||
for (int i = 0; i < palette.iconRows.Count; i++)
|
||||
normalRow(i);
|
||||
|
||||
crossIcon();
|
||||
|
||||
draggedRow_();
|
||||
|
||||
|
||||
}
|
||||
void tutor()
|
||||
{
|
||||
SetGUIEnabled(false);
|
||||
|
||||
|
||||
GUILayout.Label("Click a color to edit it");
|
||||
|
||||
Space(4);
|
||||
GUILayout.Label("Click '+' to add a custom icon");
|
||||
|
||||
Space(4);
|
||||
GUILayout.Label("Click a custom icon to replace or remove it");
|
||||
|
||||
Space(4);
|
||||
GUILayout.Label("Drag rows to reorder them");
|
||||
|
||||
|
||||
ResetGUIEnabled();
|
||||
|
||||
}
|
||||
|
||||
|
||||
Space(15);
|
||||
colors();
|
||||
|
||||
Space(15);
|
||||
icons();
|
||||
|
||||
Space(25);
|
||||
tutor();
|
||||
|
||||
UpdateAnimations();
|
||||
|
||||
UpdateDragging();
|
||||
|
||||
palette.Dirty();
|
||||
|
||||
if (draggingRow || animatingCrossIcon)
|
||||
Repaint();
|
||||
|
||||
}
|
||||
|
||||
float iconSize => 18;
|
||||
float iconSpacing => 2;
|
||||
float cellSize => iconSize + iconSpacing;
|
||||
float rowSpacing = 1;
|
||||
float rowsOffsetX => 14;
|
||||
float iconsOffsetX => 27;
|
||||
|
||||
Color hoveredRowBackground => Greyscale(isDarkTheme ? 1 : 0, .05f);
|
||||
Color draggedRowBackground => Greyscale(isDarkTheme ? .3f : .9f);
|
||||
Color pickingBackground => Greyscale(1, .17f);
|
||||
Color disabledRowTint => Greyscale(1, .45f);
|
||||
|
||||
float rowWidth => cellSize * Mathf.Max(palette.colors.Count, palette.iconRows.Max(r => r.iconCount + 1)) + 55;
|
||||
|
||||
bool pickingColor;
|
||||
int pickingColorAtIndex;
|
||||
EditorWindow colorPicker;
|
||||
|
||||
bool pickingIcon;
|
||||
int pickingIconAtIndex;
|
||||
IconRow pickingIconAtRow;
|
||||
EditorWindow iconPicker;
|
||||
|
||||
IconRow hoveredRow;
|
||||
|
||||
float firstRowY = 51;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void UpdateAnimations()
|
||||
{
|
||||
void calcDeltaTime()
|
||||
{
|
||||
if (!curEvent.isLayout) return;
|
||||
|
||||
deltaTime = (float)(EditorApplication.timeSinceStartup - lastLayoutTime);
|
||||
|
||||
if (deltaTime > .05f)
|
||||
deltaTime = .0166f;
|
||||
|
||||
lastLayoutTime = EditorApplication.timeSinceStartup;
|
||||
|
||||
}
|
||||
|
||||
void lerpRowGaps()
|
||||
{
|
||||
if (!curEvent.isLayout) return;
|
||||
|
||||
var lerpSpeed = draggingRow ? 12 : 12321;
|
||||
|
||||
for (int i = 0; i < rowGaps.Count; i++)
|
||||
rowGaps[i] = Lerp(rowGaps[i], draggingRow && i == insertDraggedRowAtIndex ? 1 : 0, lerpSpeed, deltaTime);// todo deltatime
|
||||
|
||||
for (int i = 0; i < rowGaps.Count; i++)
|
||||
if (rowGaps[i].Approx(0))
|
||||
rowGaps[i] = 0;
|
||||
else if (rowGaps[i].Approx(1))
|
||||
rowGaps[i] = 1;
|
||||
|
||||
|
||||
}
|
||||
|
||||
void lerpCrossIconAnimationT()
|
||||
{
|
||||
if (!curEvent.isLayout) return;
|
||||
|
||||
var lerpSpeed = 12;
|
||||
|
||||
Lerp(ref crossIconAnimationT, 1, lerpSpeed, deltaTime);
|
||||
|
||||
}
|
||||
void startCrossIconAnimation()
|
||||
{
|
||||
if (prevFirstEnabledRow == null) { prevFirstEnabledRow = curFirstEnabledRow; return; }
|
||||
if (prevFirstEnabledRow == curFirstEnabledRow) return;
|
||||
|
||||
crossIconAnimationT = 0;
|
||||
crossIconAnimationSourceRow = prevFirstEnabledRow;
|
||||
|
||||
prevFirstEnabledRow = curFirstEnabledRow;
|
||||
|
||||
}
|
||||
void stopCrossIconAnimation()
|
||||
{
|
||||
if (!crossIconAnimationT.Approx(1)) return;
|
||||
|
||||
crossIconAnimationT = 1;
|
||||
crossIconAnimationSourceRow = null;
|
||||
|
||||
}
|
||||
void calcCrossIconY()
|
||||
{
|
||||
var indexOfFirstEnabled = palette.iconRows.IndexOfFirst(r => r.enabled);
|
||||
var yOfFirstEnabled = firstRowY + indexOfFirstEnabled * (cellSize + rowSpacing);
|
||||
for (int i = 0; i < indexOfFirstEnabled + 1; i++)
|
||||
yOfFirstEnabled += rowGaps[i] * (cellSize + rowSpacing);
|
||||
|
||||
|
||||
var indexOfSourceRow = palette.iconRows.IndexOf(crossIconAnimationSourceRow);
|
||||
var yOfSourceRow = firstRowY + indexOfSourceRow * (cellSize + rowSpacing);
|
||||
for (int i = 0; i < indexOfSourceRow + 1; i++)
|
||||
yOfSourceRow += rowGaps[i] * (cellSize + rowSpacing);
|
||||
|
||||
if (crossIconAnimationSourceRow == draggedRow)
|
||||
yOfSourceRow = draggedRowY;
|
||||
|
||||
|
||||
crossIconY = Lerp(yOfSourceRow, yOfFirstEnabled, crossIconAnimationT);
|
||||
|
||||
if (indexOfFirstEnabled == indexOfSourceRow) { crossIconAnimationT = 1; }
|
||||
|
||||
}
|
||||
|
||||
|
||||
calcDeltaTime();
|
||||
|
||||
lerpRowGaps();
|
||||
|
||||
lerpCrossIconAnimationT();
|
||||
startCrossIconAnimation();
|
||||
stopCrossIconAnimation();
|
||||
calcCrossIconY();
|
||||
|
||||
}
|
||||
|
||||
List<float> rowGaps = new List<float>();
|
||||
|
||||
float deltaTime;
|
||||
double lastLayoutTime;
|
||||
|
||||
float crossIconY = 51;
|
||||
float crossIconAnimationT = 1;
|
||||
IconRow crossIconAnimationSourceRow;
|
||||
bool animatingCrossIcon => crossIconAnimationT != 1;
|
||||
|
||||
IconRow prevFirstEnabledRow;
|
||||
IconRow curFirstEnabledRow => palette.iconRows.FirstOrDefault(r => r.enabled);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void UpdateDragging()
|
||||
{
|
||||
void startDragging()
|
||||
{
|
||||
if (draggingRow) return;
|
||||
if (!curEvent.isMouseDrag) return;
|
||||
if (hoveredRow == null) return;
|
||||
if (hoveredRow == palette.iconRows.Last()) return;
|
||||
|
||||
palette.RecordUndo();
|
||||
|
||||
draggingRow = true;
|
||||
draggedRow = hoveredRow;
|
||||
draggingRowFromIndex = palette.iconRows.IndexOf(hoveredRow);
|
||||
draggedRowHoldOffset = firstRowY + draggingRowFromIndex * (cellSize + rowSpacing) - curEvent.mousePosition.y;
|
||||
|
||||
palette.iconRows.Remove(hoveredRow);
|
||||
rowGaps[draggingRowFromIndex] = 1;
|
||||
|
||||
}
|
||||
void updateDragging()
|
||||
{
|
||||
if (!draggingRow) return;
|
||||
|
||||
insertDraggedRowAtIndex = ((curEvent.mousePosition.y - firstRowY) / (cellSize + rowSpacing)).FloorToInt().Clamp(0, palette.iconRows.Count - 1);
|
||||
|
||||
EditorGUIUtility.hotControl = EditorGUIUtility.GetControlID(FocusType.Passive);
|
||||
|
||||
}
|
||||
void stopDragging()
|
||||
{
|
||||
if (!draggingRow) return;
|
||||
if (!curEvent.isMouseUp) return;
|
||||
|
||||
palette.RecordUndo();
|
||||
palette.Dirty();
|
||||
|
||||
palette.iconRows.AddAt(draggedRow, insertDraggedRowAtIndex);
|
||||
|
||||
rowGaps[insertDraggedRowAtIndex] = 0;
|
||||
|
||||
draggingRow = false;
|
||||
draggedRow = null;
|
||||
|
||||
EditorGUIUtility.hotControl = 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
startDragging();
|
||||
updateDragging();
|
||||
stopDragging();
|
||||
|
||||
}
|
||||
|
||||
IconRow draggedRow;
|
||||
bool draggingRow;
|
||||
int draggingRowFromIndex;
|
||||
float draggedRowHoldOffset;
|
||||
float draggedRowY;
|
||||
int insertDraggedRowAtIndex;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
VHierarchyPalette palette => target as VHierarchyPalette;
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2b7dce55e9e9b476fb5d1d669c006123
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,550 +0,0 @@
|
||||
#if UNITY_EDITOR
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using UnityEditor.ShortcutManagement;
|
||||
using System.Reflection;
|
||||
using System.Linq;
|
||||
using UnityEngine.UIElements;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEditor.SceneManagement;
|
||||
using Type = System.Type;
|
||||
using static VHierarchy.VHierarchyData;
|
||||
using static VHierarchy.VHierarchyPalette;
|
||||
using static VHierarchy.Libs.VUtils;
|
||||
using static VHierarchy.Libs.VGUI;
|
||||
|
||||
|
||||
|
||||
namespace VHierarchy
|
||||
{
|
||||
public class VHierarchyPaletteWindow : EditorWindow
|
||||
{
|
||||
void OnGUI()
|
||||
{
|
||||
if (!palette) { Close(); return; }
|
||||
|
||||
int hoveredColorIndex = -1;
|
||||
string hoveredIconNameOrGuid = null;
|
||||
|
||||
void background()
|
||||
{
|
||||
position.SetPos(0, 0).Draw(windowBackground);
|
||||
}
|
||||
void outline()
|
||||
{
|
||||
if (Application.platform == RuntimePlatform.OSXEditor) return;
|
||||
|
||||
position.SetPos(0, 0).DrawOutline(Greyscale(.1f));
|
||||
|
||||
}
|
||||
void colors()
|
||||
{
|
||||
if (!palette.colorsEnabled) { Space(-spaceAfterColors); return; }
|
||||
|
||||
var rowRect = ExpandWidthLabelRect(height: cellSize).SetX(paddingX);
|
||||
|
||||
void color(int i)
|
||||
{
|
||||
var cellRect = rowRect.MoveX(i * cellSize).SetWidth(cellSize).SetHeightFromMid(cellSize);
|
||||
|
||||
void backgroundSelected()
|
||||
{
|
||||
if (!initialColorIndexes.Contains(i)) return;
|
||||
|
||||
cellRect.Resize(1).DrawWithRoundedCorners(selectedBackground, 2);
|
||||
|
||||
}
|
||||
void backgroundHovered()
|
||||
{
|
||||
if (!cellRect.IsHovered()) return;
|
||||
|
||||
cellRect.Resize(1).DrawWithRoundedCorners(this.hoveredBackground, 2);
|
||||
|
||||
}
|
||||
void crossIcon()
|
||||
{
|
||||
if (i != 0) return;
|
||||
|
||||
SetLabelAlignmentCenter();
|
||||
|
||||
GUI.Label(cellRect.SetSizeFromMid(iconSize), EditorGUIUtility.IconContent("CrossIcon"));
|
||||
|
||||
ResetLabelStyle();
|
||||
|
||||
}
|
||||
void color()
|
||||
{
|
||||
if (i == 0) return;
|
||||
|
||||
var brightness = i <= VHierarchyPalette.greyColorsCount ? 1.02f : 1.35f;
|
||||
var outlineColor = i <= VHierarchyPalette.greyColorsCount ? Greyscale(.0f, .4f) : Greyscale(.15f, .2f);
|
||||
|
||||
cellRect.Resize(3).DrawWithRoundedCorners(outlineColor, 4);
|
||||
cellRect.Resize(4).DrawWithRoundedCorners((palette.colors[i - 1] * brightness).SetAlpha(1), 3);
|
||||
cellRect.Resize(4).AddWidthFromRight(-2).DrawCurtainLeft(GUIColors.windowBackground.SetAlpha((1 - palette.colors[i - 1].a) * .45f));
|
||||
|
||||
}
|
||||
void setHovered()
|
||||
{
|
||||
if (!cellRect.IsHovered()) return;
|
||||
|
||||
hoveredColorIndex = i;
|
||||
|
||||
}
|
||||
void closeOnClick()
|
||||
{
|
||||
if (!cellRect.IsHovered()) return;
|
||||
if (!curEvent.isMouseDown) return;
|
||||
|
||||
Close();
|
||||
|
||||
}
|
||||
|
||||
|
||||
cellRect.MarkInteractive();
|
||||
|
||||
backgroundSelected();
|
||||
backgroundHovered();
|
||||
crossIcon();
|
||||
color();
|
||||
setHovered();
|
||||
closeOnClick();
|
||||
|
||||
}
|
||||
|
||||
|
||||
for (int i = 0; i < palette.colors.Count + 1; i++)
|
||||
color(i);
|
||||
|
||||
}
|
||||
void icons()
|
||||
{
|
||||
void row(IconRow iconRow)
|
||||
{
|
||||
if (!iconRow.enabled) return;
|
||||
if (iconRow.isEmpty) return;
|
||||
|
||||
var rowRect = ExpandWidthLabelRect(height: cellSize).SetX(paddingX);
|
||||
var isFirstEnabledRow = palette.iconRows.First(r => r.enabled) == iconRow;
|
||||
|
||||
void icon(int i)
|
||||
{
|
||||
var cellRect = rowRect.MoveX(i * cellSize).SetWidth(cellSize).SetHeightFromMid(cellSize);
|
||||
|
||||
var isCrossIcon = isFirstEnabledRow && i == 0;
|
||||
var actualIconIndex = isFirstEnabledRow ? i - 1 : i;
|
||||
var isBuiltinIcon = !isCrossIcon && actualIconIndex < iconRow.builtinIcons.Count;
|
||||
var isCustomIcon = !isCrossIcon && actualIconIndex >= iconRow.builtinIcons.Count;
|
||||
var iconNameOrGuid = isCrossIcon ? "" : isCustomIcon ? iconRow.customIcons[actualIconIndex - iconRow.builtinIcons.Count] : iconRow.builtinIcons[actualIconIndex];
|
||||
|
||||
void backgroundSelected()
|
||||
{
|
||||
if (!initialIconNamesOrGuids.Contains(iconNameOrGuid)) return;
|
||||
|
||||
cellRect.Resize(1).DrawWithRoundedCorners(selectedBackground, 2);
|
||||
|
||||
}
|
||||
void backgroundHovered()
|
||||
{
|
||||
if (!cellRect.IsHovered()) return;
|
||||
|
||||
cellRect.Resize(1).DrawWithRoundedCorners(this.hoveredBackground, 2);
|
||||
|
||||
}
|
||||
void crossIcon()
|
||||
{
|
||||
if (!isCrossIcon) return;
|
||||
|
||||
SetLabelAlignmentCenter();
|
||||
|
||||
GUI.Label(cellRect.SetSizeFromMid(iconSize), EditorGUIUtility.IconContent("CrossIcon"));
|
||||
|
||||
ResetLabelStyle();
|
||||
|
||||
}
|
||||
void builtinIcon()
|
||||
{
|
||||
if (!isBuiltinIcon) return;
|
||||
|
||||
SetLabelAlignmentCenter();
|
||||
|
||||
GUI.Label(cellRect.SetSizeFromMid(iconSize), EditorGUIUtility.IconContent(iconNameOrGuid));
|
||||
|
||||
ResetLabelStyle();
|
||||
|
||||
}
|
||||
void customIcon()
|
||||
{
|
||||
if (!isCustomIcon) return;
|
||||
|
||||
var texture = AssetDatabase.LoadAssetAtPath<Texture2D>(iconNameOrGuid.ToPath());
|
||||
|
||||
GUI.DrawTexture(cellRect.SetSizeFromMid(iconSize), texture ?? Texture2D.blackTexture);
|
||||
|
||||
}
|
||||
void setHovered()
|
||||
{
|
||||
if (!cellRect.IsHovered()) return;
|
||||
|
||||
hoveredIconNameOrGuid = iconNameOrGuid;
|
||||
|
||||
}
|
||||
void closeOnClick()
|
||||
{
|
||||
if (!cellRect.IsHovered()) return;
|
||||
if (!curEvent.isMouseDown) return;
|
||||
|
||||
Close();
|
||||
|
||||
}
|
||||
|
||||
|
||||
cellRect.MarkInteractive();
|
||||
|
||||
backgroundSelected();
|
||||
backgroundHovered();
|
||||
crossIcon();
|
||||
builtinIcon();
|
||||
customIcon();
|
||||
setHovered();
|
||||
closeOnClick();
|
||||
|
||||
}
|
||||
|
||||
for (int i = 0; i < iconRow.iconCount + (isFirstEnabledRow ? 1 : 0); i++)
|
||||
icon(i);
|
||||
|
||||
Space(rowSpacing - 2);
|
||||
|
||||
}
|
||||
|
||||
for (int i = 0; i < palette.iconRows.Count; i++)
|
||||
row(palette.iconRows[i]);
|
||||
|
||||
}
|
||||
|
||||
void setColorsAndIcons()
|
||||
{
|
||||
if (!curEvent.isRepaint) return;
|
||||
|
||||
|
||||
if (palette.iconRows.Any(r => r.enabled))
|
||||
if (hoveredIconNameOrGuid != null)
|
||||
SetIcon(hoveredIconNameOrGuid);
|
||||
else
|
||||
SetInitialIcons();
|
||||
|
||||
|
||||
if (palette.colorsEnabled)
|
||||
if (hoveredColorIndex != -1)
|
||||
SetColor(hoveredColorIndex);
|
||||
else
|
||||
SetInitialColors();
|
||||
|
||||
}
|
||||
void updatePosition()
|
||||
{
|
||||
if (!curEvent.isLayout) return;
|
||||
|
||||
void calcDeltaTime()
|
||||
{
|
||||
deltaTime = (float)(EditorApplication.timeSinceStartup - lastLayoutTime);
|
||||
|
||||
if (deltaTime > .05f)
|
||||
deltaTime = .0166f;
|
||||
|
||||
lastLayoutTime = EditorApplication.timeSinceStartup;
|
||||
|
||||
}
|
||||
void resetCurPos()
|
||||
{
|
||||
if (currentPosition != default) return;
|
||||
|
||||
currentPosition = position.position; // position.position is always int, which can't be used for lerping
|
||||
|
||||
}
|
||||
void lerpCurPos()
|
||||
{
|
||||
var speed = 9;
|
||||
|
||||
SmoothDamp(ref currentPosition, targetPosition, speed, ref positionDeriv, deltaTime);
|
||||
// Lerp(ref currentPosition, targetPosition, speed, deltaTime);
|
||||
|
||||
}
|
||||
void setCurPos()
|
||||
{
|
||||
position = position.SetPos(currentPosition);
|
||||
}
|
||||
|
||||
calcDeltaTime();
|
||||
resetCurPos();
|
||||
lerpCurPos();
|
||||
setCurPos();
|
||||
|
||||
if (!currentPosition.y.Approx(targetPosition.y))
|
||||
Repaint();
|
||||
|
||||
}
|
||||
void closeOnEscape()
|
||||
{
|
||||
if (!curEvent.isKeyDown) return;
|
||||
if (curEvent.keyCode != KeyCode.Escape) return;
|
||||
|
||||
SetInitialColors();
|
||||
SetInitialIcons();
|
||||
|
||||
Close();
|
||||
|
||||
}
|
||||
|
||||
|
||||
RecordUndoOnDatas();
|
||||
|
||||
background();
|
||||
outline();
|
||||
|
||||
Space(paddingY);
|
||||
colors();
|
||||
|
||||
Space(spaceAfterColors);
|
||||
icons();
|
||||
|
||||
setColorsAndIcons();
|
||||
updatePosition();
|
||||
closeOnEscape();
|
||||
|
||||
EditorApplication.RepaintHierarchyWindow();
|
||||
|
||||
}
|
||||
|
||||
static float iconSize => 18;
|
||||
static float iconSpacing => 2;
|
||||
static float cellSize => iconSize + iconSpacing;
|
||||
static float spaceAfterColors => 11;
|
||||
public float rowSpacing = 1;
|
||||
static float paddingX => 12;
|
||||
static float paddingY => 12;
|
||||
|
||||
Color windowBackground => isDarkTheme ? Greyscale(.23f) : Greyscale(.7f);
|
||||
Color selectedBackground => isDarkTheme ? new Color(.3f, .5f, .7f, .8f) : new Color(.3f, .5f, .7f, .4f) * 1.35f;
|
||||
Color hoveredBackground = Greyscale(1, .3f);
|
||||
|
||||
public Vector2 targetPosition;
|
||||
public Vector2 currentPosition;
|
||||
Vector2 positionDeriv;
|
||||
float deltaTime;
|
||||
double lastLayoutTime;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void SetIcon(string iconNameOrGuid)
|
||||
{
|
||||
foreach (var r in goDatas)
|
||||
r.iconNameOrGuid = iconNameOrGuid;
|
||||
}
|
||||
void SetColor(int colorIndex)
|
||||
{
|
||||
foreach (var r in goDatas)
|
||||
r.colorIndex = colorIndex;
|
||||
}
|
||||
|
||||
void SetInitialIcons()
|
||||
{
|
||||
for (int i = 0; i < goDatas.Count; i++)
|
||||
goDatas[i].iconNameOrGuid = initialIconNamesOrGuids[i];
|
||||
|
||||
}
|
||||
void SetInitialColors()
|
||||
{
|
||||
for (int i = 0; i < goDatas.Count; i++)
|
||||
goDatas[i].colorIndex = initialColorIndexes[i];
|
||||
|
||||
}
|
||||
|
||||
void RemoveEmptyGoDatas()
|
||||
{
|
||||
var toRemove = goDatas.Where(r => r.iconNameOrGuid == "" && r.colorIndex == 0);
|
||||
|
||||
foreach (var goData in toRemove)
|
||||
goData.sceneData.goDatas_byGlobalId.RemoveValue(goData);
|
||||
|
||||
if (toRemove.Any())
|
||||
Undo.CollapseUndoOperations(Undo.GetCurrentGroup() - 1);
|
||||
|
||||
}
|
||||
|
||||
void RecordUndoOnDatas()
|
||||
{
|
||||
if (usingDataSO)
|
||||
if (data)
|
||||
data.RecordUndo();
|
||||
|
||||
foreach (var r in usedDataComponents)
|
||||
r.RecordUndo();
|
||||
|
||||
}
|
||||
void MarkDatasDirty()
|
||||
{
|
||||
if (usingDataSO)
|
||||
if (data)
|
||||
data.Dirty();
|
||||
|
||||
foreach (var r in usedDataComponents)
|
||||
r.Dirty();
|
||||
}
|
||||
void SaveData()
|
||||
{
|
||||
if (usingDataSO)
|
||||
data.Save();
|
||||
}
|
||||
|
||||
bool usingDataSO => !gameObjects.Select(r => r.scene).All(r => VHierarchy.dataComponents_byScene.GetValueOrDefault(r) != null);
|
||||
IEnumerable<VHierarchyDataComponent> usedDataComponents => VHierarchy.dataComponents_byScene.Where(kvp => kvp.Value && gameObjects.Select(r => r.scene).Contains(kvp.Key)).Select(kvp => kvp.Value);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void OnLostFocus()
|
||||
{
|
||||
if (curEvent.holdingAlt && EditorWindow.focusedWindow?.GetType().Name == "SceneHierarchyWindow")
|
||||
CloseNextFrameIfNotRefocused();
|
||||
else
|
||||
Close();
|
||||
|
||||
}
|
||||
|
||||
void CloseNextFrameIfNotRefocused()
|
||||
{
|
||||
EditorApplication.delayCall += () => { if (EditorWindow.focusedWindow != this) Close(); };
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public void Init(List<GameObject> gameObjects)
|
||||
{
|
||||
void createData()
|
||||
{
|
||||
if (VHierarchy.data) return;
|
||||
|
||||
VHierarchy.data = ScriptableObject.CreateInstance<VHierarchyData>();
|
||||
|
||||
AssetDatabase.CreateAsset(VHierarchy.data, GetScriptPath("VHierarchy").GetParentPath().CombinePath("vHierarchy Data.asset"));
|
||||
|
||||
}
|
||||
void createPalette()
|
||||
{
|
||||
if (VHierarchy.palette) return;
|
||||
|
||||
VHierarchy.palette = ScriptableObject.CreateInstance<VHierarchyPalette>();
|
||||
|
||||
AssetDatabase.CreateAsset(VHierarchy.palette, GetScriptPath("VHierarchy").GetParentPath().CombinePath("vHierarchy Palette.asset"));
|
||||
|
||||
}
|
||||
void setSize()
|
||||
{
|
||||
var rowCellCounts = new List<int>();
|
||||
|
||||
if (palette.colorsEnabled)
|
||||
rowCellCounts.Add(palette.colors.Count + 1);
|
||||
|
||||
foreach (var r in palette.iconRows.Where(r => r.enabled))
|
||||
rowCellCounts.Add(r.iconCount + (r == palette.iconRows.First(r => r.enabled) ? 1 : 0));
|
||||
|
||||
var width = rowCellCounts.Max() * cellSize + paddingX * 2;
|
||||
|
||||
|
||||
|
||||
var iconRowCount = palette.iconRows.Count(r => r.enabled && !r.isEmpty);
|
||||
var rowCount = iconRowCount + (palette.colorsEnabled ? 1 : 0);
|
||||
|
||||
var height = rowCount * (cellSize + rowSpacing) + (palette.colorsEnabled && palette.iconRows.Any(r => r.enabled && !r.isEmpty) ? spaceAfterColors : 0) + paddingY * 2;
|
||||
|
||||
|
||||
|
||||
position = position.SetSize(width, height).SetPos(targetPosition);
|
||||
|
||||
}
|
||||
void getDatas()
|
||||
{
|
||||
goDatas.Clear();
|
||||
|
||||
foreach (var r in gameObjects)
|
||||
goDatas.Add(VHierarchy.GetGameObjectData(r, createDataIfDoesntExist: true));
|
||||
|
||||
}
|
||||
void getInitColorsAndIcons()
|
||||
{
|
||||
initialColorIndexes.Clear();
|
||||
initialIconNamesOrGuids.Clear();
|
||||
|
||||
foreach (var r in goDatas)
|
||||
initialColorIndexes.Add(r.colorIndex);
|
||||
|
||||
foreach (var r in goDatas)
|
||||
initialIconNamesOrGuids.Add(r.iconNameOrGuid);
|
||||
|
||||
}
|
||||
|
||||
|
||||
this.gameObjects = gameObjects;
|
||||
|
||||
RecordUndoOnDatas();
|
||||
|
||||
createData();
|
||||
createPalette();
|
||||
setSize();
|
||||
getDatas();
|
||||
getInitColorsAndIcons();
|
||||
|
||||
}
|
||||
|
||||
void OnDestroy()
|
||||
{
|
||||
RemoveEmptyGoDatas();
|
||||
MarkDatasDirty();
|
||||
SaveData();
|
||||
|
||||
}
|
||||
|
||||
public List<GameObject> gameObjects = new List<GameObject>();
|
||||
public List<GameObjectData> goDatas = new List<GameObjectData>();
|
||||
|
||||
public List<int> initialColorIndexes = new List<int>();
|
||||
public List<string> initialIconNamesOrGuids = new List<string>();
|
||||
|
||||
static VHierarchyPalette palette => VHierarchy.palette;
|
||||
static VHierarchyData data => VHierarchy.data;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static void CreateInstance(Vector2 position)
|
||||
{
|
||||
instance = ScriptableObject.CreateInstance<VHierarchyPaletteWindow>();
|
||||
|
||||
instance.ShowPopup();
|
||||
|
||||
instance.position = instance.position.SetPos(position).SetSize(200, 300);
|
||||
instance.targetPosition = position;
|
||||
|
||||
}
|
||||
|
||||
public static VHierarchyPaletteWindow instance;
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8ae240588f29744208e627125db9c9e4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,21 +0,0 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 3a9752b0c8e144801967e6897679604b, type: 3}
|
||||
m_Name: vHierarchy Data
|
||||
m_EditorClassIdentifier:
|
||||
sceneDatas_byGuid:
|
||||
keys:
|
||||
- 99c9720ab356a0642a771bea13969a05
|
||||
values:
|
||||
- goDatas_byGlobalId:
|
||||
keys: []
|
||||
values: []
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 258a078a981a33b4cb3d28d7518292dd
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,78 +0,0 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 61290d425f1c94a8cbfb56f754ca6757, type: 3}
|
||||
m_Name: vHierarchy Palette
|
||||
m_EditorClassIdentifier:
|
||||
colors:
|
||||
- {r: 0.16, g: 0.16, b: 0.16, a: 1}
|
||||
- {r: 0.609, g: 0.231, b: 0.23100014, a: 0.1}
|
||||
- {r: 0.55825, g: 0.471625, b: 0.21175, a: 0.1}
|
||||
- {r: 0.34999996, g: 0.5075, b: 0.1925, a: 0.1}
|
||||
- {r: 0.1925, g: 0.5075, b: 0.27124998, a: 0.1}
|
||||
- {r: 0.1925, g: 0.50750005, b: 0.5075, a: 0.1}
|
||||
- {r: 0.259875, g: 0.36618757, b: 0.685125, a: 0.1}
|
||||
- {r: 0.4550001, g: 0.25024998, b: 0.65975, a: 0.1}
|
||||
- {r: 0.53287494, g: 0.20212498, b: 0.4501876, a: 0.1}
|
||||
colorsEnabled: 1
|
||||
iconRows:
|
||||
- builtinIcons:
|
||||
- Folder Icon
|
||||
- Canvas Icon
|
||||
- AvatarMask On Icon
|
||||
- cs Script Icon
|
||||
- StandaloneInputModule Icon
|
||||
- EventSystem Icon
|
||||
- Terrain Icon
|
||||
- ScriptableObject Icon
|
||||
customIcons: []
|
||||
enabled: 1
|
||||
- builtinIcons:
|
||||
- Camera Icon
|
||||
- ParticleSystem Icon
|
||||
- TrailRenderer Icon
|
||||
- Material Icon
|
||||
- ReflectionProbe Icon
|
||||
customIcons: []
|
||||
enabled: 1
|
||||
- builtinIcons:
|
||||
- Light Icon
|
||||
- DirectionalLight Icon
|
||||
- LightmapParameters Icon
|
||||
- LightProbes Icon
|
||||
customIcons: []
|
||||
enabled: 1
|
||||
- builtinIcons:
|
||||
- Rigidbody Icon
|
||||
- BoxCollider Icon
|
||||
- SphereCollider Icon
|
||||
- CapsuleCollider Icon
|
||||
- WheelCollider Icon
|
||||
- MeshCollider Icon
|
||||
customIcons: []
|
||||
enabled: 1
|
||||
- builtinIcons:
|
||||
- AudioSource Icon
|
||||
- AudioClip Icon
|
||||
- AudioListener Icon
|
||||
- AudioEchoFilter Icon
|
||||
- AudioReverbZone Icon
|
||||
customIcons: []
|
||||
enabled: 1
|
||||
- builtinIcons:
|
||||
- PreMatCube
|
||||
- PreMatSphere
|
||||
- PreMatCylinder
|
||||
- PreMatQuad
|
||||
- Favorite
|
||||
- Settings Icon
|
||||
customIcons: []
|
||||
enabled: 1
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 150e54b62f1dc324586c8422a12aee4b
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d3f8a0081f4dcd247831812434183ac9
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
@@ -1,7 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5bc65026e2b5e458b838d06e4ef39409
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,14 +0,0 @@
|
||||
{
|
||||
"name": "VInspector",
|
||||
"rootNamespace": "",
|
||||
"references": [],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: de13f8b1675b449e6a6af1cc0f7842ec
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cb0378825d0df482cb66e646e57e5153
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,104 +0,0 @@
|
||||
Shader "Hidden/VInspectorAssetPreview"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex ("Texture", Any) = "white" {}
|
||||
[HDR] _Color ("Tint", Color) = (1,1,1,1)
|
||||
}
|
||||
|
||||
CGINCLUDE
|
||||
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct appdata_t
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 vertex : SV_POSITION;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
float2 clipUV : TEXCOORD1;
|
||||
};
|
||||
|
||||
sampler2D _MainTex;
|
||||
sampler2D _GUIClipTexture;
|
||||
bool _ManualTex2SRGB;
|
||||
float4 _MainTex_ST;
|
||||
float4 _Color;
|
||||
float4x4 unity_GUIClipTextureMatrix;
|
||||
|
||||
v2f vert (appdata_t v)
|
||||
{
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
float3 eyePos = UnityObjectToViewPos(v.vertex);
|
||||
o.clipUV = mul(unity_GUIClipTextureMatrix, float4(eyePos.xy, 0, 1.0));
|
||||
o.texcoord = TRANSFORM_TEX(v.texcoord,_MainTex);
|
||||
return o;
|
||||
}
|
||||
|
||||
fixed4 frag (v2f i) : SV_Target
|
||||
{
|
||||
float4 c = tex2D(_MainTex, i.texcoord);
|
||||
|
||||
#ifndef UNITY_COLORSPACE_GAMMA
|
||||
c.rgb = LinearToGammaSpace(c.rgb);
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef UNITY_COLORSPACE_GAMMA
|
||||
float backgroundGreyscale = 0.32178620999; // linear
|
||||
#else
|
||||
float backgroundGreyscale = 0.32156862319; // gamma
|
||||
#endif
|
||||
|
||||
|
||||
if(c.r == c.g && c.r == c.b && c.a == 1)
|
||||
if(c.r == backgroundGreyscale)
|
||||
c = float4(backgroundGreyscale, backgroundGreyscale, backgroundGreyscale, 0);
|
||||
|
||||
|
||||
c *= _Color;
|
||||
|
||||
c.a *= tex2D(_GUIClipTexture, i.clipUV).a;
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
ENDCG
|
||||
|
||||
SubShader
|
||||
{
|
||||
Blend SrcAlpha OneMinusSrcAlpha, One One
|
||||
Cull Off
|
||||
ZWrite Off
|
||||
ZTest Always
|
||||
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
Cull Off
|
||||
ZWrite Off
|
||||
ZTest Always
|
||||
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 913b985f9895c47cbb23d4dabc002788
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
preprocessorOverride: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,128 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
using static VInspector.Libs.VUtils;
|
||||
#endif
|
||||
|
||||
|
||||
namespace VInspector
|
||||
{
|
||||
|
||||
public class FoldoutAttribute : Attribute
|
||||
{
|
||||
public string name;
|
||||
|
||||
public FoldoutAttribute(string name) => this.name = name;
|
||||
|
||||
}
|
||||
public class EndFoldoutAttribute : Attribute { }
|
||||
|
||||
|
||||
|
||||
public class TabAttribute : Attribute
|
||||
{
|
||||
public string name;
|
||||
|
||||
public TabAttribute(string name) => this.name = name;
|
||||
|
||||
}
|
||||
public class EndTabAttribute : Attribute { }
|
||||
|
||||
|
||||
|
||||
public class ButtonAttribute : Attribute
|
||||
{
|
||||
public string name = "";
|
||||
public int size = 30;
|
||||
public int space = 0;
|
||||
public string color = "Grey";
|
||||
|
||||
public ButtonAttribute() => this.name = "";
|
||||
public ButtonAttribute(string name) => this.name = name;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public class VariantsAttribute : PropertyAttribute
|
||||
{
|
||||
public object[] variants;
|
||||
|
||||
public VariantsAttribute(params object[] variants) => this.variants = variants;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public abstract class IfAttribute : Attribute
|
||||
{
|
||||
public string variableName;
|
||||
public object variableValue;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
public bool Evaluate(object target)
|
||||
{
|
||||
if (target.GetType().GetFieldInfo(variableName) == null &&
|
||||
target.GetType().GetPropertyInfo(variableName) == null)
|
||||
return false;
|
||||
|
||||
var curValue = target.GetMemberValue(variableName);
|
||||
|
||||
return object.Equals(curValue, variableValue);
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
public IfAttribute(string boolName) { this.variableName = boolName; this.variableValue = true; }
|
||||
public IfAttribute(string variableName, object variableValue) { this.variableName = variableName; this.variableValue = variableValue; }
|
||||
|
||||
}
|
||||
public class EndIfAttribute : Attribute { }
|
||||
|
||||
public class HideIfAttribute : IfAttribute
|
||||
{
|
||||
public HideIfAttribute(string boolName) : base(boolName) { }
|
||||
public HideIfAttribute(string variableName, object variableValue) : base(variableName, variableValue) { }
|
||||
}
|
||||
public class ShowIfAttribute : IfAttribute
|
||||
{
|
||||
public ShowIfAttribute(string boolName) : base(boolName) { }
|
||||
public ShowIfAttribute(string variableName, object variableValue) : base(variableName, variableValue) { }
|
||||
}
|
||||
public class EnableIfAttribute : IfAttribute
|
||||
{
|
||||
public EnableIfAttribute(string boolName) : base(boolName) { }
|
||||
public EnableIfAttribute(string variableName, object variableValue) : base(variableName, variableValue) { }
|
||||
}
|
||||
public class DisableIfAttribute : IfAttribute
|
||||
{
|
||||
public DisableIfAttribute(string boolName) : base(boolName) { }
|
||||
public DisableIfAttribute(string variableName, object variableValue) : base(variableName, variableValue) { }
|
||||
}
|
||||
|
||||
|
||||
|
||||
public class ReadOnlyAttribute : Attribute { }
|
||||
|
||||
|
||||
|
||||
public class ShowInInspectorAttribute : Attribute { }
|
||||
|
||||
|
||||
[AttributeUsage(AttributeTargets.Method)]
|
||||
public class OnValueChangedAttribute : Attribute
|
||||
{
|
||||
public string[] variableNames;
|
||||
|
||||
public OnValueChangedAttribute(string variableName) => this.variableNames = new[] { variableName };
|
||||
public OnValueChangedAttribute(params string[] variableNames) => this.variableNames = variableNames;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c8d83838ee14b4445a0abac264bf08d8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,6 +0,0 @@
|
||||
|
||||
|
||||
// this file was present in a previus version and is supposed to be deleted now
|
||||
// but asset store update delivery system doesn't allow deleting files
|
||||
// so instead this file is now emptied
|
||||
// feel free to delete it if you want
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9ee37a1072bf4467d923d9ef51a0e63d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,206 +0,0 @@
|
||||
#if UNITY_EDITOR
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEditor.ShortcutManagement;
|
||||
using System.Reflection;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using Type = System.Type;
|
||||
using static VInspector.Libs.VUtils;
|
||||
using static VInspector.Libs.VGUI;
|
||||
|
||||
|
||||
|
||||
namespace VInspector
|
||||
{
|
||||
public class VInspectorComponentClipboard : ScriptableSingleton<VInspectorComponentClipboard>
|
||||
{
|
||||
public static void CopyComponent(Component component)
|
||||
{
|
||||
instance.RecordUndo();
|
||||
|
||||
if (instance.copiedComponetDatas.FirstOrDefault(r => r.sourceComponent == component) is ComponentData alreadyCopiedData)
|
||||
{
|
||||
instance.discardedComponentDatas.Add(alreadyCopiedData);
|
||||
instance.copiedComponetDatas.Remove(alreadyCopiedData);
|
||||
}
|
||||
else
|
||||
instance.copiedComponetDatas.Add(GetComponentData(component));
|
||||
|
||||
instance.Dirty();
|
||||
|
||||
}
|
||||
public static void PasteComponentValues(ComponentData data, Component component)
|
||||
{
|
||||
component.RecordUndo();
|
||||
|
||||
ApplyComponentData(data, component);
|
||||
|
||||
component.Dirty();
|
||||
|
||||
|
||||
|
||||
instance.RecordUndo();
|
||||
|
||||
instance.copiedComponetDatas.Remove(data);
|
||||
instance.discardedComponentDatas.Add(data);
|
||||
|
||||
instance.Dirty();
|
||||
|
||||
}
|
||||
public static void PasteComponentAsNew(ComponentData data, GameObject gameObject)
|
||||
{
|
||||
var addedComponent = Undo.AddComponent(gameObject, data.sourceComponent.GetType());
|
||||
|
||||
ApplyComponentData(data, addedComponent);
|
||||
|
||||
}
|
||||
|
||||
public static void ClearCopiedDatas()
|
||||
{
|
||||
instance.RecordUndo();
|
||||
|
||||
instance.discardedComponentDatas.AddRange(instance.copiedComponetDatas);
|
||||
instance.copiedComponetDatas.Clear();
|
||||
|
||||
instance.Dirty();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static bool CanComponentsBePastedTo(IEnumerable<GameObject> targetGos)
|
||||
{
|
||||
if (!targetGos.Any()) return false;
|
||||
|
||||
foreach (var copiedData in instance.copiedComponetDatas)
|
||||
if (nonDuplicableComponentTypes.Contains(copiedData.sourceComponent.GetType()))
|
||||
if (targetGos.Any(r => r.TryGetComponent(copiedData.sourceComponent.GetType(), out _)))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
static Type[] nonDuplicableComponentTypes = new[]
|
||||
{
|
||||
typeof(Transform),
|
||||
typeof(RectTransform),
|
||||
typeof(MeshFilter),
|
||||
typeof(MeshRenderer),
|
||||
typeof(SkinnedMeshRenderer),
|
||||
typeof(Camera),
|
||||
typeof(AudioListener),
|
||||
typeof(Rigidbody),
|
||||
typeof(Rigidbody2D),
|
||||
typeof(Light),
|
||||
typeof(Canvas),
|
||||
typeof(Animation),
|
||||
typeof(Animator),
|
||||
typeof(AudioSource),
|
||||
typeof(ParticleSystem),
|
||||
typeof(TrailRenderer),
|
||||
typeof(LineRenderer),
|
||||
typeof(LensFlare),
|
||||
typeof(Projector),
|
||||
typeof(AudioReverbZone),
|
||||
typeof(AudioEchoFilter),
|
||||
typeof(Terrain),
|
||||
typeof(TerrainCollider),
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
[SerializeReference] public List<ComponentData> copiedComponetDatas = new();
|
||||
|
||||
[SerializeReference] public List<ComponentData> discardedComponentDatas = new(); // removed datas get stashed here so they can be restored on undo/redo
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static void SaveComponent(Component component)
|
||||
{
|
||||
instance.RecordUndo();
|
||||
|
||||
if (instance.savedComponentDatas.FirstOrDefault(r => r.sourceComponent == component) is ComponentData alreadySavedData)
|
||||
{
|
||||
instance.discardedComponentDatas.Add(alreadySavedData);
|
||||
instance.savedComponentDatas.Remove(alreadySavedData);
|
||||
}
|
||||
else
|
||||
instance.savedComponentDatas.Add(GetComponentData(component));
|
||||
|
||||
instance.Dirty();
|
||||
|
||||
}
|
||||
|
||||
public static void OnPlaymodeStateChanged(PlayModeStateChange state)
|
||||
{
|
||||
if (state != PlayModeStateChange.EnteredEditMode) return;
|
||||
|
||||
foreach (var data in instance.savedComponentDatas)
|
||||
if (EditorUtility.InstanceIDToObject(data.sourceComponent.GetInstanceID()) is Component sourceComponent)
|
||||
ApplyComponentData(data, sourceComponent);
|
||||
|
||||
instance.savedComponentDatas.Clear();
|
||||
|
||||
}
|
||||
|
||||
[SerializeReference] public List<ComponentData> savedComponentDatas = new();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static ComponentData GetComponentData(Component component)
|
||||
{
|
||||
var data = new ComponentData();
|
||||
|
||||
data.sourceComponent = component;
|
||||
|
||||
|
||||
var property = new SerializedObject(component).GetIterator();
|
||||
|
||||
if (!property.Next(true)) return data;
|
||||
|
||||
|
||||
do data.serializedPropertyValues_byPath[property.propertyPath] = property.GetBoxedValue();
|
||||
while (property.NextVisible(true));
|
||||
|
||||
return data;
|
||||
|
||||
}
|
||||
public static void ApplyComponentData(ComponentData componentData, Component targetComponent)
|
||||
{
|
||||
foreach (var kvp in componentData.serializedPropertyValues_byPath)
|
||||
{
|
||||
var so = new SerializedObject(targetComponent);
|
||||
var property = so.FindProperty(kvp.Key);
|
||||
|
||||
so.Update();
|
||||
|
||||
property.SetBoxedValue(kvp.Value);
|
||||
|
||||
so.ApplyModifiedProperties();
|
||||
|
||||
targetComponent.Dirty();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class ComponentData { public Component sourceComponent; public Dictionary<string, object> serializedPropertyValues_byPath = new(); }
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b4a601d21911941c9b6aa75950470764
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,573 +0,0 @@
|
||||
#if UNITY_EDITOR
|
||||
using System.Collections;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using UnityEditor.UIElements;
|
||||
using System.Reflection;
|
||||
using UnityEditor;
|
||||
using static VInspector.Libs.VUtils;
|
||||
using static VInspector.Libs.VGUI;
|
||||
|
||||
|
||||
|
||||
|
||||
namespace VInspector
|
||||
{
|
||||
public class VInspectorComponentHeader
|
||||
{
|
||||
|
||||
void OnGUI()
|
||||
{
|
||||
void masks()
|
||||
{
|
||||
Color backgroundColor;
|
||||
|
||||
float buttonMask_xMin;
|
||||
float buttonMask_xMax;
|
||||
|
||||
void set_backgroundColor()
|
||||
{
|
||||
var hovered = EditorGUIUtility.isProSkin ? Greyscale(.28f) : Greyscale(.84f);
|
||||
var normal = EditorGUIUtility.isProSkin ? Greyscale(.244f) : Greyscale(.8f);
|
||||
|
||||
backgroundColor = normal;
|
||||
|
||||
if (headerRect.IsHovered() && !mousePressedOnBackground && EditorWindow.mouseOverWindow == window)
|
||||
backgroundColor = hovered;
|
||||
|
||||
}
|
||||
void set_buttonMaskSize()
|
||||
{
|
||||
var defaultButtonCount = VInspectorMenu.componentButtons_defaultButtonsCount;
|
||||
|
||||
|
||||
var customButtonCount = 0;
|
||||
|
||||
if (VInspectorMenu.copyPasteButtonsEnabled)
|
||||
customButtonCount++;
|
||||
|
||||
if (VInspectorMenu.saveInPlaymodeButtonEnabled && Application.isPlaying)
|
||||
customButtonCount++;
|
||||
|
||||
|
||||
if (VInspectorMenu.minimalModeEnabled && !headerRect.IsHovered())
|
||||
defaultButtonCount = customButtonCount = 0;
|
||||
|
||||
|
||||
|
||||
|
||||
buttonMask_xMax = headerRect.xMax - buttonsOffsetRight - defaultButtonCount * buttonSize;
|
||||
|
||||
|
||||
buttonMask_xMin = headerRect.xMax - buttonsOffsetRight - (defaultButtonCount + customButtonCount).Max(3) * buttonSize;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void hideArrow()
|
||||
{
|
||||
if (headerRect.IsHovered()) return;
|
||||
if (!VInspectorMenu.minimalModeEnabled) return;
|
||||
|
||||
// headerRect.SetWidth(17).MoveX(3).AddHeightFromMid(-2).Draw(backgroundColor);
|
||||
headerRect.SetWidth(17).MoveX(-2).AddHeightFromMid(-2).AddWidthFromRight(-4).Draw(backgroundColor);
|
||||
|
||||
}
|
||||
void hideDefaultButtons_()
|
||||
{
|
||||
var rect = headerRect.AddHeightFromMid(-2).SetX(buttonMask_xMin).SetXMax(buttonMask_xMax);
|
||||
|
||||
rect.Draw(backgroundColor);
|
||||
|
||||
}
|
||||
void hideScriptText()
|
||||
{
|
||||
if (component is not MonoBehaviour) return;
|
||||
if (!VInspectorMenu.minimalModeEnabled) return;
|
||||
|
||||
var name = component.GetType().Name.Decamelcase();
|
||||
|
||||
var rect = headerRect.AddHeightFromMid(-2).SetWidth(60).MoveX(name.GetLabelWidth(fontSize: 12, isBold: true) + 60 - 3);
|
||||
|
||||
rect.xMax = rect.xMax.Min(buttonMask_xMin).Max(rect.xMin);
|
||||
|
||||
|
||||
rect.Draw(backgroundColor);
|
||||
|
||||
}
|
||||
void tintScriptIcon()
|
||||
{
|
||||
if (component is not MonoBehaviour) return;
|
||||
if (!mousePressedOnScriptIcon) return;
|
||||
|
||||
var iconRect = headerRect.MoveX(18).SetWidth(22);
|
||||
|
||||
iconRect.Draw(backgroundColor.SetAlpha(EditorGUIUtility.isProSkin ? .3f : .45f));
|
||||
|
||||
}
|
||||
void nameCurtain()
|
||||
{
|
||||
var rect = headerRect.AddHeightFromMid(-2).SetXMax(buttonMask_xMin + 2).SetWidthFromRight(18);
|
||||
|
||||
rect.DrawCurtainLeft(backgroundColor);
|
||||
|
||||
}
|
||||
|
||||
|
||||
set_backgroundColor();
|
||||
set_buttonMaskSize();
|
||||
|
||||
hideArrow();
|
||||
hideDefaultButtons_();
|
||||
hideScriptText();
|
||||
tintScriptIcon();
|
||||
nameCurtain();
|
||||
|
||||
}
|
||||
|
||||
void scriptIconClicks()
|
||||
{
|
||||
if (component is not MonoBehaviour) return;
|
||||
if (curEvent.mouseButton != 0) return;
|
||||
if (!VInspectorMenu.hideScriptFieldEnabled) return;
|
||||
|
||||
var iconRect = headerRect.MoveX(18).SetWidth(22);
|
||||
|
||||
|
||||
void mosueDown()
|
||||
{
|
||||
if (!curEvent.isMouseDown) return;
|
||||
if (!iconRect.IsHovered()) return;
|
||||
|
||||
|
||||
mousePressedOnScriptIcon = true;
|
||||
mousePressedOnScriptIcon_initPos = curEvent.mousePosition;
|
||||
|
||||
|
||||
var script = MonoScript.FromMonoBehaviour(component as MonoBehaviour);
|
||||
|
||||
// if (curEvent.holdingAlt)
|
||||
|
||||
|
||||
if (curEvent.clickCount == 2)
|
||||
AssetDatabase.OpenAsset(script);
|
||||
|
||||
|
||||
curEvent.Use();
|
||||
|
||||
}
|
||||
void mouseUp()
|
||||
{
|
||||
if (!curEvent.isMouseUp) return;
|
||||
if (!mousePressedOnScriptIcon) return;
|
||||
|
||||
var script = MonoScript.FromMonoBehaviour(component as MonoBehaviour);
|
||||
|
||||
if (curEvent.clickCount == 1)
|
||||
PingObject(script);
|
||||
|
||||
mousePressedOnScriptIcon = false;
|
||||
|
||||
window.Repaint();
|
||||
|
||||
curEvent.Use();
|
||||
|
||||
}
|
||||
void startDrag()
|
||||
{
|
||||
if (!curEvent.isMouseDrag) return;
|
||||
if (!mousePressedOnScriptIcon) return;
|
||||
if ((mousePressedOnScriptIcon_initPos - curEvent.mousePosition).magnitude < 2) return;
|
||||
|
||||
DragAndDrop.PrepareStartDrag();
|
||||
DragAndDrop.objectReferences = new[] { component };
|
||||
DragAndDrop.StartDrag(component.ToString());
|
||||
|
||||
mousePressedOnScriptIcon = false;
|
||||
mousePressedOnBackground = false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
mosueDown();
|
||||
mouseUp();
|
||||
startDrag();
|
||||
|
||||
}
|
||||
void copyPasteButton()
|
||||
{
|
||||
if (VInspectorMenu.minimalModeEnabled && !headerRect.IsHovered()) return;
|
||||
if (!VInspectorMenu.copyPasteButtonsEnabled) return;
|
||||
|
||||
|
||||
var copiedData = VInspectorComponentClipboard.instance.copiedComponetDatas.FirstOrDefault(r => r.sourceComponent == component);
|
||||
var pastableData = VInspectorComponentClipboard.instance.copiedComponetDatas.FirstOrDefault(r => r.sourceComponent.GetType() == component.GetType());
|
||||
|
||||
var isCopied = copiedData != null;
|
||||
var canValuesBePasted = !isCopied && pastableData != null;
|
||||
|
||||
|
||||
|
||||
var buttonRect = headerRect.SetWidthFromRight(buttonSize).MoveX(-buttonsOffsetRight - VInspectorMenu.componentButtons_defaultButtonsCount * buttonSize);
|
||||
|
||||
var iconName = canValuesBePasted ? "Paste values" : isCopied ? "Copied" : "Copy";
|
||||
var iconSize = 16;
|
||||
var color = Greyscale(isDarkTheme ? .78f : .49f);
|
||||
var colorHovered = Greyscale(isDarkTheme ? 1f : .2f);
|
||||
var colorPressed = Greyscale(isDarkTheme ? .8f : .6f);
|
||||
var colorDisabled = Greyscale(.52f);
|
||||
|
||||
deferredTooltips_byRect[buttonRect] = canValuesBePasted ? "Paste values" : isCopied ? "Copied" : "Copy component";
|
||||
|
||||
|
||||
|
||||
var disabled = editingMultiselection;
|
||||
|
||||
if (disabled) { IconButton(buttonRect, iconName, iconSize, colorDisabled, colorDisabled, colorDisabled); return; }
|
||||
|
||||
|
||||
|
||||
if (!IconButton(buttonRect, iconName, iconSize, color, colorHovered, colorPressed)) return;
|
||||
|
||||
if (canValuesBePasted)
|
||||
VInspectorComponentClipboard.PasteComponentValues(pastableData, component);
|
||||
else
|
||||
VInspectorComponentClipboard.CopyComponent(component);
|
||||
|
||||
}
|
||||
void saveInPlaymodeButton()
|
||||
{
|
||||
if (VInspectorMenu.minimalModeEnabled && !headerRect.IsHovered()) return;
|
||||
if (!Application.isPlaying) return;
|
||||
if (!VInspectorMenu.saveInPlaymodeButtonEnabled) return;
|
||||
|
||||
|
||||
var savedData = VInspectorComponentClipboard.instance.savedComponentDatas.FirstOrDefault(r => r.sourceComponent == component);
|
||||
|
||||
var isSaved = savedData != null;
|
||||
|
||||
|
||||
|
||||
var buttonRect = headerRect.SetWidthFromRight(buttonSize).MoveX(-buttonsOffsetRight - (VInspectorMenu.componentButtons_defaultButtonsCount + (VInspectorMenu.copyPasteButtonsEnabled ? 1 : 0)) * buttonSize);
|
||||
|
||||
var iconName = isSaved ? "Saved" : "Save";
|
||||
var iconSize = 16;
|
||||
var color = Greyscale(isDarkTheme ? .8f : .46f);
|
||||
var colorHovered = Greyscale(isDarkTheme ? 1f : .2f);
|
||||
var colorPressed = Greyscale(isDarkTheme ? .8f : .6f);
|
||||
|
||||
deferredTooltips_byRect[buttonRect] = isSaved ? "Saved" : "Save in play mode";
|
||||
|
||||
|
||||
|
||||
|
||||
if (!IconButton(buttonRect, iconName, iconSize, color, colorHovered, colorPressed)) return;
|
||||
|
||||
if (editingMultiselection)
|
||||
foreach (var component in multiselectedComponents)
|
||||
VInspectorComponentClipboard.SaveComponent(component);
|
||||
else
|
||||
VInspectorComponentClipboard.SaveComponent(component);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void expandWithAnimation()
|
||||
{
|
||||
if (!mousePressedOnBackground) return;
|
||||
if (!curEvent.isMouseUp) return;
|
||||
if (curEvent.mouseButton != 0) return;
|
||||
if (headerRect.SetWidth(16).MoveX(40).IsHovered()) return; // enabled toggle
|
||||
if (headerRect.SetWidthFromRight(64).IsHovered()) return; // right buttons
|
||||
|
||||
|
||||
if (curEvent.holdingShift)
|
||||
VInspector.CollapseOtherComponents(component, window);
|
||||
|
||||
else if (VInspectorMenu.componentAnimationsEnabled)
|
||||
VInspector.ToggleComponentExpanded(component, window);
|
||||
|
||||
else return;
|
||||
|
||||
|
||||
mousePressedOnBackground = false;
|
||||
|
||||
curEvent.Use();
|
||||
|
||||
EditorGUIUtility.hotControl = 0;
|
||||
|
||||
}
|
||||
void createComponentWindow()
|
||||
{
|
||||
if (!mousePressedOnBackground) return;
|
||||
if (!curEvent.isMouseDrag) return;
|
||||
if (!curEvent.holdingAlt) return;
|
||||
if (curEvent.mousePosition.DistanceTo(mousePressedOnBackground_initPos) < 2) return;
|
||||
if (!VInspectorMenu.componentWindowsEnabled) return;
|
||||
|
||||
if (VInspectorComponentWindow.draggedInstance != null) return;
|
||||
|
||||
|
||||
|
||||
var position = EditorGUIUtility.GUIToScreenPoint(headerRect.position + (curEvent.mousePosition - mousePressedOnBackground_initPos));
|
||||
|
||||
VInspectorComponentWindow.CreateDraggedInstance(component, position, headerRect.width);
|
||||
|
||||
|
||||
|
||||
EditorGUIUtility.hotControl = 0;
|
||||
|
||||
mousePressedOnBackground = false;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void set_mousePressedOnBackground()
|
||||
{
|
||||
if (curEvent.isMouseDown)
|
||||
{
|
||||
mousePressedOnBackground = true;
|
||||
mousePressedOnBackground_initPos = curEvent.mousePosition;
|
||||
}
|
||||
|
||||
if (curEvent.isMouseUp || curEvent.isDragUpdate)
|
||||
mousePressedOnBackground = false;
|
||||
|
||||
if (!imguiContainer.contentRect.IsHovered())
|
||||
mousePressedOnBackground = false;
|
||||
|
||||
}
|
||||
void set_hoveredComponentHeader()
|
||||
{
|
||||
if (!curEvent.isRepaint) return;
|
||||
|
||||
if (component is Transform)
|
||||
VInspector.hoveredComponentHeader = null;
|
||||
|
||||
if (headerRect.IsHovered())
|
||||
VInspector.hoveredComponentHeader = this;
|
||||
|
||||
}
|
||||
|
||||
void deferredTooltips()
|
||||
{
|
||||
foreach (var kvp in deferredTooltips_byRect)
|
||||
GUI.Label(kvp.Key, new GUIContent("", kvp.Value));
|
||||
|
||||
deferredTooltips_byRect.Clear();
|
||||
|
||||
// tooltips should be drawn before defaultHeaderGUI to take precedence over default tooltips
|
||||
// so in button functions we schedule them to be drawn first thing next repaint
|
||||
// and here we do the drawing
|
||||
|
||||
}
|
||||
|
||||
void defaultHeaderGUI()
|
||||
{
|
||||
void initOffsets()
|
||||
{
|
||||
if (!VInspectorMenu.minimalModeEnabled) return;
|
||||
if (headerContentStyle != null) return;
|
||||
|
||||
headerContentStyle = typeof(EditorStyles).GetMemberValue<GUIStyle>("inspectorTitlebar");
|
||||
headerFoldoutStyle = typeof(EditorStyles).GetMemberValue<GUIStyle>("titlebarFoldout");
|
||||
|
||||
headerContentStyle_defaultLeftPadding = headerContentStyle.padding.left;
|
||||
headerFoldoutStyle_defaultLeftMargin = headerFoldoutStyle.margin.left;
|
||||
|
||||
}
|
||||
void setAdjustedOffsets()
|
||||
{
|
||||
if (!VInspectorMenu.minimalModeEnabled) return;
|
||||
|
||||
headerContentStyle.padding.left = headerContentStyle_defaultLeftPadding - 2;
|
||||
headerFoldoutStyle.margin.left = headerFoldoutStyle_defaultLeftMargin - 1;
|
||||
|
||||
}
|
||||
void setDefaultOffsets()
|
||||
{
|
||||
if (!VInspectorMenu.minimalModeEnabled) return;
|
||||
|
||||
headerContentStyle.padding.left = headerContentStyle_defaultLeftPadding;
|
||||
headerFoldoutStyle.margin.left = headerFoldoutStyle_defaultLeftMargin;
|
||||
|
||||
}
|
||||
|
||||
initOffsets();
|
||||
setAdjustedOffsets();
|
||||
defaultHeaderGUIAction.Invoke();
|
||||
setDefaultOffsets();
|
||||
|
||||
}
|
||||
|
||||
void preventKeyboardFocus()
|
||||
{
|
||||
if (!curEvent.isUsed) return;
|
||||
if (!headerRect.IsHovered()) return;
|
||||
|
||||
GUIUtility.keyboardControl = 0;
|
||||
|
||||
// removes that annoying blue highlight after clicking on header
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (curEvent.isRepaint)
|
||||
{
|
||||
deferredTooltips();
|
||||
defaultHeaderGUI();
|
||||
}
|
||||
|
||||
masks();
|
||||
|
||||
scriptIconClicks();
|
||||
copyPasteButton();
|
||||
saveInPlaymodeButton();
|
||||
|
||||
createComponentWindow();
|
||||
expandWithAnimation();
|
||||
|
||||
set_mousePressedOnBackground();
|
||||
set_hoveredComponentHeader();
|
||||
|
||||
if (!curEvent.isRepaint)
|
||||
{
|
||||
defaultHeaderGUI();
|
||||
preventKeyboardFocus();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public float buttonsOffsetRight = 3;
|
||||
public float buttonSize = 20;
|
||||
|
||||
public bool mousePressedOnBackground;
|
||||
public bool mousePressedOnScriptIcon;
|
||||
public Vector2 mousePressedOnBackground_initPos;
|
||||
public Vector2 mousePressedOnScriptIcon_initPos;
|
||||
|
||||
public Dictionary<Rect, string> deferredTooltips_byRect = new();
|
||||
|
||||
public Rect headerRect
|
||||
{
|
||||
get
|
||||
{
|
||||
var contentRect = imguiContainer.contentRect;
|
||||
|
||||
if (contentRect.height == 42) // with extra lines like "Multi-object editing not supported"
|
||||
return contentRect.SetHeight(22);
|
||||
else
|
||||
return contentRect.SetHeightFromBottom(22); // fixes offset on transform header in 6000
|
||||
}
|
||||
}
|
||||
|
||||
static GUIStyle headerContentStyle;
|
||||
static GUIStyle headerFoldoutStyle;
|
||||
|
||||
static int headerContentStyle_defaultLeftPadding;
|
||||
static int headerFoldoutStyle_defaultLeftMargin;
|
||||
|
||||
public Vector2 mouseDownPos;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public void Update()
|
||||
{
|
||||
if (imguiContainer is VisualElement v && v.panel == null) { imguiContainer.onGUIHandler = defaultHeaderGUIAction; imguiContainer = null; }
|
||||
if (imguiContainer != null && imguiContainer.onGUIHandler.Method.DeclaringType == typeof(VInspectorComponentHeader)) return;
|
||||
if (typeof(ScriptableObject).IsAssignableFrom(component.GetType())) return;
|
||||
if (editor.GetPropertyValue("propertyViewer") is not EditorWindow window) return;
|
||||
|
||||
|
||||
this.window = window;
|
||||
|
||||
void fixWrongWindow_2022_3_26()
|
||||
{
|
||||
if (Application.unityVersion != "2022.3.26f1") return;
|
||||
|
||||
if (!window.hasFocus)
|
||||
window = window.GetMemberValue("m_Parent")?.GetMemberValue<List<EditorWindow>>("m_Panes")?.FirstOrDefault(r => r.hasFocus) ?? window;
|
||||
|
||||
// in 2022.3.26 wrong inspector may be returned by propertyViewer when there are multiple inspectors
|
||||
// also the same instance of an editor may be used on all inspectors
|
||||
// here we fix it for cases when multiple inspectors are in the same dock area
|
||||
|
||||
}
|
||||
void findHeader(VisualElement element)
|
||||
{
|
||||
if (element == null) return;
|
||||
|
||||
if (element.GetType().Name == "EditorElement")
|
||||
{
|
||||
IMGUIContainer curHeaderImguiContainer = null;
|
||||
|
||||
foreach (var child in element.Children())
|
||||
{
|
||||
curHeaderImguiContainer ??= new[] { child as IMGUIContainer }.FirstOrDefault(r => r != null && r.name.EndsWith("Header"));
|
||||
|
||||
if (curHeaderImguiContainer is null) continue;
|
||||
if (child is not InspectorElement) continue;
|
||||
if (child.GetFieldValue("m_Editor") is not Editor editor) continue;
|
||||
if (editor.target != component) continue;
|
||||
|
||||
imguiContainer = curHeaderImguiContainer;
|
||||
|
||||
if (editingMultiselection = editor.targets.Count() > 1)
|
||||
multiselectedComponents = editor.targets.Cast<Component>().ToList();
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
foreach (var r in element.Children())
|
||||
if (imguiContainer == null)
|
||||
findHeader(r);
|
||||
|
||||
}
|
||||
void setupGUICallbacks()
|
||||
{
|
||||
if (imguiContainer == null) return;
|
||||
|
||||
defaultHeaderGUIAction = imguiContainer.onGUIHandler;
|
||||
imguiContainer.onGUIHandler = OnGUI;
|
||||
}
|
||||
|
||||
fixWrongWindow_2022_3_26();
|
||||
findHeader(window.rootVisualElement);
|
||||
setupGUICallbacks();
|
||||
|
||||
}
|
||||
|
||||
public bool editingMultiselection;
|
||||
public List<Component> multiselectedComponents;
|
||||
|
||||
IMGUIContainer imguiContainer;
|
||||
System.Action defaultHeaderGUIAction;
|
||||
|
||||
EditorWindow window;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public VInspectorComponentHeader(Component component, Editor editor) { this.component = component; this.editor = editor; }
|
||||
|
||||
public Editor editor;
|
||||
public Component component;
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 69daed4ccfde7447ba633e320119de35
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,390 +0,0 @@
|
||||
#if UNITY_EDITOR
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using UnityEditor.ShortcutManagement;
|
||||
using System.Reflection;
|
||||
using System.Linq;
|
||||
using UnityEngine.UIElements;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEditor.SceneManagement;
|
||||
using Type = System.Type;
|
||||
using static VInspector.Libs.VUtils;
|
||||
using static VInspector.Libs.VGUI;
|
||||
|
||||
|
||||
|
||||
namespace VInspector
|
||||
{
|
||||
public class VInspectorComponentWindow : EditorWindow
|
||||
{
|
||||
|
||||
void OnGUI()
|
||||
{
|
||||
if (!component || !editor) { Close(); return; } // todo script components break on playmode
|
||||
|
||||
|
||||
void background()
|
||||
{
|
||||
position.SetPos(0, 0).Draw(GUIColors.windowBackground);
|
||||
}
|
||||
void outline()
|
||||
{
|
||||
if (Application.platform == RuntimePlatform.OSXEditor) return;
|
||||
|
||||
position.SetPos(0, 0).DrawOutline(Greyscale(.1f));
|
||||
|
||||
}
|
||||
void header()
|
||||
{
|
||||
var headerRect = ExpandWidthLabelRect(18).Resize(-1).AddWidthFromMid(6);
|
||||
var closeButtonRect = headerRect.SetWidthFromRight(16).SetHeightFromMid(16).Move(-4, 0);
|
||||
|
||||
var backgroundColor = isDarkTheme ? Greyscale(.25f) : GUIColors.windowBackground;
|
||||
|
||||
void startDragging()
|
||||
{
|
||||
if (isResizing) return;
|
||||
if (isDragged) return;
|
||||
if (!curEvent.isMouseDrag) return;
|
||||
if (!headerRect.IsHovered()) return;
|
||||
|
||||
|
||||
draggedInstance = this;
|
||||
|
||||
dragStartMousePos = EditorGUIUtility.GUIToScreenPoint(curEvent.mousePosition);
|
||||
dragStartWindowPos = position.position;
|
||||
|
||||
}
|
||||
void updateDragging()
|
||||
{
|
||||
if (!isDragged) return;
|
||||
|
||||
|
||||
var draggedPosition = dragStartWindowPos + EditorGUIUtility.GUIToScreenPoint(curEvent.mousePosition) - dragStartMousePos;
|
||||
|
||||
if (!curEvent.isRepaint)
|
||||
position = position.SetPos(draggedPosition);
|
||||
|
||||
|
||||
EditorGUIUtility.hotControl = EditorGUIUtility.GetControlID(FocusType.Passive);
|
||||
|
||||
}
|
||||
void stopDragging()
|
||||
{
|
||||
if (!isDragged) return;
|
||||
if (!curEvent.isMouseMove && !curEvent.isMouseUp) return;
|
||||
|
||||
|
||||
draggedInstance = null;
|
||||
|
||||
EditorGUIUtility.hotControl = 0;
|
||||
|
||||
}
|
||||
|
||||
void background()
|
||||
{
|
||||
headerRect.Draw(backgroundColor);
|
||||
|
||||
headerRect.SetHeightFromBottom(1).Draw(isDarkTheme ? Greyscale(.2f) : Greyscale(.7f));
|
||||
|
||||
}
|
||||
void icon()
|
||||
{
|
||||
var iconRect = headerRect.SetWidth(20).MoveX(14).MoveY(-1);
|
||||
|
||||
if (!componentIcons_byType.ContainsKey(component.GetType()))
|
||||
componentIcons_byType[component.GetType()] = EditorGUIUtility.ObjectContent(component, component.GetType()).image;
|
||||
|
||||
GUI.Label(iconRect, componentIcons_byType[component.GetType()]);
|
||||
|
||||
}
|
||||
void toggle()
|
||||
{
|
||||
var toggleRect = headerRect.MoveX(36).SetSize(20, 20);
|
||||
|
||||
|
||||
var pi_enabled = component.GetType().GetProperty("enabled") ??
|
||||
component.GetType().BaseType?.GetProperty("enabled") ??
|
||||
component.GetType().BaseType?.BaseType?.GetProperty("enabled") ??
|
||||
component.GetType().BaseType?.BaseType?.BaseType?.GetProperty("enabled");
|
||||
|
||||
|
||||
if (pi_enabled == null) return;
|
||||
|
||||
var enabled = (bool)pi_enabled.GetValue(component);
|
||||
|
||||
|
||||
if (GUI.Toggle(toggleRect, enabled, "") == enabled) return;
|
||||
|
||||
component.RecordUndo();
|
||||
pi_enabled.SetValue(component, !enabled);
|
||||
|
||||
}
|
||||
void name()
|
||||
{
|
||||
var nameRect = headerRect.MoveX(54).MoveY(-1);
|
||||
|
||||
|
||||
var s = new GUIContent(EditorGUIUtility.ObjectContent(component, component.GetType())).text;
|
||||
s = s.Substring(s.LastIndexOf('(') + 1);
|
||||
s = s.Substring(0, s.Length - 1);
|
||||
|
||||
if (instances.Any(r => r.component.GetType() == component.GetType() && r.component != component))
|
||||
s += " - " + component.gameObject.name;
|
||||
|
||||
|
||||
SetLabelBold();
|
||||
|
||||
GUI.Label(nameRect, s);
|
||||
|
||||
ResetLabelStyle();
|
||||
|
||||
}
|
||||
void nameCurtain()
|
||||
{
|
||||
var flatColorRect = headerRect.SetX(closeButtonRect.x + 3).SetXMax(headerRect.xMax);
|
||||
var gradientRect = headerRect.SetXMax(flatColorRect.x).SetWidthFromRight(30);
|
||||
|
||||
flatColorRect.Draw(backgroundColor);
|
||||
gradientRect.DrawCurtainLeft(backgroundColor);
|
||||
|
||||
}
|
||||
void closeButton()
|
||||
{
|
||||
var iconName = "CrossIcon";
|
||||
var iconSize = 14;
|
||||
var color = isDarkTheme ? Greyscale(.65f) : Greyscale(.35f);
|
||||
var colorHovered = isDarkTheme ? Greyscale(.9f) : color;
|
||||
var colorPressed = color;
|
||||
|
||||
|
||||
if (!IconButton(closeButtonRect, iconName, iconSize, color, colorHovered, colorPressed)) return;
|
||||
|
||||
Close();
|
||||
|
||||
EditorGUIUtility.ExitGUI();
|
||||
|
||||
}
|
||||
void escHint()
|
||||
{
|
||||
if (!closeButtonRect.IsHovered()) return;
|
||||
if (EditorWindow.focusedWindow != this) return;
|
||||
|
||||
var textRect = headerRect.SetWidthFromRight(42).MoveY(-.5f);
|
||||
var fontSize = 11;
|
||||
var color = Greyscale(.65f);
|
||||
|
||||
|
||||
SetLabelFontSize(fontSize);
|
||||
SetGUIColor(color);
|
||||
|
||||
GUI.Label(textRect, "Esc");
|
||||
|
||||
ResetGUIColor();
|
||||
ResetLabelStyle();
|
||||
|
||||
}
|
||||
|
||||
startDragging();
|
||||
updateDragging();
|
||||
stopDragging();
|
||||
|
||||
background();
|
||||
icon();
|
||||
toggle();
|
||||
name();
|
||||
nameCurtain();
|
||||
closeButton();
|
||||
escHint();
|
||||
|
||||
}
|
||||
void body()
|
||||
{
|
||||
EditorGUIUtility.labelWidth = (this.position.width * .4f).Max(120);
|
||||
|
||||
BeginIndent(17);
|
||||
|
||||
editor?.OnInspectorGUI();
|
||||
|
||||
EndIndent(1);
|
||||
|
||||
EditorGUIUtility.labelWidth = 0;
|
||||
|
||||
}
|
||||
|
||||
void updateHeight()
|
||||
{
|
||||
var r = ExpandWidthLabelRect();
|
||||
|
||||
if (curEvent.isRepaint)
|
||||
position = position.SetHeight(lastRect.y);
|
||||
|
||||
}
|
||||
void closeOnEscape()
|
||||
{
|
||||
if (!curEvent.isKeyDown) return;
|
||||
if (curEvent.keyCode != KeyCode.Escape) return;
|
||||
|
||||
Close();
|
||||
|
||||
EditorGUIUtility.ExitGUI();
|
||||
|
||||
}
|
||||
|
||||
void horizontalResize()
|
||||
{
|
||||
var resizeArea = this.position.SetPos(0, 0).SetWidthFromRight(5).AddHeightFromBottom(-20);
|
||||
|
||||
void startResize()
|
||||
{
|
||||
if (isDragged) return;
|
||||
if (isResizing) return;
|
||||
if (!curEvent.isMouseDown && !curEvent.isMouseDrag) return;
|
||||
if (!resizeArea.IsHovered()) return;
|
||||
|
||||
isResizing = true;
|
||||
|
||||
resizeStartMousePos = EditorGUIUtility.GUIToScreenPoint(curEvent.mousePosition);
|
||||
resizeStartWindowSize = this.position.size;
|
||||
|
||||
}
|
||||
void updateResize()
|
||||
{
|
||||
if (!isResizing) return;
|
||||
|
||||
|
||||
var resizedWidth = resizeStartWindowSize.x + EditorGUIUtility.GUIToScreenPoint(curEvent.mousePosition).x - resizeStartMousePos.x;
|
||||
|
||||
var width = resizedWidth.Max(minWidth);
|
||||
|
||||
if (!curEvent.isRepaint)
|
||||
position = position.SetWidth(width);
|
||||
|
||||
|
||||
EditorGUIUtility.hotControl = EditorGUIUtility.GetControlID(FocusType.Passive);
|
||||
// GUI.focused
|
||||
|
||||
}
|
||||
void stopResize()
|
||||
{
|
||||
if (!isResizing) return;
|
||||
if (!curEvent.isMouseUp) return;
|
||||
|
||||
isResizing = false;
|
||||
|
||||
EditorGUIUtility.hotControl = 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
EditorGUIUtility.AddCursorRect(resizeArea, MouseCursor.ResizeHorizontal);
|
||||
|
||||
startResize();
|
||||
updateResize();
|
||||
stopResize();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
background();
|
||||
header();
|
||||
outline();
|
||||
|
||||
Space(3);
|
||||
body();
|
||||
|
||||
Space(7);
|
||||
|
||||
|
||||
updateHeight();
|
||||
closeOnEscape();
|
||||
|
||||
horizontalResize();
|
||||
|
||||
if (isDragged)
|
||||
Repaint();
|
||||
|
||||
}
|
||||
|
||||
public bool isDragged => draggedInstance == this;
|
||||
public Vector2 dragStartMousePos;
|
||||
public Vector2 dragStartWindowPos;
|
||||
|
||||
public bool isResizing;
|
||||
public Vector2 resizeStartMousePos;
|
||||
public Vector2 resizeStartWindowSize;
|
||||
|
||||
static Dictionary<System.Type, Texture> componentIcons_byType = new();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public void Init(Component component)
|
||||
{
|
||||
if (editor)
|
||||
editor.DestroyImmediate();
|
||||
|
||||
this.component = component;
|
||||
this.editor = Editor.CreateEditor(component);
|
||||
|
||||
if (!instances.Contains(this))
|
||||
instances.Add(this);
|
||||
|
||||
}
|
||||
|
||||
void OnDestroy()
|
||||
{
|
||||
editor?.DestroyImmediate();
|
||||
|
||||
if (instances.Contains(this))
|
||||
instances.Remove(this);
|
||||
|
||||
}
|
||||
|
||||
public Component component;
|
||||
public Editor editor;
|
||||
|
||||
public static List<VInspectorComponentWindow> instances = new();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static void CreateDraggedInstance(Component component, Vector2 windowPosition, float windowWidth)
|
||||
{
|
||||
draggedInstance = ScriptableObject.CreateInstance<VInspectorComponentWindow>();
|
||||
|
||||
draggedInstance.ShowPopup();
|
||||
draggedInstance.Init(component);
|
||||
draggedInstance.Focus();
|
||||
|
||||
draggedInstance.wantsMouseMove = true;
|
||||
|
||||
|
||||
draggedInstance.position = Rect.zero.SetPos(windowPosition).SetWidth(windowWidth).SetHeight(200);
|
||||
|
||||
draggedInstance.dragStartMousePos = curEvent.mousePosition_screenSpace;
|
||||
draggedInstance.dragStartWindowPos = windowPosition;
|
||||
|
||||
}
|
||||
|
||||
public static VInspectorComponentWindow draggedInstance;
|
||||
|
||||
public static float minWidth => 300;
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 295e0a9b2039246c59fbe00423b2723e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,185 +0,0 @@
|
||||
#if UNITY_EDITOR
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
using UnityEditor;
|
||||
using UnityEditor.ShortcutManagement;
|
||||
using System.Reflection;
|
||||
using System.Linq;
|
||||
using UnityEngine.UIElements;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEditor.SceneManagement;
|
||||
using Type = System.Type;
|
||||
using static VInspector.VInspectorState;
|
||||
using static VInspector.Libs.VUtils;
|
||||
using static VInspector.Libs.VGUI;
|
||||
|
||||
|
||||
|
||||
namespace VInspector
|
||||
{
|
||||
public class VInspectorData : ScriptableObject, ISerializationCallbackReceiver
|
||||
{
|
||||
|
||||
public List<Item> items = new();
|
||||
|
||||
[System.Serializable]
|
||||
public class Item
|
||||
{
|
||||
public GlobalID globalId;
|
||||
|
||||
|
||||
public Type type => Type.GetType(_typeString) ?? typeof(DefaultAsset);
|
||||
public string _typeString;
|
||||
|
||||
public Object obj
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_obj == null && !isSceneGameObject)
|
||||
_obj = globalId.GetObject();
|
||||
|
||||
return _obj;
|
||||
|
||||
// updating scene objects here using globalId.GetObject() could cause performance issues on large scenes
|
||||
// so instead they are batch updated in VInspector.UpdateBookmarkedObjectsForScene()
|
||||
|
||||
}
|
||||
}
|
||||
public Object _obj;
|
||||
|
||||
|
||||
public bool isSceneGameObject;
|
||||
public bool isAsset;
|
||||
|
||||
|
||||
public bool isLoadable => obj != null;
|
||||
|
||||
public bool isDeleted
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!isSceneGameObject)
|
||||
return !isLoadable;
|
||||
|
||||
if (isLoadable)
|
||||
return false;
|
||||
|
||||
if (!AssetDatabase.LoadAssetAtPath<SceneAsset>(globalId.guid.ToPath()))
|
||||
return true;
|
||||
|
||||
for (int i = 0; i < EditorSceneManager.sceneCount; i++)
|
||||
if (EditorSceneManager.GetSceneAt(i).path == globalId.guid.ToPath())
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public string assetPath => globalId.guid.ToPath();
|
||||
|
||||
|
||||
public Item(Object o)
|
||||
{
|
||||
globalId = o.GetGlobalID();
|
||||
|
||||
id = Random.value.GetHashCode();
|
||||
|
||||
isSceneGameObject = o is GameObject go && go.scene.rootCount != 0;
|
||||
isAsset = !isSceneGameObject;
|
||||
|
||||
_typeString = o.GetType().AssemblyQualifiedName;
|
||||
|
||||
_name = o.name;
|
||||
|
||||
_obj = o;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public float width => VInspectorNavbar.expandedItemWidth;
|
||||
|
||||
|
||||
|
||||
|
||||
public string name
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!isLoadable) return _name;
|
||||
|
||||
if (assetPath.GetExtension() == ".cs")
|
||||
_name = obj.name.Decamelcase();
|
||||
else
|
||||
_name = obj.name;
|
||||
|
||||
return _name;
|
||||
|
||||
}
|
||||
}
|
||||
public string _name { get => state._name; set => state._name = value; }
|
||||
|
||||
public string sceneGameObjectIconName { get => state.sceneGameObjectIconName; set => state.sceneGameObjectIconName = value; }
|
||||
|
||||
|
||||
|
||||
public ItemState state
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!VInspectorState.instance.itemStates_byItemId.ContainsKey(id))
|
||||
VInspectorState.instance.itemStates_byItemId[id] = new ItemState();
|
||||
|
||||
return VInspectorState.instance.itemStates_byItemId[id];
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public int id;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void OnAfterDeserialize() => VInspectorNavbar.repaintNeededAfterUndoRedo = true;
|
||||
public void OnBeforeSerialize() { }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
[CustomEditor(typeof(VInspectorData))]
|
||||
class Editor : UnityEditor.Editor
|
||||
{
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
var style = EditorStyles.label;
|
||||
style.wordWrap = true;
|
||||
|
||||
|
||||
SetGUIEnabled(false);
|
||||
BeginIndent(0);
|
||||
|
||||
Space(10);
|
||||
EditorGUILayout.LabelField("This file stores bookmarks from vInspector's navigation bar", style);
|
||||
|
||||
EndIndent(10);
|
||||
ResetGUIEnabled();
|
||||
|
||||
// Space(15);
|
||||
// base.OnInspectorGUI();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b7915df4cd4da490ab52fc8fa9ee9127
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,318 +0,0 @@
|
||||
#if UNITY_EDITOR
|
||||
using System.Collections;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using UnityEditor.UIElements;
|
||||
using System.Reflection;
|
||||
using UnityEditor;
|
||||
using UnityEditorInternal;
|
||||
using Type = System.Type;
|
||||
using Attribute = System.Attribute;
|
||||
using static VInspector.VInspectorState;
|
||||
using static VInspector.Libs.VUtils;
|
||||
using static VInspector.Libs.VGUI;
|
||||
|
||||
|
||||
|
||||
namespace VInspector
|
||||
{
|
||||
[CustomPropertyDrawer(typeof(SerializedDictionary<,>), true)]
|
||||
public class SerializedDictionaryDrawer : PropertyDrawer
|
||||
{
|
||||
public override void OnGUI(Rect rect, SerializedProperty prop, GUIContent label)
|
||||
{
|
||||
var indentedRect = EditorGUI.IndentedRect(rect);
|
||||
|
||||
void header()
|
||||
{
|
||||
var headerRect = indentedRect.SetHeight(EditorGUIUtility.singleLineHeight);
|
||||
|
||||
void foldout()
|
||||
{
|
||||
var fullHeaderRect = headerRect.MoveX(3).AddWidthFromRight(17);
|
||||
|
||||
if (fullHeaderRect.IsHovered())
|
||||
fullHeaderRect.Draw(Greyscale(1, .07f));
|
||||
|
||||
SetGUIColor(Color.clear);
|
||||
SetGUIEnabled(true);
|
||||
|
||||
if (GUI.Button(fullHeaderRect.AddWidth(-50), ""))
|
||||
prop.isExpanded = !prop.isExpanded;
|
||||
|
||||
ResetGUIColor();
|
||||
ResetGUIEnabled();
|
||||
|
||||
|
||||
|
||||
var triangleRect = rect.SetHeight(EditorGUIUtility.singleLineHeight);
|
||||
|
||||
SetGUIEnabled(true);
|
||||
|
||||
EditorGUI.Foldout(triangleRect, prop.isExpanded, "");
|
||||
|
||||
ResetGUIEnabled();
|
||||
|
||||
|
||||
}
|
||||
void label()
|
||||
{
|
||||
SetLabelBold();
|
||||
SetLabelFontSize(12);
|
||||
SetGUIColor(Greyscale(.9f));
|
||||
SetGUIEnabled(true);
|
||||
|
||||
GUI.Label(headerRect, prop.displayName);
|
||||
|
||||
ResetGUIEnabled();
|
||||
ResetGUIColor();
|
||||
ResetLabelStyle();
|
||||
|
||||
}
|
||||
void count()
|
||||
{
|
||||
kvpsProp.arraySize = EditorGUI.DelayedIntField(headerRect.SetWidthFromRight(48 + EditorGUI.indentLevel * 15), kvpsProp.arraySize);
|
||||
}
|
||||
void repeatedKeysWarning()
|
||||
{
|
||||
if (!curEvent.isRepaint) return;
|
||||
|
||||
|
||||
var hasRepeated = false;
|
||||
|
||||
for (int i = 0; i < kvpsProp.arraySize; i++)
|
||||
hasRepeated |= kvpsProp.GetArrayElementAtIndex(i).FindPropertyRelative("isKeyRepeated").boolValue;
|
||||
|
||||
|
||||
if (!hasRepeated) return;
|
||||
|
||||
var warningRect = headerRect.AddWidthFromRight(-prop.displayName.GetLabelWidth(isBold: true));
|
||||
|
||||
GUI.Label(warningRect.SetHeightFromMid(20).SetWidth(20), EditorGUIUtility.IconContent("Warning"));
|
||||
|
||||
SetGUIColor(new Color(1, .9f, .03f) * 1.1f);
|
||||
GUI.Label(warningRect.MoveX(16), "Repeated keys");
|
||||
ResetGUIColor();
|
||||
|
||||
}
|
||||
|
||||
foldout();
|
||||
label();
|
||||
count();
|
||||
repeatedKeysWarning();
|
||||
|
||||
}
|
||||
void list_()
|
||||
{
|
||||
if (!prop.isExpanded) return;
|
||||
|
||||
SetupList(prop);
|
||||
|
||||
list.DoList(indentedRect.AddHeightFromBottom(-EditorGUIUtility.singleLineHeight - 3));
|
||||
}
|
||||
|
||||
|
||||
SetupProps(prop);
|
||||
|
||||
header();
|
||||
list_();
|
||||
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
|
||||
{
|
||||
SetupProps(prop);
|
||||
|
||||
var height = EditorGUIUtility.singleLineHeight;
|
||||
|
||||
if (prop.isExpanded)
|
||||
{
|
||||
SetupList(prop);
|
||||
height += list.GetHeight() + 3;
|
||||
}
|
||||
|
||||
return height;
|
||||
}
|
||||
|
||||
float GetListElementHeight(int index)
|
||||
{
|
||||
var kvpProp = kvpsProp.GetArrayElementAtIndex(index);
|
||||
var keyProp = kvpProp.FindPropertyRelative("Key");
|
||||
var valueProp = kvpProp.FindPropertyRelative("Value");
|
||||
|
||||
float propHeight(SerializedProperty prop)
|
||||
{
|
||||
// var height = typeof(Editor).Assembly.GetType("UnityEditor.ScriptAttributeUtility").InvokeMethod("GetHandler", prop).InvokeMethod<float>("GetHeight", prop, GUIContent.none, true);
|
||||
var height = EditorGUI.GetPropertyHeight(prop);
|
||||
|
||||
if (!IsSingleLine(prop))
|
||||
height -= 10;
|
||||
|
||||
return height;
|
||||
|
||||
}
|
||||
|
||||
return Mathf.Max(propHeight(keyProp), propHeight(valueProp));
|
||||
|
||||
}
|
||||
|
||||
void DrawListElement(Rect rect, int index, bool isActive, bool isFocused)
|
||||
{
|
||||
Rect keyRect;
|
||||
Rect valueRect;
|
||||
Rect dividerRect;
|
||||
|
||||
var kvpProp = kvpsProp.GetArrayElementAtIndex(index);
|
||||
var keyProp = kvpProp.FindPropertyRelative("Key");
|
||||
var valueProp = kvpProp.FindPropertyRelative("Value");
|
||||
|
||||
void drawProp(Rect rect, SerializedProperty prop)
|
||||
{
|
||||
if (IsSingleLine(prop)) { EditorGUI.PropertyField(rect.SetHeight(EditorGUIUtility.singleLineHeight), prop, GUIContent.none); return; }
|
||||
|
||||
|
||||
prop.isExpanded = true;
|
||||
|
||||
GUI.BeginGroup(rect);
|
||||
|
||||
EditorGUI.PropertyField(rect.SetPos(0, -20), prop, true);
|
||||
|
||||
GUI.EndGroup();
|
||||
|
||||
}
|
||||
|
||||
void rects()
|
||||
{
|
||||
var dividerWidh = 6f;
|
||||
|
||||
var dividerPos = dividerPosProp.floatValue.Clamp(.2f, .8f);
|
||||
|
||||
var fullRect = rect.AddWidthFromRight(-1).AddHeightFromMid(-2);
|
||||
|
||||
keyRect = fullRect.SetWidth(fullRect.width * dividerPos - dividerWidh / 2);
|
||||
valueRect = fullRect.SetWidthFromRight(fullRect.width * (1 - dividerPos) - dividerWidh / 2);
|
||||
dividerRect = fullRect.MoveX(fullRect.width * dividerPos - dividerWidh / 2).SetWidth(dividerWidh).Resize(-1);
|
||||
|
||||
}
|
||||
void key()
|
||||
{
|
||||
drawProp(keyRect, keyProp);
|
||||
|
||||
if (kvpProp.FindPropertyRelative("isKeyRepeated").boolValue)
|
||||
GUI.Label(keyRect.SetWidthFromRight(20).SetHeight(20).MoveY(-1), EditorGUIUtility.IconContent("Warning"));
|
||||
|
||||
}
|
||||
void value()
|
||||
{
|
||||
drawProp(valueRect, valueProp);
|
||||
}
|
||||
void divider()
|
||||
{
|
||||
EditorGUIUtility.AddCursorRect(dividerRect, MouseCursor.ResizeHorizontal);
|
||||
|
||||
if (!rect.IsHovered()) return;
|
||||
|
||||
if (dividerRect.IsHovered())
|
||||
{
|
||||
if (curEvent.isMouseDown)
|
||||
isDividerDragged = true;
|
||||
|
||||
if (curEvent.isMouseUp || curEvent.isMouseMove || curEvent.isMouseLeaveWindow)
|
||||
isDividerDragged = false;
|
||||
}
|
||||
|
||||
if (isDividerDragged && curEvent.isMouseDrag)
|
||||
dividerPosProp.floatValue += curEvent.mouseDelta.x / rect.width;
|
||||
|
||||
}
|
||||
|
||||
rects();
|
||||
key();
|
||||
value();
|
||||
divider();
|
||||
|
||||
}
|
||||
|
||||
void DrawDictionaryIsEmpty(Rect rect) => GUI.Label(rect, "Dictionary is empty");
|
||||
|
||||
|
||||
|
||||
IEnumerable<SerializedProperty> GetChildren(SerializedProperty prop, bool enterVisibleGrandchildren)
|
||||
{
|
||||
var startPath = prop.propertyPath;
|
||||
|
||||
var enterVisibleChildren = true;
|
||||
|
||||
while (prop.NextVisible(enterVisibleChildren) && prop.propertyPath.StartsWith(startPath))
|
||||
{
|
||||
yield return prop;
|
||||
enterVisibleChildren = enterVisibleGrandchildren;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool IsSingleLine(SerializedProperty prop) => prop.propertyType != SerializedPropertyType.Generic || !prop.hasVisibleChildren;
|
||||
|
||||
|
||||
|
||||
public void SetupList(SerializedProperty prop)
|
||||
{
|
||||
if (list != null) return;
|
||||
|
||||
SetupProps(prop);
|
||||
|
||||
this.list = new ReorderableList(kvpsProp.serializedObject, kvpsProp, true, false, true, true);
|
||||
this.list.drawElementCallback = DrawListElement;
|
||||
this.list.elementHeightCallback = GetListElementHeight;
|
||||
this.list.drawNoneElementCallback = DrawDictionaryIsEmpty;
|
||||
|
||||
}
|
||||
ReorderableList list;
|
||||
bool isDividerDragged;
|
||||
|
||||
|
||||
public void SetupProps(SerializedProperty prop)
|
||||
{
|
||||
if (this.prop != null) return;
|
||||
|
||||
this.prop = prop;
|
||||
this.kvpsProp = prop.FindPropertyRelative("serializedKvps");
|
||||
this.dividerPosProp = prop.FindPropertyRelative("dividerPos");
|
||||
|
||||
|
||||
}
|
||||
SerializedProperty prop;
|
||||
SerializedProperty kvpsProp;
|
||||
SerializedProperty dividerPosProp;
|
||||
|
||||
}
|
||||
|
||||
|
||||
[CustomPropertyDrawer(typeof(VariantsAttribute))]
|
||||
public class VariantsAttributeDrawer : PropertyDrawer
|
||||
{
|
||||
public override void OnGUI(Rect rect, SerializedProperty prop, GUIContent label)
|
||||
{
|
||||
var variants = ((VariantsAttribute)attribute).variants;
|
||||
|
||||
|
||||
EditorGUI.BeginProperty(rect, label, prop);
|
||||
|
||||
var iCur = prop.hasMultipleDifferentValues ? -1 : variants.ToList().IndexOf(prop.GetBoxedValue());
|
||||
|
||||
var iNew = EditorGUI.IntPopup(rect, label.text, iCur, variants.Select(r => r.ToString()).ToArray(), Enumerable.Range(0, variants.Length).ToArray());
|
||||
|
||||
if (iNew != -1)
|
||||
prop.SetBoxedValue(variants[iNew]);
|
||||
else if (!prop.hasMultipleDifferentValues)
|
||||
prop.SetBoxedValue(variants[0]);
|
||||
|
||||
EditorGUI.EndProperty();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 481331f9e0bfe494f98ee0fc8ebfeb84
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4a8eec962d2dd440196b02dca0f62e3e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 077bd88e5e3a2421b8bd152c5b813ea2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,180 +0,0 @@
|
||||
#if UNITY_EDITOR
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Compilation;
|
||||
using static VInspector.Libs.VUtils;
|
||||
using static VInspector.Libs.VGUI;
|
||||
|
||||
|
||||
namespace VInspector
|
||||
{
|
||||
class VInspectorMenu
|
||||
{
|
||||
public static bool navigationBarEnabled { get => EditorPrefs.GetBool("vInspector-navigationBarEnabled", false); set => EditorPrefs.SetBool("vInspector-navigationBarEnabled", value); }
|
||||
public static bool copyPasteButtonsEnabled { get => EditorPrefs.GetBool("vInspector-copyPasteButtonsEnabled", false); set => EditorPrefs.SetBool("vInspector-copyPasteButtonsEnabled", value); }
|
||||
public static bool saveInPlaymodeButtonEnabled { get => EditorPrefs.GetBool("vInspector-saveInPlaymodeButtonEnabled", false); set => EditorPrefs.SetBool("vInspector-saveInPlaymodeButtonEnabled", value); }
|
||||
public static bool componentWindowsEnabled { get => EditorPrefs.GetBool("vInspector-componentWindowsEnabled", false); set => EditorPrefs.SetBool("vInspector-componentWindowsEnabled", value); }
|
||||
public static bool componentAnimationsEnabled { get => EditorPrefs.GetBool("vInspector-componentAnimationsEnabled", false); set => EditorPrefs.SetBool("vInspector-componentAnimationsEnabled", value); }
|
||||
public static bool minimalModeEnabled { get => EditorPrefs.GetBool("vInspector-minimalModeEnabled", false); set => EditorPrefs.SetBool("vInspector-minimalModeEnabled", value); }
|
||||
public static bool attributesEnabled { get => EditorPrefs.GetBool("vInspector-attributesEnabled", false); set => EditorPrefs.SetBool("vInspector-attributesEnabled", value); }
|
||||
public static bool resettableVariablesEnabled { get => EditorPrefs.GetBool("vInspector-resettableVariablesEnabled", false); set => EditorPrefs.SetBool("vInspector-resettableVariablesEnabled", value); }
|
||||
public static bool hideScriptFieldEnabled { get => EditorPrefs.GetBool("vInspector-hideScriptFieldEnabled", false); set => EditorPrefs.SetBool("vInspector-hideScriptFieldEnabled", value); }
|
||||
public static bool hideHelpButtonEnabled { get => !helpButtonEnabled; set => helpButtonEnabled = !value; }
|
||||
public static bool hidePresetsButtonEnabled { get => !presetsButtonEnabled; set => presetsButtonEnabled = !value; }
|
||||
|
||||
public static bool toggleActiveEnabled { get => EditorPrefs.GetBool("vInspector-toggleActiveEnabled", true); set => EditorPrefs.SetBool("vInspector-toggleActiveEnabled", value); }
|
||||
public static bool deleteEnabled { get => EditorPrefs.GetBool("vInspector-deleteEnabled", true); set => EditorPrefs.SetBool("vInspector-deleteEnabled", value); }
|
||||
public static bool toggleExpandedEnabled { get => EditorPrefs.GetBool("vInspector-toggleExpandedEnabled", true); set => EditorPrefs.SetBool("vInspector-toggleExpandedEnabled", value); }
|
||||
public static bool collapseEverythingElseEnabled { get => EditorPrefs.GetBool("vInspector-collapseEverythingElseEnabled", true); set => EditorPrefs.SetBool("vInspector-collapseEverythingElseEnabled", value); }
|
||||
public static bool collapseEverythingEnabled { get => EditorPrefs.GetBool("vInspector-collapseEverythingEnabled", true); set => EditorPrefs.SetBool("vInspector-collapseEverythingEnabled", value); }
|
||||
|
||||
public static bool attributesDisabled { get => IsSymbolDefinedInAsmdef(nameof(VInspector), "VINSPECTOR_ATTRIBUTES_DISABLED"); set => SetSymbolDefinedInAsmdef(nameof(VInspector), "VINSPECTOR_ATTRIBUTES_DISABLED", value); }
|
||||
public static bool pluginDisabled { get => EditorPrefs.GetBool("vInspector-pluginDisabled-" + GetProjectId(), false); set => EditorPrefs.SetBool("vInspector-pluginDisabled-" + GetProjectId(), value); }
|
||||
|
||||
|
||||
public static int componentButtons_defaultButtonsCount { get => EditorPrefs.GetInt("vInspector-componentButtons_defaultButtonsCount", 3); set => EditorPrefs.SetInt("vInspector-componentButtons_defaultButtonsCount", value); }
|
||||
public static bool menuButtonEnabled { get => componentButtons_defaultButtonsCount >= 1; set => componentButtons_defaultButtonsCount = value ? 1 : 0; }
|
||||
public static bool presetsButtonEnabled { get => componentButtons_defaultButtonsCount >= 2; set => componentButtons_defaultButtonsCount = value ? 2 : 1; }
|
||||
public static bool helpButtonEnabled { get => componentButtons_defaultButtonsCount >= 3; set => componentButtons_defaultButtonsCount = value ? 3 : 2; }
|
||||
|
||||
|
||||
|
||||
public static void RepaintInspectors()
|
||||
{
|
||||
Resources.FindObjectsOfTypeAll(typeof(Editor).Assembly.GetType("UnityEditor.InspectorWindow"))
|
||||
.Cast<EditorWindow>()
|
||||
.ForEach(r => r.Repaint());
|
||||
|
||||
Resources.FindObjectsOfTypeAll(typeof(Editor).Assembly.GetType("UnityEditor.PropertyEditor"))
|
||||
.Where(r => r.GetType().BaseType == typeof(EditorWindow))
|
||||
.Cast<EditorWindow>()
|
||||
.ForEach(r => r.Repaint());
|
||||
}
|
||||
|
||||
|
||||
|
||||
const string dir = "Tools/vInspector/";
|
||||
#if UNITY_EDITOR_OSX
|
||||
const string cmd = "Cmd";
|
||||
#else
|
||||
const string cmd = "Ctrl";
|
||||
#endif
|
||||
|
||||
const string navigationBar = dir + "Navigation bar";
|
||||
const string copyPasteButtons = dir + "Copy \u2215 Paste components";
|
||||
const string saveInPlaymodeButton = dir + "Save in play mode";
|
||||
const string componentWindows = dir + "Component windows";
|
||||
const string componentAnimations = dir + "Component animations";
|
||||
const string minimalMode = dir + "Minimal mode";
|
||||
const string resettableVariables = dir + "Resettable variables";
|
||||
const string hideScriptField = dir + "Hide script field";
|
||||
const string hideHelpButton = dir + "Hide help button";
|
||||
const string hidePresetsButton = dir + "Hide presets button";
|
||||
|
||||
const string toggleActive = dir + "A to toggle component active";
|
||||
const string delete = dir + "X to delete component";
|
||||
const string toggleExpanded = dir + "E to expand \u2215 collapse component";
|
||||
const string collapseEverythingElse = dir + "Shift-E to expand only one component";
|
||||
const string collapseEverything = dir + "Ctrl-Shift-E to expand \u2215 collapse all components";
|
||||
|
||||
const string disableAttributes = dir + "Disable attributes";
|
||||
const string disablePlugin = dir + "Disable vInspector";
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
[MenuItem(dir + "Features", false, 1)] static void dadsas() { }
|
||||
[MenuItem(dir + "Features", true, 1)] static bool dadsas123() => false;
|
||||
|
||||
[MenuItem(navigationBar, false, 2)] static void dadsadsadasdsadadsas() { navigationBarEnabled = !navigationBarEnabled; RepaintInspectors(); }
|
||||
[MenuItem(navigationBar, true, 2)] static bool dadsaddsasadadsdasadsas() { Menu.SetChecked(navigationBar, navigationBarEnabled); return !pluginDisabled; }
|
||||
|
||||
[MenuItem(copyPasteButtons, false, 3)] static void dadsaasddsadaasdsdsadadsas() { copyPasteButtonsEnabled = !copyPasteButtonsEnabled; RepaintInspectors(); }
|
||||
[MenuItem(copyPasteButtons, true, 3)] static bool dadsaddasdsasaasddadsdasadsas() { Menu.SetChecked(copyPasteButtons, copyPasteButtonsEnabled); return !pluginDisabled; }
|
||||
|
||||
[MenuItem(saveInPlaymodeButton, false, 4)] static void dadsadsadaasasdsdsadadsas() { saveInPlaymodeButtonEnabled = !saveInPlaymodeButtonEnabled; RepaintInspectors(); }
|
||||
[MenuItem(saveInPlaymodeButton, true, 4)] static bool dadsaddsasaadsasddadsdasadsas() { Menu.SetChecked(saveInPlaymodeButton, saveInPlaymodeButtonEnabled); return !pluginDisabled; }
|
||||
|
||||
[MenuItem(componentWindows, false, 5)] static void dadsadsadaasdsdsadadsas() { componentWindowsEnabled = !componentWindowsEnabled; RepaintInspectors(); }
|
||||
[MenuItem(componentWindows, true, 5)] static bool dadsaddsasaasddadsdasadsas() { Menu.SetChecked(componentWindows, componentWindowsEnabled); return !pluginDisabled; }
|
||||
|
||||
[MenuItem(componentAnimations, false, 6)] static void dadsadsadsadaasdsdsadadsas() { componentAnimationsEnabled = !componentAnimationsEnabled; RepaintInspectors(); }
|
||||
[MenuItem(componentAnimations, true, 6)] static bool dadsadddsasasaasddadsdasadsas() { Menu.SetChecked(componentAnimations, componentAnimationsEnabled); return !pluginDisabled; }
|
||||
|
||||
[MenuItem(minimalMode, false, 7)] static void dadsadsadsadsadasdsadadsas() { minimalModeEnabled = !minimalModeEnabled; RepaintInspectors(); }
|
||||
[MenuItem(minimalMode, true, 7)] static bool dadsadasdasddsasadadsdasadsas() { Menu.SetChecked(minimalMode, minimalModeEnabled); return !pluginDisabled; }
|
||||
|
||||
[MenuItem(resettableVariables, false, 8)] static void dadsadsadsadasdsadadsas() { resettableVariablesEnabled = !resettableVariablesEnabled; RepaintInspectors(); }
|
||||
[MenuItem(resettableVariables, true, 8)] static bool dadsadasddsasadadsdasadsas() { Menu.SetChecked(resettableVariables, resettableVariablesEnabled); return !pluginDisabled; }
|
||||
|
||||
[MenuItem(hideScriptField, false, 9)] static void dadsadsdsaadsadsadasdsadadsas() { hideScriptFieldEnabled = !hideScriptFieldEnabled; RepaintInspectors(); }
|
||||
[MenuItem(hideScriptField, true, 9)] static bool dadsadasadsdasddsasadadsdasadsas() { Menu.SetChecked(hideScriptField, hideScriptFieldEnabled); return !pluginDisabled; }
|
||||
|
||||
[MenuItem(hideHelpButton, false, 10)] static void dadsadsadsdsaadsadsadasdsadadsas() { hideHelpButtonEnabled = !hideHelpButtonEnabled; RepaintInspectors(); }
|
||||
[MenuItem(hideHelpButton, true, 10)] static bool dadsaadsdasadsdasddsasadadsdasadsas() { Menu.SetChecked(hideHelpButton, hideHelpButtonEnabled); return !pluginDisabled; }
|
||||
|
||||
[MenuItem(hidePresetsButton, false, 11)] static void dadsadsdsaadssdadsadasdsadadsas() { hidePresetsButtonEnabled = !hidePresetsButtonEnabled; RepaintInspectors(); }
|
||||
[MenuItem(hidePresetsButton, true, 11)] static bool dadsadasadsddsasddsasadadsdasadsas() { Menu.SetChecked(hidePresetsButton, hidePresetsButtonEnabled); return !pluginDisabled; }
|
||||
|
||||
|
||||
|
||||
|
||||
[MenuItem(dir + "Shortcuts", false, 1001)] static void dadsadsas() { }
|
||||
[MenuItem(dir + "Shortcuts", true, 1001)] static bool dadsadsas123() => false;
|
||||
|
||||
[MenuItem(toggleActive, false, 1002)] static void dadsadadsas() => toggleActiveEnabled = !toggleActiveEnabled;
|
||||
[MenuItem(toggleActive, true, 1002)] static bool dadsaddasadsas() { Menu.SetChecked(toggleActive, toggleActiveEnabled); return !pluginDisabled; }
|
||||
|
||||
[MenuItem(delete, false, 1003)] static void dadsadsadasdadsas() => deleteEnabled = !deleteEnabled;
|
||||
[MenuItem(delete, true, 1003)] static bool dadsaddsasaddasadsas() { Menu.SetChecked(delete, deleteEnabled); return !pluginDisabled; }
|
||||
|
||||
[MenuItem(toggleExpanded, false, 1004)] static void dadsaddsasadasdsadadsas() => toggleExpandedEnabled = !toggleExpandedEnabled;
|
||||
[MenuItem(toggleExpanded, true, 1004)] static bool dadsaddsdsasadadsdasadsas() { Menu.SetChecked(toggleExpanded, toggleExpandedEnabled); return !pluginDisabled; }
|
||||
|
||||
[MenuItem(collapseEverythingElse, false, 1005)] static void dadsadsasdadasdsadadsas() => collapseEverythingElseEnabled = !collapseEverythingElseEnabled;
|
||||
[MenuItem(collapseEverythingElse, true, 1005)] static bool dadsaddsdasasadadsdasadsas() { Menu.SetChecked(collapseEverythingElse, collapseEverythingElseEnabled); return !pluginDisabled; }
|
||||
|
||||
[MenuItem(collapseEverything, false, 1006)] static void dadsadsdasadasdsadadsas() => collapseEverythingEnabled = !collapseEverythingEnabled;
|
||||
[MenuItem(collapseEverything, true, 1006)] static bool dadsaddssdaasadadsdasadsas() { Menu.SetChecked(collapseEverything, collapseEverythingEnabled); return !pluginDisabled; }
|
||||
|
||||
|
||||
|
||||
|
||||
[MenuItem(dir + "More", false, 10001)] static void daasadsddsas() { }
|
||||
[MenuItem(dir + "More", true, 10001)] static bool dadsadsdasas123() => false;
|
||||
|
||||
[MenuItem(dir + "Open manual", false, 10002)]
|
||||
static void dadadssadsas() => Application.OpenURL("https://kubacho-lab.gitbook.io/vinspector2");
|
||||
|
||||
[MenuItem(dir + "Join our Discord", false, 10003)]
|
||||
static void dadasdsas() => Application.OpenURL("https://discord.gg/pUektnZeJT");
|
||||
|
||||
|
||||
|
||||
|
||||
// [MenuItem(dir + "Clear state", false, 5555)] static void dassaadsasddc() { VInspectorState.Clear(); VInspector.firstAttrStateCacheLayer.Clear(); RepaintInspectors(); }
|
||||
// [MenuItem(dir + "Clear state", true, 5555)] static bool dassaadsadsasddc() { return !pluginDisabled; }
|
||||
|
||||
// [MenuItem(dir + "Save state", false, 5556)] static void dassaaasddsasddc() { VInspectorState.Save(); }
|
||||
// [MenuItem(dir + "Save state", true, 5556)] static bool dassaadsaasddsasddc() { return !pluginDisabled; }
|
||||
|
||||
// [MenuItem(disableAttributes, false, 5557)] static void dadsadsdasadasdasdsadadsas() { attributesDisabled = !attributesDisabled; }
|
||||
// [MenuItem(disableAttributes, true, 5557)] static bool dadsaddssdaasadsadadsdasadsas() { Menu.SetChecked(disableAttributes, attributesDisabled); return !pluginDisabled; }
|
||||
|
||||
|
||||
|
||||
|
||||
[MenuItem(disablePlugin, false, 100001)] static void dadsadsdsdasadasdasdsadadsas() { pluginDisabled = !pluginDisabled; if (!pluginDisabled) EditorPrefs.SetBool("vInspector-pluginWasReenabled", true); attributesDisabled = pluginDisabled; }
|
||||
[MenuItem(disablePlugin, true, 100001)] static bool dadsaddssdsdaasadsadadsdasadsas() { Menu.SetChecked(disablePlugin, pluginDisabled); return true; }
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 07852b6b534474f7fb57529201e123e0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f27f798b17a724efc8b05c54e23eff97
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,173 +0,0 @@
|
||||
#if UNITY_EDITOR
|
||||
using System.Collections;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.RegularExpressions;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using UnityEditor.UIElements;
|
||||
using System.Reflection;
|
||||
using UnityEditor;
|
||||
using Type = System.Type;
|
||||
using static VInspector.VInspectorState;
|
||||
using static VInspector.Libs.VUtils;
|
||||
using static VInspector.Libs.VGUI;
|
||||
|
||||
|
||||
|
||||
namespace VInspector
|
||||
{
|
||||
static class VInspectorResettableVariables
|
||||
{
|
||||
|
||||
public static void ResetButtonGUI(Rect fieldRect, SerializedProperty property, FieldInfo fieldInfo, IEnumerable<object> targets)
|
||||
{
|
||||
// if (!fieldRect.IsHovered()) return;
|
||||
|
||||
|
||||
object targetWithDefaultValues = GetTargetWithDefaulValues(targets.First().GetType());
|
||||
|
||||
bool isResetted(object target)
|
||||
{
|
||||
if (property.isInstantiatedPrefab) return !property.prefabOverride;
|
||||
|
||||
if (targetWithDefaultValues as object == null) return true;
|
||||
|
||||
|
||||
var currentValue = fieldInfo.GetValue(target);
|
||||
var defaultValue = fieldInfo.GetValue(targetWithDefaultValues);
|
||||
|
||||
var isResetted = object.Equals(currentValue, defaultValue);
|
||||
|
||||
|
||||
if (typeof(Object).IsAssignableFrom(fieldInfo.FieldType))
|
||||
isResetted |= (defaultValue == null) && !(bool)(Object)currentValue;
|
||||
|
||||
if (fieldInfo.FieldType == typeof(string))
|
||||
isResetted |= fieldInfo.FieldType == typeof(string) && (object.Equals(currentValue, "") && object.Equals(defaultValue, null));
|
||||
|
||||
|
||||
return isResetted;
|
||||
|
||||
}
|
||||
|
||||
if (targets.All(r => isResetted(r))) return;
|
||||
|
||||
|
||||
|
||||
var iconSize = 12;
|
||||
var colorNormal = Greyscale(.41f);
|
||||
var colorHovered = Greyscale(isDarkTheme ? .9f : .0f);
|
||||
var colorPressed = Greyscale(isDarkTheme ? .65f : .6f);
|
||||
|
||||
var buttonRect = fieldRect.SetWidthFromRight(20).MoveX(typeof(Object).IsAssignableFrom(fieldInfo.FieldType) ? -18 : 1);
|
||||
|
||||
EditorGUIUtility.AddCursorRect(buttonRect, MouseCursor.CustomCursor);
|
||||
|
||||
|
||||
|
||||
if (!IconButton(buttonRect, "CrossIcon", iconSize, colorNormal, colorHovered, colorPressed)) return;
|
||||
|
||||
if (property.isInstantiatedPrefab)
|
||||
{
|
||||
foreach (var target in property.serializedObject.targetObjects)
|
||||
target.RecordUndo();
|
||||
|
||||
PrefabUtility.RevertPropertyOverride(property, InteractionMode.AutomatedAction);
|
||||
|
||||
}
|
||||
else
|
||||
property.SetBoxedValue(fieldInfo.GetValue(targetWithDefaultValues));
|
||||
|
||||
GUI.changed = true;
|
||||
|
||||
GUI.FocusControl(null);
|
||||
|
||||
}
|
||||
|
||||
|
||||
static object GetTargetWithDefaulValues(Type targetType)
|
||||
{
|
||||
if (targetWithDefaulValues_byType.TryGetValue(targetType, out var cachedResult)) return cachedResult;
|
||||
|
||||
object targetWithDefaultValues = null;
|
||||
|
||||
void script_2023plus()
|
||||
{
|
||||
#if UNITY_2023_2_OR_NEWER
|
||||
|
||||
if (!typeof(MonoBehaviour).IsAssignableFrom(targetType)) return;
|
||||
|
||||
if (Application.isPlaying || TypeCache.GetTypesWithAttribute<ExecuteInEditMode>().Contains(targetType) || TypeCache.GetTypesWithAttribute<ExecuteAlways>().Contains(targetType))
|
||||
if ((targetType.GetMethodInfo("Awake") ?? targetType.GetMethodInfo("OnEnable") ?? targetType.GetMethodInfo("OnDisable") ?? targetType.GetMethodInfo("OnDestroy")) != null) return; // to avoid executing user code
|
||||
|
||||
|
||||
var tempGo = EditorUtility.CreateGameObjectWithHideFlags("Dummy object for fetching default variable values for vInspector's resettable variables feature", HideFlags.HideAndDontSave, targetType);
|
||||
|
||||
try { targetWithDefaultValues = tempGo.GetComponent(targetType); }
|
||||
|
||||
finally { Object.DestroyImmediate(tempGo); }
|
||||
|
||||
#endif
|
||||
}
|
||||
void script_olderVersions()
|
||||
{
|
||||
#if !UNITY_2023_2_OR_NEWER
|
||||
|
||||
if (!typeof(MonoBehaviour).IsAssignableFrom(targetType)) return;
|
||||
|
||||
targetWithDefaultValues = ScriptableObject.CreateInstance(targetType);
|
||||
|
||||
#endif
|
||||
}
|
||||
void scriptableObject()
|
||||
{
|
||||
if (!typeof(ScriptableObject).IsAssignableFrom(targetType)) return;
|
||||
|
||||
targetWithDefaultValues = ScriptableObject.CreateInstance(targetType);
|
||||
|
||||
}
|
||||
void customClass()
|
||||
{
|
||||
if (typeof(MonoBehaviour).IsAssignableFrom(targetType)) return;
|
||||
if (typeof(ScriptableObject).IsAssignableFrom(targetType)) return;
|
||||
if (targetType.GetConstructor(System.Type.EmptyTypes) == null) return;
|
||||
|
||||
targetWithDefaultValues = System.Activator.CreateInstance(targetType);
|
||||
|
||||
}
|
||||
|
||||
script_2023plus();
|
||||
script_olderVersions();
|
||||
scriptableObject();
|
||||
customClass();
|
||||
|
||||
return targetWithDefaulValues_byType[targetType] = targetWithDefaultValues;
|
||||
|
||||
}
|
||||
|
||||
static Dictionary<Type, object> targetWithDefaulValues_byType = new();
|
||||
|
||||
|
||||
|
||||
|
||||
public static bool IsResettable(FieldInfo fieldInfo)
|
||||
{
|
||||
if (!VInspectorMenu.resettableVariablesEnabled) return false;
|
||||
if (Application.isPlaying) return false;
|
||||
|
||||
if (System.Attribute.IsDefined(fieldInfo, typeof(VariantsAttribute))) return false;
|
||||
|
||||
if (typeof(Object).IsAssignableFrom(fieldInfo.FieldType)) return true;
|
||||
if (fieldInfo.FieldType == typeof(int)) return true;
|
||||
if (fieldInfo.FieldType == typeof(float)) return true;
|
||||
if (fieldInfo.FieldType == typeof(double)) return true;
|
||||
if (fieldInfo.FieldType == typeof(string)) return true;
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4efb7d95707f0459ba76cac7fa149875
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,125 +0,0 @@
|
||||
#if UNITY_EDITOR
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEditor.ShortcutManagement;
|
||||
using System.Reflection;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using Type = System.Type;
|
||||
using static VInspector.Libs.VUtils;
|
||||
using static VInspector.Libs.VGUI;
|
||||
|
||||
|
||||
|
||||
namespace VInspector
|
||||
{
|
||||
public class VInspectorSelectionHistory : ScriptableSingleton<VInspectorSelectionHistory>
|
||||
{
|
||||
public void MoveBack()
|
||||
{
|
||||
var prevState = prevStates.Last();
|
||||
|
||||
instance.RecordUndo("VInspectorSelectionHistory.MoveBack");
|
||||
|
||||
prevStates.Remove(prevState);
|
||||
nextStates.Add(curState);
|
||||
curState = prevState;
|
||||
|
||||
|
||||
ignoreThisSelectionChange = true;
|
||||
|
||||
prevState.selectedObjects.ToArray().SelectInInspector(frameInHierarchy: false, frameInProject: false);
|
||||
|
||||
}
|
||||
public void MoveForward()
|
||||
{
|
||||
var nextState = nextStates.Last();
|
||||
|
||||
instance.RecordUndo("VInspectorSelectionHistory.MoveForward");
|
||||
|
||||
nextStates.Remove(nextState);
|
||||
prevStates.Add(curState);
|
||||
curState = nextState;
|
||||
|
||||
|
||||
ignoreThisSelectionChange = true;
|
||||
|
||||
nextState.selectedObjects.ToArray().SelectInInspector(frameInHierarchy: false, frameInProject: false);
|
||||
|
||||
}
|
||||
|
||||
static void OnSelectionChange()
|
||||
{
|
||||
if (ignoreThisSelectionChange) { ignoreThisSelectionChange = false; return; }
|
||||
|
||||
if (curEvent.modifiers == EventModifiers.Command && curEvent.keyCode == KeyCode.Z) return;
|
||||
if (curEvent.modifiers == (EventModifiers.Command | EventModifiers.Shift) && curEvent.keyCode == KeyCode.Z) return;
|
||||
|
||||
if (curEvent.modifiers == EventModifiers.Control && curEvent.keyCode == KeyCode.Z) return;
|
||||
if (curEvent.modifiers == EventModifiers.Control && curEvent.keyCode == KeyCode.Y) return;
|
||||
|
||||
|
||||
instance.RecordUndo(Undo.GetCurrentGroupName());
|
||||
|
||||
instance.prevStates.Add(instance.curState);
|
||||
instance.curState = new SelectionState() { selectedObjects = Selection.objects.ToList() };
|
||||
instance.nextStates.Clear();
|
||||
|
||||
if (instance.prevStates.Count > 50)
|
||||
instance.prevStates.RemoveAt(0);
|
||||
|
||||
}
|
||||
|
||||
static bool ignoreThisSelectionChange;
|
||||
|
||||
|
||||
public List<SelectionState> prevStates = new();
|
||||
public List<SelectionState> nextStates = new();
|
||||
public SelectionState curState;
|
||||
|
||||
[System.Serializable]
|
||||
public class SelectionState { public List<Object> selectedObjects = new(); }
|
||||
|
||||
|
||||
|
||||
[InitializeOnLoadMethod]
|
||||
static void Init()
|
||||
{
|
||||
Selection.selectionChanged -= OnSelectionChange;
|
||||
Selection.selectionChanged += OnSelectionChange;
|
||||
|
||||
|
||||
// var globalEventHandler = typeof(EditorApplication).GetFieldValue<EditorApplication.CallbackFunction>("globalEventHandler");
|
||||
// typeof(EditorApplication).SetFieldValue("globalEventHandler", ClearHistories + (globalEventHandler - ClearHistories));
|
||||
|
||||
|
||||
instance.curState = new SelectionState() { selectedObjects = Selection.objects.ToList() };
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// static void ClearHistories() // just for debug
|
||||
// {
|
||||
// if (curEvent.holdingAnyModifierKey) return;
|
||||
// if (!curEvent.isKeyDown || curEvent.keyCode != KeyCode.Y) return;
|
||||
|
||||
// VInspectorSelectionHistory.instance.prevStates.Clear();
|
||||
// VInspectorSelectionHistory.instance.nextStates.Clear();
|
||||
|
||||
// Undo.ClearAll();
|
||||
|
||||
// VInspectorMenu.RepaintInspectors();
|
||||
|
||||
// }
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 76c5ee368a46a4167b845f6db32ad060
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,64 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
|
||||
namespace VInspector
|
||||
{
|
||||
[System.Serializable]
|
||||
public class SerializedDictionary<TKey, TValue> : Dictionary<TKey, TValue>, ISerializationCallbackReceiver
|
||||
{
|
||||
public List<SerializedKeyValuePair<TKey, TValue>> serializedKvps = new();
|
||||
|
||||
public float dividerPos = .33f;
|
||||
|
||||
public void OnBeforeSerialize()
|
||||
{
|
||||
foreach (var kvp in this)
|
||||
if (serializedKvps.FirstOrDefault(r => this.Comparer.Equals(r.Key, kvp.Key)) is SerializedKeyValuePair<TKey, TValue> serializedKvp)
|
||||
serializedKvp.Value = kvp.Value;
|
||||
else
|
||||
serializedKvps.Add(kvp);
|
||||
|
||||
serializedKvps.RemoveAll(r => !this.ContainsKey(r.Key));
|
||||
|
||||
for (int i = 0; i < serializedKvps.Count; i++)
|
||||
serializedKvps[i].index = i;
|
||||
|
||||
}
|
||||
public void OnAfterDeserialize()
|
||||
{
|
||||
this.Clear();
|
||||
|
||||
serializedKvps.RemoveAll(r => r.Key is null);
|
||||
|
||||
foreach (var serializedKvp in serializedKvps)
|
||||
if (!(serializedKvp.isKeyRepeated = this.ContainsKey(serializedKvp.Key)))
|
||||
this.Add(serializedKvp.Key, serializedKvp.Value);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
[System.Serializable]
|
||||
public class SerializedKeyValuePair<TKey_, TValue_>
|
||||
{
|
||||
public TKey_ Key;
|
||||
public TValue_ Value;
|
||||
|
||||
public int index;
|
||||
public bool isKeyRepeated;
|
||||
|
||||
|
||||
public SerializedKeyValuePair(TKey_ key, TValue_ value) { this.Key = key; this.Value = value; }
|
||||
|
||||
public static implicit operator SerializedKeyValuePair<TKey_, TValue_>(KeyValuePair<TKey_, TValue_> kvp) => new(kvp.Key, kvp.Value);
|
||||
public static implicit operator KeyValuePair<TKey_, TValue_>(SerializedKeyValuePair<TKey_, TValue_> kvp) => new(kvp.Key, kvp.Value);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 00ee9a38e8fee47c29efb5789be8458c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,66 +0,0 @@
|
||||
#if UNITY_EDITOR
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
using UnityEditor;
|
||||
using UnityEditor.ShortcutManagement;
|
||||
using System.Reflection;
|
||||
using System.Linq;
|
||||
using UnityEngine.UIElements;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEditor.SceneManagement;
|
||||
using Type = System.Type;
|
||||
using static VInspector.Libs.VUtils;
|
||||
using static VInspector.Libs.VGUI;
|
||||
|
||||
|
||||
|
||||
namespace VInspector
|
||||
{
|
||||
[FilePath("Library/vInspector State.asset", FilePathAttribute.Location.ProjectFolder)]
|
||||
public class VInspectorState : ScriptableSingleton<VInspectorState>
|
||||
{
|
||||
|
||||
public SerializableDictionary<string, AttributesState> attributeStates_byScriptName = new();
|
||||
|
||||
[System.Serializable]
|
||||
public class AttributesState
|
||||
{
|
||||
public SerializableDictionary<string, int> selectedSubtabIndexes_byTabPath = new();
|
||||
public SerializableDictionary<string, bool> isExpandeds_byFoldoutPath = new();
|
||||
public SerializableDictionary<string, bool> isExpandeds_byButtonPath = new();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public SerializableDictionary<int, ItemState> itemStates_byItemId = new();
|
||||
|
||||
[System.Serializable]
|
||||
public class ItemState
|
||||
{
|
||||
public string _name;
|
||||
public string sceneGameObjectIconName;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static void Clear()
|
||||
{
|
||||
instance.attributeStates_byScriptName.Clear();
|
||||
instance.itemStates_byItemId.Clear();
|
||||
|
||||
}
|
||||
|
||||
public static void Save() => instance.Save(true);
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6fcb471c750b741839863cd8a7ce5785
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,15 +0,0 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: b7915df4cd4da490ab52fc8fa9ee9127, type: 3}
|
||||
m_Name: vInspector Data
|
||||
m_EditorClassIdentifier:
|
||||
items: []
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ddfa531a68919e242bbdf2705511235c
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f6e39c216db447344a65a23de981d9ca
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
@@ -1,7 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 01fbcccbc9a1a44c2bf42479f17dfb69
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user