少年修仙传客户端基础资源
dabaoji
2023-11-13 0a23e1b83f8fda8ab9f9e32fe71c26c431faf63a
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
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using qtools.qhierarchy.pcomponent.pbase;
using qtools.qhierarchy.pdata;
using qtools.qhierarchy.phelper;
 
namespace qtools.qhierarchy.pcomponent
{
    public class QSeparatorComponent: QBaseComponent
    {
        // PRIVATE
        private Color separatorColor;
        private Color shadingColor;
        private bool showRowShading;
 
        // CONSTRUCTOR
        public QSeparatorComponent ()
        {
            separatorColor = new Color(0f, 0f, 0f, 0.15f);
            shadingColor = new Color(0f, 0f, 0f, 0.05f);
 
            showComponentDuringPlayMode = true;
 
            QSettings.getInstance().addEventListener(QSetting.ShowRowShading, settingsChanged);
            QSettings.getInstance().addEventListener(QSetting.ShowSeparatorComponent, settingsChanged);
            settingsChanged();
        }
        
        // PRIVATE
        private void settingsChanged()
        {
            showRowShading = QSettings.getInstance().get<bool>(QSetting.ShowRowShading);
            enabled = QSettings.getInstance().get<bool>(QSetting.ShowSeparatorComponent);
        }
 
        // DRAW
        public override void draw(GameObject gameObject, QObjectList objectList, Rect selectionRect, Rect curRect)
        {
            curRect.y = selectionRect.y + selectionRect.height - 1;
            curRect.width = selectionRect.width + selectionRect.x;
            curRect.height = 1;
            curRect.x = 0;
 
            EditorGUI.DrawRect(curRect, separatorColor);
 
            if (showRowShading && (Mathf.FloorToInt(((selectionRect.y - 4) / 16) % 2) == 0))
            {
                selectionRect.width += selectionRect.x;
                selectionRect.x = 0;
                selectionRect.height -=1;
                EditorGUI.DrawRect(selectionRect, shadingColor);
            }
        }
    }
}