Question by
moyadupwork · Sep 05, 2020 at 09:30 PM ·
c#programmingassemblyreflectionssolution
Get the scroll position of hierarchy window
I am looking for a way to get hierarchy properties and get value scollPos.
I found this method but treeView not available.
Assembly asm = typeof(UnityEditor.EditorWindow).Assembly;
Type wndType = asm.GetType("UnityEditor.SceneHierarchyWindow");
EditorWindow wnd = EditorWindow.GetWindow(wndType, false, "Hierarchy", false);
if (wndType == null)
return Vector2.zero;
var treeViewVal = wndType.GetProperties(BindingFlags.NonPublic | BindingFlags.Instance );
string result = "List:";
foreach (PropertyInfo info in treeViewVal)
{
result += "\n" + info.ToString();
}
Debug.Log(result);
var stateVal = treeViewVal.GetType().GetProperty("state").GetValue(treeViewVal, null);
return (Vector2)stateVal.GetType().GetField("scrollPos").GetValue(stateVal);
Tha outpot of Debug
List:
Boolean showingStageHeader
UnityEngine.Rect stageHeaderRect
UnityEngine.Rect treeViewRect Boolean
hasSearchFilter Boolean
hasSearchFilterFocus SearchMode
searchMode System.Object
uiRootElement System.Action
uiRootElementCreated
UnityEditor.UIElements.SerializableJsonDictionary
viewDataDictionary Boolean
disableInputEvents Int32 antiAliasing
Comment