summaryrefslogtreecommitdiff
path: root/Assets/ActionTool/Editor/ActionEditorUI.cs
blob: f04c10ead2559189aa63bb803909e81dbad307dc (plain)
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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;

namespace ActionTool
{
    internal class ActionEditorUI
    {
        static ActionEditorUI s_instance;

        static Material m_material;

        public Material defaultUIMaterail { get { return m_material; } }

        public static ActionEditorUI Get()
        {
            bool flag = s_instance == null;
            if (flag)
            {
                s_instance = new ActionEditorUI();
            }
            return s_instance;
        }

        private ActionEditorUI()
        {
            m_material = new Material(Shader.Find("Hidden/Internal-Colored"));
            m_material.hideFlags = HideFlags.HideAndDontSave;
        }

        public void DrawVerticalLineFast(float x, float minY, float maxY, Color color)
        {
            bool bWin = Application.platform == RuntimePlatform.WindowsEditor;
            if (bWin)
            {
                GL.Color(color);
                GL.Vertex(new Vector3(x - 0.5f, minY, 0f));
                GL.Vertex(new Vector3(x + 0.5f, minY, 0f));
                GL.Vertex(new Vector3(x + 0.5f, maxY, 0f));
                GL.Vertex(new Vector3(x - 0.5f, maxY, 0f));
            }
            else
            {
                GL.Color(color);
                GL.Vertex(new Vector3(x, minY, 0f));
                GL.Vertex(new Vector3(x, maxY, 0f));
            }
        }

        public void DrawHorizontalLineFast(float y, float minX, float maxX, Color color)
        {
            bool bWin = Application.platform == RuntimePlatform.WindowsEditor;
            if (bWin)
            {
                GL.Color(color);
                GL.Vertex(new Vector3(minX, y - 0.5f, 0f));
                GL.Vertex(new Vector3(minX, y + 0.5f, 0f));
                GL.Vertex(new Vector3(maxX, y + 0.5f, 0f));
                GL.Vertex(new Vector3(maxX, y - 0.5f, 0f));
            }
            else
            {
                GL.Color(color);
                GL.Vertex(new Vector3(minX, y, 0f));
                GL.Vertex(new Vector3(maxX, y, 0f));
            }
        }

        public void SelectObject(Object obj)
        {
            Selection.activeObject = obj;
            EditorGUIUtility.PingObject(obj);
        }

        public void SelectObject(string path)
        {
            Object obj = AssetDatabase.LoadAssetAtPath(path, typeof(Object)) as Object;
            if(obj)
            {
                SelectObject(obj);
            }
        }

    }
}