aboutsummaryrefslogtreecommitdiff
path: root/Assets/Cinemachine/Base/Editor/Windows/CinemachineColliderPrefs.cs
blob: 4cc881a0eca405de67353508e49df086d60415e2 (plain) (blame)
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
using UnityEngine;
using UnityEditor;

using Cinemachine.Editor;

namespace Cinemachine
{
    [InitializeOnLoad]
    internal static class CinemachineColliderPrefs
    {
        private static bool SettingsFoldedOut
        {
            get { return EditorPrefs.GetBool(kColliderSettingsFoldoutKey, false); }
            set
            {
                if (value != SettingsFoldedOut)
                {
                    EditorPrefs.SetBool(kColliderSettingsFoldoutKey, value);
                }
            }
        }

        public static Color FeelerHitColor
        {
            get
            {
                return CinemachineSettings.UnpackColour(EditorPrefs.GetString(kFeelerHitColourKey, CinemachineSettings.PackColor(Color.yellow)));
            }

            set
            {
                if (value != FeelerHitColor)
                {
                    EditorPrefs.SetString(kFeelerHitColourKey, CinemachineSettings.PackColor(value));
                }
            }
        }

        public static Color FeelerColor
        {
            get
            {
                return CinemachineSettings.UnpackColour(EditorPrefs.GetString(kFeelerColourKey, CinemachineSettings.PackColor(Color.gray)));
            }

            set
            {
                if (value != FeelerColor)
                {
                    EditorPrefs.SetString(kFeelerColourKey, CinemachineSettings.PackColor(value));
                }
            }
        }

        private const string kColliderSettingsFoldoutKey  = "CNMCN_Collider_Foldout";
        private const string kFeelerHitColourKey          = "CNMCN_Collider_FeelerHit_Colour";
        private const string kFeelerColourKey             = "CNMCN_Collider_Feeler_Colour";

        static CinemachineColliderPrefs()
        {
            Cinemachine.Editor.CinemachineSettings.AdditionalCategories += DrawColliderSettings;
        }

        private static void DrawColliderSettings()
        {
            SettingsFoldedOut = EditorGUILayout.Foldout(SettingsFoldedOut, "Collider Settings");
            if (SettingsFoldedOut)
            {
                EditorGUI.indentLevel++;

                EditorGUI.BeginChangeCheck();

                FeelerHitColor   = EditorGUILayout.ColorField("Feeler Hit", FeelerHitColor);
                FeelerColor = EditorGUILayout.ColorField("Feeler", FeelerColor);

                if (EditorGUI.EndChangeCheck())
                {
                    UnityEditorInternal.InternalEditorUtility.RepaintAllViews();
                }

                EditorGUI.indentLevel--;
            }
        }
    }
}