-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockGUIStyles.cs
117 lines (96 loc) · 4.12 KB
/
DockGUIStyles.cs
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Text.RegularExpressions;
using DockGUI;
using UnityEngine;
using UnityEngine.UIElements;
using UnityEditor;
[InitializeOnLoad]
public static class DockGUIStyles
{
public static StyleSheet DefaultStyle;
public const float DEFAULT_LAYOUT_SIZE = 250f;
public const LengthUnit DEFAULT_LAYOUT_SIZE_UNIT = LengthUnit.Pixel;
public static StyleLength DefaultStyleLength;
public static IStyle FlexLayoutStyle;
private const string _defaultStyleFilename = "DefaultStyle2.uss";
static DockGUIStyles()
{
Refresh();
}
public static string[] DockingStyleNames()
{
return new string[]{"DockLayoutTop", "DockLayoutBottom", "DockLayoutLeft", "DockLayoutRight"};
}
public static string[] DockingGhostStyleNames()
{
return new string[]{DockingGhostTop, DockingGhostBottom, DockingGhostLeft, DockingGhostRight};
}
public static string DockingGhostTop => "DockingGhostTop";
public static string DockingGhostBottom => "DockingGhostBottom";
public static string DockingGhostRight => "DockingGhostRight";
public static string DockingGhostLeft => "DockingGhostLeft";
public static void Refresh()
{
Debug.Log("Refreshing...");
var files = Directory.GetFiles(Application.dataPath, _defaultStyleFilename, SearchOption.AllDirectories);
if (files == null)
{
throw new Exception("Could not find default style...");
}
var folderGuid = AssetDatabase.FindAssets("DockGUI,t:folder");
var folderPath = AssetDatabase.GUIDToAssetPath(folderGuid[0]);
var defaultStyleGuid = AssetDatabase.FindAssets("DefaultStyle,t:StyleSheet", new string[]{folderPath + "/Styles"});
var defaultStylePath = AssetDatabase.GUIDToAssetPath(defaultStyleGuid[0]);
DefaultStyle = AssetDatabase.LoadAssetAtPath<StyleSheet>(defaultStylePath);
DefaultStyleLength = new StyleLength(new Length(DEFAULT_LAYOUT_SIZE, DEFAULT_LAYOUT_SIZE_UNIT));
}
public static void FlexLayout(ref VisualElement element, FlexDirection direction)
{
element.style.flexGrow = 1;
element.style.backgroundColor = new StyleColor(Color.blue);
element.style.flexDirection = direction;
}
public static void DockLayoutLeft(ref DockLayout element)
{
element.style.flexDirection = new StyleEnum<FlexDirection>(FlexDirection.Column);
element.style.flexGrow = 0;
element.style.backgroundColor = new StyleColor(Color.red);
element.style.paddingLeft = 3;
element.style.paddingRight = 3;
element.style.paddingTop = 3;
element.style.paddingBottom = 3;
}
public static void DockLayoutTop(ref DockLayout element)
{
element.style.flexDirection = new StyleEnum<FlexDirection>(FlexDirection.Row);
element.style.flexGrow = 0;
element.style.backgroundColor = new StyleColor(Color.white);
element.style.paddingLeft = 3;
element.style.paddingRight = 3;
element.style.paddingTop = 3;
element.style.paddingBottom = 3;
}
public static void DockLayoutBottom(ref DockLayout element)
{
element.style.flexDirection = new StyleEnum<FlexDirection>(FlexDirection.Column);
element.style.flexGrow = 0;
element.style.backgroundColor = new StyleColor(Color.green);
element.style.paddingLeft = 3;
element.style.paddingRight = 3;
element.style.paddingTop = 3;
element.style.paddingBottom = 3;
}
public static void DockLayoutRight(ref DockLayout element)
{
element.style.flexDirection = new StyleEnum<FlexDirection>(FlexDirection.Column);
element.style.flexGrow = 0;
element.style.backgroundColor = new StyleColor(Color.red);
element.style.paddingLeft = 3;
element.style.paddingRight = 3;
element.style.paddingTop = 3;
element.style.paddingBottom = 3;
}
}