aboutsummaryrefslogtreecommitdiff
path: root/Assets/Cinemachine/Base/Editor/PropertyDrawers
diff options
context:
space:
mode:
authorTom Harley2018-09-03 23:34:21 +0100
committerTom Harley2018-09-03 23:36:01 +0100
commit5440734d820606b29a795c46172ade5d7eba8efb (patch)
tree85867f40afb02cfa2a5028b515ed0a195866b7e9 /Assets/Cinemachine/Base/Editor/PropertyDrawers
downloadpowerless-5440734d820606b29a795c46172ade5d7eba8efb.tar.gz
powerless-5440734d820606b29a795c46172ade5d7eba8efb.zip

Initial commit

Diffstat (limited to 'Assets/Cinemachine/Base/Editor/PropertyDrawers')
-rw-r--r--Assets/Cinemachine/Base/Editor/PropertyDrawers/CinemachineBlendDefinitionPropertyDrawer.cs38
-rw-r--r--Assets/Cinemachine/Base/Editor/PropertyDrawers/CinemachineBlendDefinitionPropertyDrawer.cs.meta12
-rw-r--r--Assets/Cinemachine/Base/Editor/PropertyDrawers/CinemachineTagFieldPropertyDrawer.cs28
-rw-r--r--Assets/Cinemachine/Base/Editor/PropertyDrawers/CinemachineTagFieldPropertyDrawer.cs.meta12
-rw-r--r--Assets/Cinemachine/Base/Editor/PropertyDrawers/GetSetDrawer.cs1
-rw-r--r--Assets/Cinemachine/Base/Editor/PropertyDrawers/GetSetDrawer.cs.meta12
-rw-r--r--Assets/Cinemachine/Base/Editor/PropertyDrawers/LensSettingsPropertyDrawer.cs61
-rw-r--r--Assets/Cinemachine/Base/Editor/PropertyDrawers/LensSettingsPropertyDrawer.cs.meta12
-rw-r--r--Assets/Cinemachine/Base/Editor/PropertyDrawers/MinDrawer.cs1
-rw-r--r--Assets/Cinemachine/Base/Editor/PropertyDrawers/MinDrawer.cs.meta12
10 files changed, 189 insertions, 0 deletions
diff --git a/Assets/Cinemachine/Base/Editor/PropertyDrawers/CinemachineBlendDefinitionPropertyDrawer.cs b/Assets/Cinemachine/Base/Editor/PropertyDrawers/CinemachineBlendDefinitionPropertyDrawer.cs
new file mode 100644
index 0000000..17ac49d
--- /dev/null
+++ b/Assets/Cinemachine/Base/Editor/PropertyDrawers/CinemachineBlendDefinitionPropertyDrawer.cs
@@ -0,0 +1,38 @@
+using UnityEngine;
+using UnityEditor;
+
+namespace Cinemachine.Editor
+{
+ [CustomPropertyDrawer(typeof(CinemachineBlendDefinitionPropertyAttribute))]
+ public sealed class CinemachineBlendDefinitionPropertyDrawer : PropertyDrawer
+ {
+ CinemachineBlendDefinition myClass = new CinemachineBlendDefinition(); // to access name strings
+ public override void OnGUI(Rect rect, SerializedProperty property, GUIContent label)
+ {
+ float vSpace = 0;
+ float floatFieldWidth = EditorGUIUtility.singleLineHeight * 2.5f;
+
+ SerializedProperty timeProp = property.FindPropertyRelative(() => myClass.m_Time);
+ GUIContent timeText = new GUIContent(" sec ", timeProp.tooltip);
+ var textDimensions = GUI.skin.label.CalcSize(timeText);
+
+ rect = EditorGUI.PrefixLabel(rect, label);
+
+ rect.y += vSpace; rect.height = EditorGUIUtility.singleLineHeight;
+ rect.width -= floatFieldWidth + textDimensions.x;
+
+ SerializedProperty styleProp = property.FindPropertyRelative(() => myClass.m_Style);
+ EditorGUI.PropertyField(rect, styleProp, GUIContent.none);
+
+ if (styleProp.intValue != (int)CinemachineBlendDefinition.Style.Cut)
+ {
+ float oldWidth = EditorGUIUtility.labelWidth;
+ EditorGUIUtility.labelWidth = textDimensions.x;
+ rect.x += rect.width; rect.width = floatFieldWidth + EditorGUIUtility.labelWidth;
+ EditorGUI.PropertyField(rect, timeProp, timeText);
+ timeProp.floatValue = Mathf.Max(timeProp.floatValue, 0);
+ EditorGUIUtility.labelWidth = oldWidth;
+ }
+ }
+ }
+}
diff --git a/Assets/Cinemachine/Base/Editor/PropertyDrawers/CinemachineBlendDefinitionPropertyDrawer.cs.meta b/Assets/Cinemachine/Base/Editor/PropertyDrawers/CinemachineBlendDefinitionPropertyDrawer.cs.meta
new file mode 100644
index 0000000..2eed780
--- /dev/null
+++ b/Assets/Cinemachine/Base/Editor/PropertyDrawers/CinemachineBlendDefinitionPropertyDrawer.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 4a9c464b0191f7d4da1d129d97d8240b
+timeCreated: 1486510400
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Cinemachine/Base/Editor/PropertyDrawers/CinemachineTagFieldPropertyDrawer.cs b/Assets/Cinemachine/Base/Editor/PropertyDrawers/CinemachineTagFieldPropertyDrawer.cs
new file mode 100644
index 0000000..5fba835
--- /dev/null
+++ b/Assets/Cinemachine/Base/Editor/PropertyDrawers/CinemachineTagFieldPropertyDrawer.cs
@@ -0,0 +1,28 @@
+using UnityEngine;
+using UnityEditor;
+
+namespace Cinemachine.Editor
+{
+ [CustomPropertyDrawer(typeof(TagFieldAttribute))]
+ public sealed class CinemachineTagFieldPropertyDrawer : PropertyDrawer
+ {
+ public override void OnGUI(Rect rect, SerializedProperty property, GUIContent label)
+ {
+ const float hSpace = 2;
+ GUIContent clearText = new GUIContent("Clear", "Set the tag to empty");
+ var textDimensions = GUI.skin.button.CalcSize(clearText);
+
+ rect.width -= textDimensions.x + hSpace;
+ string oldValue = property.stringValue;
+ string newValue = EditorGUI.TagField(rect, label, oldValue);
+
+ rect.x += rect.width; rect.width = textDimensions.x;
+ GUI.enabled = oldValue.Length > 0;
+ if (GUI.Button(rect, clearText))
+ newValue = string.Empty;
+ GUI.enabled = true;
+ if (oldValue != newValue)
+ property.stringValue = newValue;
+ }
+ }
+}
diff --git a/Assets/Cinemachine/Base/Editor/PropertyDrawers/CinemachineTagFieldPropertyDrawer.cs.meta b/Assets/Cinemachine/Base/Editor/PropertyDrawers/CinemachineTagFieldPropertyDrawer.cs.meta
new file mode 100644
index 0000000..b2a73ab
--- /dev/null
+++ b/Assets/Cinemachine/Base/Editor/PropertyDrawers/CinemachineTagFieldPropertyDrawer.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: ed3efd28525441947b55ec9b5d68ba31
+timeCreated: 1510677929
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Cinemachine/Base/Editor/PropertyDrawers/GetSetDrawer.cs b/Assets/Cinemachine/Base/Editor/PropertyDrawers/GetSetDrawer.cs
new file mode 100644
index 0000000..8893a81
--- /dev/null
+++ b/Assets/Cinemachine/Base/Editor/PropertyDrawers/GetSetDrawer.cs
@@ -0,0 +1 @@
+// This file is intentionally blank. \ No newline at end of file
diff --git a/Assets/Cinemachine/Base/Editor/PropertyDrawers/GetSetDrawer.cs.meta b/Assets/Cinemachine/Base/Editor/PropertyDrawers/GetSetDrawer.cs.meta
new file mode 100644
index 0000000..a265654
--- /dev/null
+++ b/Assets/Cinemachine/Base/Editor/PropertyDrawers/GetSetDrawer.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: e54b95371574a3144b851b0ca93ceb39
+timeCreated: 1493651850
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Cinemachine/Base/Editor/PropertyDrawers/LensSettingsPropertyDrawer.cs b/Assets/Cinemachine/Base/Editor/PropertyDrawers/LensSettingsPropertyDrawer.cs
new file mode 100644
index 0000000..d1a5165
--- /dev/null
+++ b/Assets/Cinemachine/Base/Editor/PropertyDrawers/LensSettingsPropertyDrawer.cs
@@ -0,0 +1,61 @@
+using UnityEngine;
+using UnityEditor;
+using System.Reflection;
+
+namespace Cinemachine.Editor
+{
+ [CustomPropertyDrawer(typeof(LensSettingsPropertyAttribute))]
+ public sealed class LensSettingsPropertyDrawer : PropertyDrawer
+ {
+ const int vSpace = 2;
+ bool mExpanded = true;
+ LensSettings def = new LensSettings(); // to access name strings
+
+ public override void OnGUI(Rect rect, SerializedProperty property, GUIContent label)
+ {
+ float height = EditorGUIUtility.singleLineHeight;
+ rect.height = height;
+ mExpanded = EditorGUI.Foldout(rect, mExpanded, label);
+ if (mExpanded)
+ {
+ bool ortho = false;
+ PropertyInfo pi = typeof(LensSettings).GetProperty(
+ "Orthographic", BindingFlags.NonPublic | BindingFlags.Instance);
+ if (pi != null)
+ ortho = bool.Equals(true, pi.GetValue(GetPropertyValue(property), null));
+
+ ++EditorGUI.indentLevel;
+ rect.y += height + vSpace;
+ if (ortho)
+ EditorGUI.PropertyField(rect, property.FindPropertyRelative(() => def.OrthographicSize));
+ else
+ EditorGUI.PropertyField(rect, property.FindPropertyRelative(() => def.FieldOfView));
+ rect.y += height + vSpace;
+ EditorGUI.PropertyField(rect, property.FindPropertyRelative(() => def.NearClipPlane));
+ rect.y += height + vSpace;
+ EditorGUI.PropertyField(rect, property.FindPropertyRelative(() => def.FarClipPlane));
+ rect.y += height + vSpace;
+ EditorGUI.PropertyField(rect, property.FindPropertyRelative(() => def.Dutch));
+ --EditorGUI.indentLevel;
+ }
+ }
+
+ object GetPropertyValue(SerializedProperty property)
+ {
+ var targetObject = property.serializedObject.targetObject;
+ var targetObjectClassType = targetObject.GetType();
+ var field = targetObjectClassType.GetField(property.propertyPath);
+ if (field != null)
+ return field.GetValue(targetObject);
+ return null;
+ }
+
+ public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
+ {
+ float height = EditorGUIUtility.singleLineHeight + vSpace;
+ if (mExpanded)
+ height *= 5;
+ return height;
+ }
+ }
+}
diff --git a/Assets/Cinemachine/Base/Editor/PropertyDrawers/LensSettingsPropertyDrawer.cs.meta b/Assets/Cinemachine/Base/Editor/PropertyDrawers/LensSettingsPropertyDrawer.cs.meta
new file mode 100644
index 0000000..2e29f7f
--- /dev/null
+++ b/Assets/Cinemachine/Base/Editor/PropertyDrawers/LensSettingsPropertyDrawer.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 2449eb616c871d044adce04ac98030a6
+timeCreated: 1496951835
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Cinemachine/Base/Editor/PropertyDrawers/MinDrawer.cs b/Assets/Cinemachine/Base/Editor/PropertyDrawers/MinDrawer.cs
new file mode 100644
index 0000000..8893a81
--- /dev/null
+++ b/Assets/Cinemachine/Base/Editor/PropertyDrawers/MinDrawer.cs
@@ -0,0 +1 @@
+// This file is intentionally blank. \ No newline at end of file
diff --git a/Assets/Cinemachine/Base/Editor/PropertyDrawers/MinDrawer.cs.meta b/Assets/Cinemachine/Base/Editor/PropertyDrawers/MinDrawer.cs.meta
new file mode 100644
index 0000000..66c16e4
--- /dev/null
+++ b/Assets/Cinemachine/Base/Editor/PropertyDrawers/MinDrawer.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 9d5b46a4a3526d14080bfc4bb247664c
+timeCreated: 1493651850
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant: