三国卡牌客户端基础资源仓库
lcy
2025-05-23 6b9f77dbc9fb802d36f4af8270f38128e8c460aa
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
using UnityEngine;
using UnityEditor;
using System;
using System.Collections.Generic;
using qtools.qhierarchy.pdata;
using qtools.qhierarchy.phierarchy;
using UnityEditor.Callbacks;
using qtools.qhierarchy.phelper;
 
namespace qtools.qhierarchy
{
    [InitializeOnLoad]
    public class QHierarchyInitializer
    {
        private static QHierarchy hierarchy;
 
        static QHierarchyInitializer()
        {
            EditorApplication.update -= update;
            EditorApplication.update += update;
 
            EditorApplication.hierarchyWindowItemOnGUI -= hierarchyWindowItemOnGUIHandler;
            EditorApplication.hierarchyWindowItemOnGUI += hierarchyWindowItemOnGUIHandler;
            
            EditorApplication.hierarchyChanged -= hierarchyWindowChanged;
            EditorApplication.hierarchyChanged += hierarchyWindowChanged;
 
            Undo.undoRedoPerformed -= undoRedoPerformed;
            Undo.undoRedoPerformed += undoRedoPerformed;
        }
 
        static void undoRedoPerformed()
        {
            EditorApplication.RepaintHierarchyWindow();          
        }
 
        static void init()
        {       
            hierarchy = new QHierarchy();
        } 
 
        static void update()
        {
            if (hierarchy == null) init();
            QObjectListManager.getInstance().update();
        }
 
        static void hierarchyWindowItemOnGUIHandler(int instanceId, Rect selectionRect)
        {
            if (hierarchy == null) init();
             hierarchy.hierarchyWindowItemOnGUIHandler(instanceId, selectionRect);
        }
 
        static void hierarchyWindowChanged()
        {
            if (hierarchy == null) init();
            QObjectListManager.getInstance().validate();
        }
    }
}