diff options
Diffstat (limited to 'Assets/uGUI-2017.1/Editor/UI')
67 files changed, 4174 insertions, 0 deletions
diff --git a/Assets/uGUI-2017.1/Editor/UI/AspectRatioFitterEditor.cs b/Assets/uGUI-2017.1/Editor/UI/AspectRatioFitterEditor.cs new file mode 100644 index 0000000..2901460 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/AspectRatioFitterEditor.cs @@ -0,0 +1,29 @@ +using UnityEngine; +using UnityEngine.UI; + +namespace UnityEditor.UI +{ + [CustomEditor(typeof(AspectRatioFitter), true)] + [CanEditMultipleObjects] + public class AspectRatioFitterEditor : SelfControllerEditor + { + SerializedProperty m_AspectMode; + SerializedProperty m_AspectRatio; + + protected virtual void OnEnable() + { + m_AspectMode = serializedObject.FindProperty("m_AspectMode"); + m_AspectRatio = serializedObject.FindProperty("m_AspectRatio"); + } + + public override void OnInspectorGUI() + { + serializedObject.Update(); + EditorGUILayout.PropertyField(m_AspectMode); + EditorGUILayout.PropertyField(m_AspectRatio); + serializedObject.ApplyModifiedProperties(); + + base.OnInspectorGUI(); + } + } +} diff --git a/Assets/uGUI-2017.1/Editor/UI/AspectRatioFitterEditor.cs.meta b/Assets/uGUI-2017.1/Editor/UI/AspectRatioFitterEditor.cs.meta new file mode 100644 index 0000000..0e02140 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/AspectRatioFitterEditor.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 47edf64b98c2574419b1a0c2b1cb4a78 +timeCreated: 1602119378 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/Editor/UI/AssemblyInfo.cs b/Assets/uGUI-2017.1/Editor/UI/AssemblyInfo.cs new file mode 100644 index 0000000..9aa72dc --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/AssemblyInfo.cs @@ -0,0 +1,38 @@ +using System.Reflection; +using System.Runtime.InteropServices; +using UnityEngine; + + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("UnityEditor.UI")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Unity Technologies")] +[assembly: AssemblyProduct("guisystemeditor")] +[assembly: AssemblyCopyright("Copyright © Unity Technologies 2013")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] +[assembly: AssemblyIsEditorAssembly] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("ad7418c3-5d25-4670-b468-8e7196596d42")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Assets/uGUI-2017.1/Editor/UI/AssemblyInfo.cs.meta b/Assets/uGUI-2017.1/Editor/UI/AssemblyInfo.cs.meta new file mode 100644 index 0000000..9d5566f --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/AssemblyInfo.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 17fd9454424a6004e9982ef22617b070 +timeCreated: 1602119377 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/Editor/UI/ButtonEditor.cs b/Assets/uGUI-2017.1/Editor/UI/ButtonEditor.cs new file mode 100644 index 0000000..9676934 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/ButtonEditor.cs @@ -0,0 +1,29 @@ +using UnityEngine.UI; + +namespace UnityEditor.UI +{ + [CustomEditor(typeof(Button), true)] + [CanEditMultipleObjects] + public class ButtonEditor : SelectableEditor + { + SerializedProperty m_OnClickProperty; + + protected override void OnEnable() + { + base.OnEnable(); + m_OnClickProperty = serializedObject.FindProperty("m_OnClick"); + } + + public override void OnInspectorGUI() + { + base.OnInspectorGUI(); + EditorGUILayout.Space(); + + serializedObject.Update(); + + EditorGUILayout.PropertyField(m_OnClickProperty); + + serializedObject.ApplyModifiedProperties(); + } + } +} diff --git a/Assets/uGUI-2017.1/Editor/UI/ButtonEditor.cs.meta b/Assets/uGUI-2017.1/Editor/UI/ButtonEditor.cs.meta new file mode 100644 index 0000000..3d63fb0 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/ButtonEditor.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 87698847489a1eb49a05be64fb084cc3 +timeCreated: 1602119379 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/Editor/UI/CanvasScalerEditor.cs b/Assets/uGUI-2017.1/Editor/UI/CanvasScalerEditor.cs new file mode 100644 index 0000000..883d300 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/CanvasScalerEditor.cs @@ -0,0 +1,160 @@ +using UnityEngine; +using UnityEngine.UI; + +namespace UnityEditor.UI +{ + [CustomEditor(typeof(CanvasScaler), true)] + [CanEditMultipleObjects] + public class CanvasScalerEditor : Editor + { + SerializedProperty m_UiScaleMode; + SerializedProperty m_ScaleFactor; + SerializedProperty m_ReferenceResolution; + SerializedProperty m_ScreenMatchMode; + SerializedProperty m_MatchWidthOrHeight; + SerializedProperty m_PhysicalUnit; + SerializedProperty m_FallbackScreenDPI; + SerializedProperty m_DefaultSpriteDPI; + SerializedProperty m_DynamicPixelsPerUnit; + SerializedProperty m_ReferencePixelsPerUnit; + + const int kSliderEndpointLabelsHeight = 12; + + private class Styles + { + public GUIContent matchContent; + public GUIContent widthContent; + public GUIContent heightContent; + public GUIContent uiScaleModeContent; + public GUIStyle leftAlignedLabel; + public GUIStyle rightAlignedLabel; + + public Styles() + { + matchContent = new GUIContent("Match"); + widthContent = new GUIContent("Width"); + heightContent = new GUIContent("Height"); + uiScaleModeContent = new GUIContent("UI Scale Mode"); + + leftAlignedLabel = new GUIStyle(EditorStyles.label); + rightAlignedLabel = new GUIStyle(EditorStyles.label); + rightAlignedLabel.alignment = TextAnchor.MiddleRight; + } + } + private static Styles s_Styles; + + protected virtual void OnEnable() + { + m_UiScaleMode = serializedObject.FindProperty("m_UiScaleMode"); + m_ScaleFactor = serializedObject.FindProperty("m_ScaleFactor"); + m_ReferenceResolution = serializedObject.FindProperty("m_ReferenceResolution"); + m_ScreenMatchMode = serializedObject.FindProperty("m_ScreenMatchMode"); + m_MatchWidthOrHeight = serializedObject.FindProperty("m_MatchWidthOrHeight"); + m_PhysicalUnit = serializedObject.FindProperty("m_PhysicalUnit"); + m_FallbackScreenDPI = serializedObject.FindProperty("m_FallbackScreenDPI"); + m_DefaultSpriteDPI = serializedObject.FindProperty("m_DefaultSpriteDPI"); + m_DynamicPixelsPerUnit = serializedObject.FindProperty("m_DynamicPixelsPerUnit"); + m_ReferencePixelsPerUnit = serializedObject.FindProperty("m_ReferencePixelsPerUnit"); + } + + public override void OnInspectorGUI() + { + if (s_Styles == null) + s_Styles = new Styles(); + + bool allAreRoot = true; + bool showWorldDiffers = false; + bool showWorld = ((target as CanvasScaler).GetComponent<Canvas>().renderMode == RenderMode.WorldSpace); + for (int i = 0; i < targets.Length; i++) + { + CanvasScaler scaler = targets[i] as CanvasScaler; + Canvas canvas = scaler.GetComponent<Canvas>(); + if (!canvas.isRootCanvas) + { + allAreRoot = false; + break; + } + if (showWorld && canvas.renderMode != RenderMode.WorldSpace || !showWorld && canvas.renderMode == RenderMode.WorldSpace) + { + showWorldDiffers = true; + break; + } + } + + if (!allAreRoot) + { + EditorGUILayout.HelpBox("Non-root Canvases will not be scaled.", MessageType.Warning); + return; + } + + serializedObject.Update(); + + EditorGUI.showMixedValue = showWorldDiffers; + using (new EditorGUI.DisabledScope(showWorld || showWorldDiffers)) + { + if (showWorld || showWorldDiffers) + { + EditorGUILayout.Popup(s_Styles.uiScaleModeContent.text, 0, new[] { "World" }); + } + else + { + EditorGUILayout.PropertyField(m_UiScaleMode, s_Styles.uiScaleModeContent); + } + } + EditorGUI.showMixedValue = false; + + if (!showWorldDiffers && !(!showWorld && m_UiScaleMode.hasMultipleDifferentValues)) + { + EditorGUILayout.Space(); + + // World Canvas + if (showWorld) + { + EditorGUILayout.PropertyField(m_DynamicPixelsPerUnit); + } + // Constant pixel size + else if (m_UiScaleMode.enumValueIndex == (int)CanvasScaler.ScaleMode.ConstantPixelSize) + { + EditorGUILayout.PropertyField(m_ScaleFactor); + } + // Scale with screen size + else if (m_UiScaleMode.enumValueIndex == (int)CanvasScaler.ScaleMode.ScaleWithScreenSize) + { + EditorGUILayout.PropertyField(m_ReferenceResolution); + EditorGUILayout.PropertyField(m_ScreenMatchMode); + if (m_ScreenMatchMode.enumValueIndex == (int)CanvasScaler.ScreenMatchMode.MatchWidthOrHeight && !m_ScreenMatchMode.hasMultipleDifferentValues) + { + Rect r = EditorGUILayout.GetControlRect(true, EditorGUIUtility.singleLineHeight + kSliderEndpointLabelsHeight); + DualLabeledSlider(r, m_MatchWidthOrHeight, s_Styles.matchContent, s_Styles.widthContent, s_Styles.heightContent); + } + } + // Constant physical size + else if (m_UiScaleMode.enumValueIndex == (int)CanvasScaler.ScaleMode.ConstantPhysicalSize) + { + EditorGUILayout.PropertyField(m_PhysicalUnit); + EditorGUILayout.PropertyField(m_FallbackScreenDPI); + EditorGUILayout.PropertyField(m_DefaultSpriteDPI); + } + + EditorGUILayout.PropertyField(m_ReferencePixelsPerUnit); + } + + serializedObject.ApplyModifiedProperties(); + } + + private static void DualLabeledSlider(Rect position, SerializedProperty property, GUIContent mainLabel, GUIContent labelLeft, GUIContent labelRight) + { + position.height = EditorGUIUtility.singleLineHeight; + Rect pos = position; + + position.y += 12; + position.xMin += EditorGUIUtility.labelWidth; + position.xMax -= EditorGUIUtility.fieldWidth; + + GUI.Label(position, labelLeft, s_Styles.leftAlignedLabel); + GUI.Label(position, labelRight, s_Styles.rightAlignedLabel); + + EditorGUI.PropertyField(pos, property, mainLabel); + } + } +} diff --git a/Assets/uGUI-2017.1/Editor/UI/CanvasScalerEditor.cs.meta b/Assets/uGUI-2017.1/Editor/UI/CanvasScalerEditor.cs.meta new file mode 100644 index 0000000..e92d213 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/CanvasScalerEditor.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 03c5d085f2f1a3d468f8073e18105b77 +timeCreated: 1602119377 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/Editor/UI/ContentSizeFitterEditor.cs b/Assets/uGUI-2017.1/Editor/UI/ContentSizeFitterEditor.cs new file mode 100644 index 0000000..87fdbef --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/ContentSizeFitterEditor.cs @@ -0,0 +1,29 @@ +using UnityEngine; +using UnityEngine.UI; + +namespace UnityEditor.UI +{ + [CustomEditor(typeof(ContentSizeFitter), true)] + [CanEditMultipleObjects] + public class ContentSizeFitterEditor : SelfControllerEditor + { + SerializedProperty m_HorizontalFit; + SerializedProperty m_VerticalFit; + + protected virtual void OnEnable() + { + m_HorizontalFit = serializedObject.FindProperty("m_HorizontalFit"); + m_VerticalFit = serializedObject.FindProperty("m_VerticalFit"); + } + + public override void OnInspectorGUI() + { + serializedObject.Update(); + EditorGUILayout.PropertyField(m_HorizontalFit, true); + EditorGUILayout.PropertyField(m_VerticalFit, true); + serializedObject.ApplyModifiedProperties(); + + base.OnInspectorGUI(); + } + } +} diff --git a/Assets/uGUI-2017.1/Editor/UI/ContentSizeFitterEditor.cs.meta b/Assets/uGUI-2017.1/Editor/UI/ContentSizeFitterEditor.cs.meta new file mode 100644 index 0000000..9f09d06 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/ContentSizeFitterEditor.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 906585751f53cee439d265a08589edcf +timeCreated: 1602119379 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/Editor/UI/DropdownEditor.cs b/Assets/uGUI-2017.1/Editor/UI/DropdownEditor.cs new file mode 100644 index 0000000..1dd16e4 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/DropdownEditor.cs @@ -0,0 +1,48 @@ +using UnityEngine.UI; + +namespace UnityEditor.UI +{ + [CustomEditor(typeof(Dropdown), true)] + [CanEditMultipleObjects] + public class DropdownEditor : SelectableEditor + { + SerializedProperty m_Template; + SerializedProperty m_CaptionText; + SerializedProperty m_CaptionImage; + SerializedProperty m_ItemText; + SerializedProperty m_ItemImage; + SerializedProperty m_OnSelectionChanged; + SerializedProperty m_Value; + SerializedProperty m_Options; + + protected override void OnEnable() + { + base.OnEnable(); + m_Template = serializedObject.FindProperty("m_Template"); + m_CaptionText = serializedObject.FindProperty("m_CaptionText"); + m_CaptionImage = serializedObject.FindProperty("m_CaptionImage"); + m_ItemText = serializedObject.FindProperty("m_ItemText"); + m_ItemImage = serializedObject.FindProperty("m_ItemImage"); + m_OnSelectionChanged = serializedObject.FindProperty("m_OnValueChanged"); + m_Value = serializedObject.FindProperty("m_Value"); + m_Options = serializedObject.FindProperty("m_Options"); + } + + public override void OnInspectorGUI() + { + base.OnInspectorGUI(); + EditorGUILayout.Space(); + + serializedObject.Update(); + EditorGUILayout.PropertyField(m_Template); + EditorGUILayout.PropertyField(m_CaptionText); + EditorGUILayout.PropertyField(m_CaptionImage); + EditorGUILayout.PropertyField(m_ItemText); + EditorGUILayout.PropertyField(m_ItemImage); + EditorGUILayout.PropertyField(m_Value); + EditorGUILayout.PropertyField(m_Options); + EditorGUILayout.PropertyField(m_OnSelectionChanged); + serializedObject.ApplyModifiedProperties(); + } + } +} diff --git a/Assets/uGUI-2017.1/Editor/UI/DropdownEditor.cs.meta b/Assets/uGUI-2017.1/Editor/UI/DropdownEditor.cs.meta new file mode 100644 index 0000000..1f51b0a --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/DropdownEditor.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 7b05a7b6f5fe0744a850680d5f282a6a +timeCreated: 1602119379 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/Editor/UI/GraphicEditor.cs b/Assets/uGUI-2017.1/Editor/UI/GraphicEditor.cs new file mode 100644 index 0000000..3fc16ee --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/GraphicEditor.cs @@ -0,0 +1,93 @@ +using System.Linq; +using UnityEditor.AnimatedValues; +using UnityEngine; +using UnityEngine.UI; + +namespace UnityEditor.UI +{ + /// <summary> + /// Editor class used to edit UI Graphics. + /// </summary> + + [CustomEditor(typeof(MaskableGraphic), false)] + [CanEditMultipleObjects] + public class GraphicEditor : Editor + { + protected SerializedProperty m_Script; + protected SerializedProperty m_Color; + protected SerializedProperty m_Material; + protected SerializedProperty m_RaycastTarget; + + private GUIContent m_CorrectButtonContent; + protected AnimBool m_ShowNativeSize; + + protected virtual void OnDisable() + { + Tools.hidden = false; + m_ShowNativeSize.valueChanged.RemoveListener(Repaint); + } + + protected virtual void OnEnable() + { + m_CorrectButtonContent = new GUIContent("Set Native Size", "Sets the size to match the content."); + + m_Script = serializedObject.FindProperty("m_Script"); + m_Color = serializedObject.FindProperty("m_Color"); + m_Material = serializedObject.FindProperty("m_Material"); + m_RaycastTarget = serializedObject.FindProperty("m_RaycastTarget"); + + m_ShowNativeSize = new AnimBool(false); + m_ShowNativeSize.valueChanged.AddListener(Repaint); + } + + public override void OnInspectorGUI() + { + serializedObject.Update(); + EditorGUILayout.PropertyField(m_Script); + AppearanceControlsGUI(); + RaycastControlsGUI(); + serializedObject.ApplyModifiedProperties(); + } + + protected void SetShowNativeSize(bool show, bool instant) + { + if (instant) + m_ShowNativeSize.value = show; + else + m_ShowNativeSize.target = show; + } + + protected void NativeSizeButtonGUI() + { + if (EditorGUILayout.BeginFadeGroup(m_ShowNativeSize.faded)) + { + EditorGUILayout.BeginHorizontal(); + { + GUILayout.Space(EditorGUIUtility.labelWidth); + if (GUILayout.Button(m_CorrectButtonContent, EditorStyles.miniButton)) + { + foreach (Graphic graphic in targets.Select(obj => obj as Graphic)) + { + Undo.RecordObject(graphic.rectTransform, "Set Native Size"); + graphic.SetNativeSize(); + EditorUtility.SetDirty(graphic); + } + } + } + EditorGUILayout.EndHorizontal(); + } + EditorGUILayout.EndFadeGroup(); + } + + protected void AppearanceControlsGUI() + { + EditorGUILayout.PropertyField(m_Color); + EditorGUILayout.PropertyField(m_Material); + } + + protected void RaycastControlsGUI() + { + EditorGUILayout.PropertyField(m_RaycastTarget); + } + } +} diff --git a/Assets/uGUI-2017.1/Editor/UI/GraphicEditor.cs.meta b/Assets/uGUI-2017.1/Editor/UI/GraphicEditor.cs.meta new file mode 100644 index 0000000..d6a4459 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/GraphicEditor.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 46f6948c5f4af7747b8bd84eaff48829 +timeCreated: 1602119378 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/Editor/UI/GridLayoutGroupEditor.cs b/Assets/uGUI-2017.1/Editor/UI/GridLayoutGroupEditor.cs new file mode 100644 index 0000000..462e99a --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/GridLayoutGroupEditor.cs @@ -0,0 +1,52 @@ +using UnityEngine; +using UnityEngine.UI; +using UnityEditorInternal; +using UnityEditor.AnimatedValues; + +namespace UnityEditor.UI +{ + [CustomEditor(typeof(GridLayoutGroup), true)] + [CanEditMultipleObjects] + public class GridLayoutGroupEditor : Editor + { + SerializedProperty m_Padding; + SerializedProperty m_CellSize; + SerializedProperty m_Spacing; + SerializedProperty m_StartCorner; + SerializedProperty m_StartAxis; + SerializedProperty m_ChildAlignment; + SerializedProperty m_Constraint; + SerializedProperty m_ConstraintCount; + + protected virtual void OnEnable() + { + m_Padding = serializedObject.FindProperty("m_Padding"); + m_CellSize = serializedObject.FindProperty("m_CellSize"); + m_Spacing = serializedObject.FindProperty("m_Spacing"); + m_StartCorner = serializedObject.FindProperty("m_StartCorner"); + m_StartAxis = serializedObject.FindProperty("m_StartAxis"); + m_ChildAlignment = serializedObject.FindProperty("m_ChildAlignment"); + m_Constraint = serializedObject.FindProperty("m_Constraint"); + m_ConstraintCount = serializedObject.FindProperty("m_ConstraintCount"); + } + + public override void OnInspectorGUI() + { + serializedObject.Update(); + EditorGUILayout.PropertyField(m_Padding, true); + EditorGUILayout.PropertyField(m_CellSize, true); + EditorGUILayout.PropertyField(m_Spacing, true); + EditorGUILayout.PropertyField(m_StartCorner, true); + EditorGUILayout.PropertyField(m_StartAxis, true); + EditorGUILayout.PropertyField(m_ChildAlignment, true); + EditorGUILayout.PropertyField(m_Constraint, true); + if (m_Constraint.enumValueIndex > 0) + { + EditorGUI.indentLevel++; + EditorGUILayout.PropertyField(m_ConstraintCount, true); + EditorGUI.indentLevel--; + } + serializedObject.ApplyModifiedProperties(); + } + } +} diff --git a/Assets/uGUI-2017.1/Editor/UI/GridLayoutGroupEditor.cs.meta b/Assets/uGUI-2017.1/Editor/UI/GridLayoutGroupEditor.cs.meta new file mode 100644 index 0000000..b0931bf --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/GridLayoutGroupEditor.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 41b243187f9b6264e8f982c805ac671d +timeCreated: 1602119378 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/Editor/UI/HorizontalOrVerticalLayoutGroupEditor.cs b/Assets/uGUI-2017.1/Editor/UI/HorizontalOrVerticalLayoutGroupEditor.cs new file mode 100644 index 0000000..01b17b8 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/HorizontalOrVerticalLayoutGroupEditor.cs @@ -0,0 +1,75 @@ +using UnityEngine; +using UnityEngine.UI; +using UnityEditorInternal; +using UnityEditor.AnimatedValues; + +namespace UnityEditor.UI +{ + [CustomEditor(typeof(HorizontalOrVerticalLayoutGroup), true)] + [CanEditMultipleObjects] + public class HorizontalOrVerticalLayoutGroupEditor : Editor + { + SerializedProperty m_Padding; + SerializedProperty m_Spacing; + SerializedProperty m_ChildAlignment; + SerializedProperty m_ChildControlWidth; + SerializedProperty m_ChildControlHeight; + SerializedProperty m_ChildForceExpandWidth; + SerializedProperty m_ChildForceExpandHeight; + + protected virtual void OnEnable() + { + m_Padding = serializedObject.FindProperty("m_Padding"); + m_Spacing = serializedObject.FindProperty("m_Spacing"); + m_ChildAlignment = serializedObject.FindProperty("m_ChildAlignment"); + m_ChildControlWidth = serializedObject.FindProperty("m_ChildControlWidth"); + m_ChildControlHeight = serializedObject.FindProperty("m_ChildControlHeight"); + m_ChildForceExpandWidth = serializedObject.FindProperty("m_ChildForceExpandWidth"); + m_ChildForceExpandHeight = serializedObject.FindProperty("m_ChildForceExpandHeight"); + } + + public override void OnInspectorGUI() + { + serializedObject.Update(); + EditorGUILayout.PropertyField(m_Padding, true); + EditorGUILayout.PropertyField(m_Spacing, true); + EditorGUILayout.PropertyField(m_ChildAlignment, true); + + Rect rect = EditorGUILayout.GetControlRect(); + rect = EditorGUI.PrefixLabel(rect, -1, new GUIContent("Child Controls Size")); + rect.width = Mathf.Max(50, (rect.width - 4) / 3); + EditorGUIUtility.labelWidth = 50; + ToggleLeft(rect, m_ChildControlWidth, new GUIContent("Width")); + rect.x += rect.width + 2; + ToggleLeft(rect, m_ChildControlHeight, new GUIContent("Height")); + EditorGUIUtility.labelWidth = 0; + + rect = EditorGUILayout.GetControlRect(); + rect = EditorGUI.PrefixLabel(rect, -1, new GUIContent("Child Force Expand")); + rect.width = Mathf.Max(50, (rect.width - 4) / 3); + EditorGUIUtility.labelWidth = 50; + ToggleLeft(rect, m_ChildForceExpandWidth, new GUIContent("Width")); + rect.x += rect.width + 2; + ToggleLeft(rect, m_ChildForceExpandHeight, new GUIContent("Height")); + EditorGUIUtility.labelWidth = 0; + + serializedObject.ApplyModifiedProperties(); + } + + void ToggleLeft(Rect position, SerializedProperty property, GUIContent label) + { + bool toggle = property.boolValue; + EditorGUI.showMixedValue = property.hasMultipleDifferentValues; + EditorGUI.BeginChangeCheck(); + int oldIndent = EditorGUI.indentLevel; + EditorGUI.indentLevel = 0; + toggle = EditorGUI.ToggleLeft(position, label, toggle); + EditorGUI.indentLevel = oldIndent; + if (EditorGUI.EndChangeCheck()) + { + property.boolValue = property.hasMultipleDifferentValues ? true : !property.boolValue; + } + EditorGUI.showMixedValue = false; + } + } +} diff --git a/Assets/uGUI-2017.1/Editor/UI/HorizontalOrVerticalLayoutGroupEditor.cs.meta b/Assets/uGUI-2017.1/Editor/UI/HorizontalOrVerticalLayoutGroupEditor.cs.meta new file mode 100644 index 0000000..f91a76b --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/HorizontalOrVerticalLayoutGroupEditor.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: be8e8f57c18c7b64a8db44d2f8b15598 +timeCreated: 1602119380 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/Editor/UI/ImageEditor.cs b/Assets/uGUI-2017.1/Editor/UI/ImageEditor.cs new file mode 100644 index 0000000..85da33f --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/ImageEditor.cs @@ -0,0 +1,251 @@ +using System.Linq; +using UnityEngine; +using UnityEditor.AnimatedValues; +using UnityEngine.UI; + +namespace UnityEditor.UI +{ + /// <summary> + /// Editor class used to edit UI Sprites. + /// </summary> + + [CustomEditor(typeof(Image), true)] + [CanEditMultipleObjects] + public class ImageEditor : GraphicEditor + { + SerializedProperty m_FillMethod; + SerializedProperty m_FillOrigin; + SerializedProperty m_FillAmount; + SerializedProperty m_FillClockwise; + SerializedProperty m_Type; + SerializedProperty m_FillCenter; + SerializedProperty m_Sprite; + SerializedProperty m_PreserveAspect; + GUIContent m_SpriteContent; + GUIContent m_SpriteTypeContent; + GUIContent m_ClockwiseContent; + AnimBool m_ShowSlicedOrTiled; + AnimBool m_ShowSliced; + AnimBool m_ShowTiled; + AnimBool m_ShowFilled; + AnimBool m_ShowType; + + protected override void OnEnable() + { + base.OnEnable(); + + m_SpriteContent = new GUIContent("Source Image"); + m_SpriteTypeContent = new GUIContent("Image Type"); + m_ClockwiseContent = new GUIContent("Clockwise"); + + m_Sprite = serializedObject.FindProperty("m_Sprite"); + m_Type = serializedObject.FindProperty("m_Type"); + m_FillCenter = serializedObject.FindProperty("m_FillCenter"); + m_FillMethod = serializedObject.FindProperty("m_FillMethod"); + m_FillOrigin = serializedObject.FindProperty("m_FillOrigin"); + m_FillClockwise = serializedObject.FindProperty("m_FillClockwise"); + m_FillAmount = serializedObject.FindProperty("m_FillAmount"); + m_PreserveAspect = serializedObject.FindProperty("m_PreserveAspect"); + + m_ShowType = new AnimBool(m_Sprite.objectReferenceValue != null); + m_ShowType.valueChanged.AddListener(Repaint); + + var typeEnum = (Image.Type)m_Type.enumValueIndex; + + m_ShowSlicedOrTiled = new AnimBool(!m_Type.hasMultipleDifferentValues && typeEnum == Image.Type.Sliced); + m_ShowSliced = new AnimBool(!m_Type.hasMultipleDifferentValues && typeEnum == Image.Type.Sliced); + m_ShowTiled = new AnimBool(!m_Type.hasMultipleDifferentValues && typeEnum == Image.Type.Tiled); + m_ShowFilled = new AnimBool(!m_Type.hasMultipleDifferentValues && typeEnum == Image.Type.Filled); + m_ShowSlicedOrTiled.valueChanged.AddListener(Repaint); + m_ShowSliced.valueChanged.AddListener(Repaint); + m_ShowTiled.valueChanged.AddListener(Repaint); + m_ShowFilled.valueChanged.AddListener(Repaint); + + SetShowNativeSize(true); + } + + protected override void OnDisable() + { + m_ShowType.valueChanged.RemoveListener(Repaint); + m_ShowSlicedOrTiled.valueChanged.RemoveListener(Repaint); + m_ShowSliced.valueChanged.RemoveListener(Repaint); + m_ShowTiled.valueChanged.RemoveListener(Repaint); + m_ShowFilled.valueChanged.RemoveListener(Repaint); + } + + public override void OnInspectorGUI() + { + serializedObject.Update(); + + SpriteGUI(); + AppearanceControlsGUI(); + RaycastControlsGUI(); + + m_ShowType.target = m_Sprite.objectReferenceValue != null; + if (EditorGUILayout.BeginFadeGroup(m_ShowType.faded)) + TypeGUI(); + EditorGUILayout.EndFadeGroup(); + + SetShowNativeSize(false); + if (EditorGUILayout.BeginFadeGroup(m_ShowNativeSize.faded)) + { + EditorGUI.indentLevel++; + EditorGUILayout.PropertyField(m_PreserveAspect); + EditorGUI.indentLevel--; + } + EditorGUILayout.EndFadeGroup(); + NativeSizeButtonGUI(); + + serializedObject.ApplyModifiedProperties(); + } + + void SetShowNativeSize(bool instant) + { + Image.Type type = (Image.Type)m_Type.enumValueIndex; + bool showNativeSize = (type == Image.Type.Simple || type == Image.Type.Filled) && m_Sprite.objectReferenceValue != null; + base.SetShowNativeSize(showNativeSize, instant); + } + + /// <summary> + /// Draw the atlas and Image selection fields. + /// </summary> + + protected void SpriteGUI() + { + EditorGUI.BeginChangeCheck(); + EditorGUILayout.PropertyField(m_Sprite, m_SpriteContent); + if (EditorGUI.EndChangeCheck()) + { + var newSprite = m_Sprite.objectReferenceValue as Sprite; + if (newSprite) + { + Image.Type oldType = (Image.Type)m_Type.enumValueIndex; + if (newSprite.border.SqrMagnitude() > 0) + { + m_Type.enumValueIndex = (int)Image.Type.Sliced; + } + else if (oldType == Image.Type.Sliced) + { + m_Type.enumValueIndex = (int)Image.Type.Simple; + } + } + } + } + + /// <summary> + /// Sprites's custom properties based on the type. + /// </summary> + + protected void TypeGUI() + { + EditorGUILayout.PropertyField(m_Type, m_SpriteTypeContent); + + ++EditorGUI.indentLevel; + { + Image.Type typeEnum = (Image.Type)m_Type.enumValueIndex; + + bool showSlicedOrTiled = (!m_Type.hasMultipleDifferentValues && (typeEnum == Image.Type.Sliced || typeEnum == Image.Type.Tiled)); + if (showSlicedOrTiled && targets.Length > 1) + showSlicedOrTiled = targets.Select(obj => obj as Image).All(img => img.hasBorder); + + m_ShowSlicedOrTiled.target = showSlicedOrTiled; + m_ShowSliced.target = (showSlicedOrTiled && !m_Type.hasMultipleDifferentValues && typeEnum == Image.Type.Sliced); + m_ShowTiled.target = (showSlicedOrTiled && !m_Type.hasMultipleDifferentValues && typeEnum == Image.Type.Tiled); + m_ShowFilled.target = (!m_Type.hasMultipleDifferentValues && typeEnum == Image.Type.Filled); + + Image image = target as Image; + if (EditorGUILayout.BeginFadeGroup(m_ShowSlicedOrTiled.faded)) + { + if (image.hasBorder) + EditorGUILayout.PropertyField(m_FillCenter); + } + EditorGUILayout.EndFadeGroup(); + + if (EditorGUILayout.BeginFadeGroup(m_ShowSliced.faded)) + { + if (image.sprite != null && !image.hasBorder) + EditorGUILayout.HelpBox("This Image doesn't have a border.", MessageType.Warning); + } + EditorGUILayout.EndFadeGroup(); + + if (EditorGUILayout.BeginFadeGroup(m_ShowTiled.faded)) + { + if (image.sprite != null && !image.hasBorder && (image.sprite.texture.wrapMode != TextureWrapMode.Repeat || image.sprite.packed)) + EditorGUILayout.HelpBox("It looks like you want to tile a sprite with no border. It would be more efficient to convert the Sprite to an Advanced texture, clear the Packing tag and set the Wrap mode to Repeat.", MessageType.Warning); + } + EditorGUILayout.EndFadeGroup(); + + if (EditorGUILayout.BeginFadeGroup(m_ShowFilled.faded)) + { + EditorGUI.BeginChangeCheck(); + EditorGUILayout.PropertyField(m_FillMethod); + if (EditorGUI.EndChangeCheck()) + { + m_FillOrigin.intValue = 0; + } + switch ((Image.FillMethod)m_FillMethod.enumValueIndex) + { + case Image.FillMethod.Horizontal: + m_FillOrigin.intValue = (int)(Image.OriginHorizontal)EditorGUILayout.EnumPopup("Fill Origin", (Image.OriginHorizontal)m_FillOrigin.intValue); + break; + case Image.FillMethod.Vertical: + m_FillOrigin.intValue = (int)(Image.OriginVertical)EditorGUILayout.EnumPopup("Fill Origin", (Image.OriginVertical)m_FillOrigin.intValue); + break; + case Image.FillMethod.Radial90: + m_FillOrigin.intValue = (int)(Image.Origin90)EditorGUILayout.EnumPopup("Fill Origin", (Image.Origin90)m_FillOrigin.intValue); + break; + case Image.FillMethod.Radial180: + m_FillOrigin.intValue = (int)(Image.Origin180)EditorGUILayout.EnumPopup("Fill Origin", (Image.Origin180)m_FillOrigin.intValue); + break; + case Image.FillMethod.Radial360: + m_FillOrigin.intValue = (int)(Image.Origin360)EditorGUILayout.EnumPopup("Fill Origin", (Image.Origin360)m_FillOrigin.intValue); + break; + } + EditorGUILayout.PropertyField(m_FillAmount); + if ((Image.FillMethod)m_FillMethod.enumValueIndex > Image.FillMethod.Vertical) + { + EditorGUILayout.PropertyField(m_FillClockwise, m_ClockwiseContent); + } + } + EditorGUILayout.EndFadeGroup(); + } + --EditorGUI.indentLevel; + } + + /// <summary> + /// All graphics have a preview. + /// </summary> + + public override bool HasPreviewGUI() { return true; } + + /// <summary> + /// Draw the Image preview. + /// </summary> + + public override void OnPreviewGUI(Rect rect, GUIStyle background) + { + Image image = target as Image; + if (image == null) return; + + Sprite sf = image.sprite; + if (sf == null) return; + + SpriteDrawUtility.DrawSprite(sf, rect, image.canvasRenderer.GetColor()); + } + + /// <summary> + /// Info String drawn at the bottom of the Preview + /// </summary> + + public override string GetInfoString() + { + Image image = target as Image; + Sprite sprite = image.sprite; + + int x = (sprite != null) ? Mathf.RoundToInt(sprite.rect.width) : 0; + int y = (sprite != null) ? Mathf.RoundToInt(sprite.rect.height) : 0; + + return string.Format("Image Size: {0}x{1}", x, y); + } + } +} diff --git a/Assets/uGUI-2017.1/Editor/UI/ImageEditor.cs.meta b/Assets/uGUI-2017.1/Editor/UI/ImageEditor.cs.meta new file mode 100644 index 0000000..db137d4 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/ImageEditor.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 8c5c2197b06fed749be6adac4f6a0c1c +timeCreated: 1602119379 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/Editor/UI/InputFieldEditor.cs b/Assets/uGUI-2017.1/Editor/UI/InputFieldEditor.cs new file mode 100644 index 0000000..f100f07 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/InputFieldEditor.cs @@ -0,0 +1,139 @@ +using UnityEditor.AnimatedValues; +using UnityEngine; +using UnityEngine.UI; + +namespace UnityEditor.UI +{ + [CanEditMultipleObjects] + [CustomEditor(typeof(InputField), true)] + public class InputFieldEditor : SelectableEditor + { + SerializedProperty m_TextComponent; + SerializedProperty m_Text; + SerializedProperty m_ContentType; + SerializedProperty m_LineType; + SerializedProperty m_InputType; + SerializedProperty m_CharacterValidation; + SerializedProperty m_KeyboardType; + SerializedProperty m_CharacterLimit; + SerializedProperty m_CaretBlinkRate; + SerializedProperty m_CaretWidth; + SerializedProperty m_CaretColor; + SerializedProperty m_CustomCaretColor; + SerializedProperty m_SelectionColor; + SerializedProperty m_HideMobileInput; + SerializedProperty m_Placeholder; + SerializedProperty m_OnValueChanged; + SerializedProperty m_OnEndEdit; + SerializedProperty m_ReadOnly; + + AnimBool m_CustomColor; + + protected override void OnEnable() + { + base.OnEnable(); + m_TextComponent = serializedObject.FindProperty("m_TextComponent"); + m_Text = serializedObject.FindProperty("m_Text"); + m_ContentType = serializedObject.FindProperty("m_ContentType"); + m_LineType = serializedObject.FindProperty("m_LineType"); + m_InputType = serializedObject.FindProperty("m_InputType"); + m_CharacterValidation = serializedObject.FindProperty("m_CharacterValidation"); + m_KeyboardType = serializedObject.FindProperty("m_KeyboardType"); + m_CharacterLimit = serializedObject.FindProperty("m_CharacterLimit"); + m_CaretBlinkRate = serializedObject.FindProperty("m_CaretBlinkRate"); + m_CaretWidth = serializedObject.FindProperty("m_CaretWidth"); + m_CaretColor = serializedObject.FindProperty("m_CaretColor"); + m_CustomCaretColor = serializedObject.FindProperty("m_CustomCaretColor"); + m_SelectionColor = serializedObject.FindProperty("m_SelectionColor"); + m_HideMobileInput = serializedObject.FindProperty("m_HideMobileInput"); + m_Placeholder = serializedObject.FindProperty("m_Placeholder"); + m_OnValueChanged = serializedObject.FindProperty("m_OnValueChanged"); + m_OnEndEdit = serializedObject.FindProperty("m_OnEndEdit"); + m_ReadOnly = serializedObject.FindProperty("m_ReadOnly"); + + m_CustomColor = new AnimBool(m_CustomCaretColor.boolValue); + m_CustomColor.valueChanged.AddListener(Repaint); + } + + protected override void OnDisable() + { + base.OnDisable(); + m_CustomColor.valueChanged.RemoveListener(Repaint); + } + + public override void OnInspectorGUI() + { + serializedObject.Update(); + + base.OnInspectorGUI(); + + EditorGUILayout.Space(); + + EditorGUILayout.PropertyField(m_TextComponent); + + if (m_TextComponent != null && m_TextComponent.objectReferenceValue != null) + { + Text text = m_TextComponent.objectReferenceValue as Text; + if (text.supportRichText) + { + EditorGUILayout.HelpBox("Using Rich Text with input is unsupported.", MessageType.Warning); + } + } + + using (new EditorGUI.DisabledScope(m_TextComponent == null || m_TextComponent.objectReferenceValue == null)) + { + EditorGUILayout.PropertyField(m_Text); + EditorGUILayout.PropertyField(m_CharacterLimit); + + EditorGUILayout.Space(); + + EditorGUILayout.PropertyField(m_ContentType); + if (!m_ContentType.hasMultipleDifferentValues) + { + EditorGUI.indentLevel++; + + if (m_ContentType.enumValueIndex == (int)InputField.ContentType.Standard || + m_ContentType.enumValueIndex == (int)InputField.ContentType.Autocorrected || + m_ContentType.enumValueIndex == (int)InputField.ContentType.Custom) + EditorGUILayout.PropertyField(m_LineType); + + if (m_ContentType.enumValueIndex == (int)InputField.ContentType.Custom) + { + EditorGUILayout.PropertyField(m_InputType); + EditorGUILayout.PropertyField(m_KeyboardType); + EditorGUILayout.PropertyField(m_CharacterValidation); + } + + EditorGUI.indentLevel--; + } + + EditorGUILayout.Space(); + + EditorGUILayout.PropertyField(m_Placeholder); + EditorGUILayout.PropertyField(m_CaretBlinkRate); + EditorGUILayout.PropertyField(m_CaretWidth); + + EditorGUILayout.PropertyField(m_CustomCaretColor); + + m_CustomColor.target = m_CustomCaretColor.boolValue; + + if (EditorGUILayout.BeginFadeGroup(m_CustomColor.faded)) + { + EditorGUILayout.PropertyField(m_CaretColor); + } + EditorGUILayout.EndFadeGroup(); + + EditorGUILayout.PropertyField(m_SelectionColor); + EditorGUILayout.PropertyField(m_HideMobileInput); + EditorGUILayout.PropertyField(m_ReadOnly); + + EditorGUILayout.Space(); + + EditorGUILayout.PropertyField(m_OnValueChanged); + EditorGUILayout.PropertyField(m_OnEndEdit); + } + + serializedObject.ApplyModifiedProperties(); + } + } +} diff --git a/Assets/uGUI-2017.1/Editor/UI/InputFieldEditor.cs.meta b/Assets/uGUI-2017.1/Editor/UI/InputFieldEditor.cs.meta new file mode 100644 index 0000000..961284b --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/InputFieldEditor.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 2c23aeb09974d4c41b3e2157285f204c +timeCreated: 1602119378 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/Editor/UI/InterceptedEventsPreview.cs b/Assets/uGUI-2017.1/Editor/UI/InterceptedEventsPreview.cs new file mode 100644 index 0000000..b02e37e --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/InterceptedEventsPreview.cs @@ -0,0 +1,304 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using UnityEngine; +using UnityEngine.Profiling; +using UnityEngine.EventSystems; + +namespace UnityEditor.Events +{ + [CustomPreview(typeof(GameObject))] + class InterceptedEventsPreview : ObjectPreview + { + protected class ComponentInterceptedEvents + { + public GUIContent componentName; + public int[] interceptedEvents; + } + + class Styles + { + public GUIStyle labelStyle = new GUIStyle(EditorStyles.label); + public GUIStyle componentName = new GUIStyle(EditorStyles.boldLabel); + + public Styles() + { + Color fontColor = new Color(0.7f, 0.7f, 0.7f); + labelStyle.padding.right += 20; + labelStyle.normal.textColor = fontColor; + labelStyle.active.textColor = fontColor; + labelStyle.focused.textColor = fontColor; + labelStyle.hover.textColor = fontColor; + labelStyle.onNormal.textColor = fontColor; + labelStyle.onActive.textColor = fontColor; + labelStyle.onFocused.textColor = fontColor; + labelStyle.onHover.textColor = fontColor; + + componentName.normal.textColor = fontColor; + componentName.active.textColor = fontColor; + componentName.focused.textColor = fontColor; + componentName.hover.textColor = fontColor; + componentName.onNormal.textColor = fontColor; + componentName.onActive.textColor = fontColor; + componentName.onFocused.textColor = fontColor; + componentName.onHover.textColor = fontColor; + } + } + + private Dictionary<GameObject, List<ComponentInterceptedEvents>> m_TargetEvents; + private bool m_InterceptsAnyEvent = false; + private GUIContent m_Title; + private Styles m_Styles = new Styles(); + + public override void Initialize(UnityEngine.Object[] targets) + { + Profiler.BeginSample("ComponentInterceptedEvents.Initialize"); + + base.Initialize(targets); + m_TargetEvents = new Dictionary<GameObject, List<ComponentInterceptedEvents>>(targets.Count()); + m_InterceptsAnyEvent = false; + for (int i = 0; i < targets.Length; ++i) + { + GameObject go = targets[i] as GameObject; + List<ComponentInterceptedEvents> interceptedEvents = GetEventsInfo(go); + m_TargetEvents.Add(go, interceptedEvents); + if (interceptedEvents.Any()) + m_InterceptsAnyEvent = true; + } + Profiler.EndSample(); + } + + public override GUIContent GetPreviewTitle() + { + if (m_Title == null) + { + m_Title = new GUIContent("Intercepted Events"); + } + return m_Title; + } + + public override bool HasPreviewGUI() + { + return m_TargetEvents != null && m_InterceptsAnyEvent; + } + + public override void OnPreviewGUI(Rect r, GUIStyle background) + { + if (Event.current.type != EventType.Repaint) + return; + Profiler.BeginSample("InterceptedEventsPreview.OnPreviewGUI"); + + + if (m_Styles == null) + m_Styles = new Styles(); + + Vector2 maxEventLabelSize = Vector2.zero; + int totalInterceptedEvents = 0; + + List<ComponentInterceptedEvents> componentIncerceptedEvents = m_TargetEvents[target as GameObject]; + + // Find out the maximum size needed for any given label. + foreach (ComponentInterceptedEvents componentInterceptedEvents in componentIncerceptedEvents) + { + foreach (int eventIndex in componentInterceptedEvents.interceptedEvents) + { + GUIContent eventContent = s_PossibleEvents[eventIndex]; + ++totalInterceptedEvents; + Vector2 labelSize = m_Styles.labelStyle.CalcSize(eventContent); + if (maxEventLabelSize.x < labelSize.x) + { + maxEventLabelSize.x = labelSize.x; + } + if (maxEventLabelSize.y < labelSize.y) + { + maxEventLabelSize.y = labelSize.y; + } + } + } + + // Apply padding + RectOffset previewPadding = new RectOffset(-5, -5, -5, -5); + r = previewPadding.Add(r); + + // Figure out how many rows and columns we can/should have + int columns = Mathf.Max(Mathf.FloorToInt(r.width / maxEventLabelSize.x), 1); + int rows = Mathf.Max(totalInterceptedEvents / columns, 1) + componentIncerceptedEvents.Count; + + // Centering + float initialX = r.x + Mathf.Max(0, (r.width - (maxEventLabelSize.x * columns)) / 2); + float initialY = r.y + Mathf.Max(0, (r.height - (maxEventLabelSize.y * rows)) / 2); + + Rect labelRect = new Rect(initialX, initialY, maxEventLabelSize.x, maxEventLabelSize.y); + int currentColumn = 0; + foreach (ComponentInterceptedEvents componentInterceptedEvents in componentIncerceptedEvents) + { + GUI.Label(labelRect, componentInterceptedEvents.componentName, m_Styles.componentName); + labelRect.y += labelRect.height; + labelRect.x = initialX; + foreach (int eventIndex in componentInterceptedEvents.interceptedEvents) + { + GUIContent eventContent = s_PossibleEvents[eventIndex]; + GUI.Label(labelRect, eventContent, m_Styles.labelStyle); + if (currentColumn < columns - 1) + { + labelRect.x += labelRect.width; + } + else + { + labelRect.y += labelRect.height; + labelRect.x = initialX; + } + + currentColumn = (currentColumn + 1) % columns; + } + + if (labelRect.x != initialX) + { + labelRect.y += labelRect.height; + labelRect.x = initialX; + } + } + Profiler.EndSample(); + } + + //Lookup cache to avoid recalculating which types uses which events: + //Caches all interfaces that inherit from IEventSystemHandler + static List<Type> s_EventSystemInterfaces = null; + //Caches all GUIContents in a single list to avoid creating too much GUIContent and strings. + private static List<GUIContent> s_PossibleEvents = null; + //Caches all events used by each interface + static Dictionary<Type, List<int>> s_InterfaceEventSystemEvents = null; + //Caches each concrete type and it's events + static readonly Dictionary<Type, ComponentInterceptedEvents> s_ComponentEvents2 = new Dictionary<Type, ComponentInterceptedEvents>(); + + + protected static List<ComponentInterceptedEvents> GetEventsInfo(GameObject gameObject) + { + InitializeEvetnsInterfaceCacheIfNeeded(); + + List<ComponentInterceptedEvents> componentEvents = new List<ComponentInterceptedEvents>(); + + MonoBehaviour[] mbs = gameObject.GetComponents<MonoBehaviour>(); + + for (int i = 0, imax = mbs.Length; i < imax; ++i) + { + ComponentInterceptedEvents componentEvent = null; + + MonoBehaviour mb = mbs[i]; + if (mb == null) + continue; + + Type type = mb.GetType(); + + if (!s_ComponentEvents2.ContainsKey(type)) + { + List<int> events = null; + Profiler.BeginSample("ComponentInterceptedEvents.GetEventsInfo.NewType"); + if (typeof(IEventSystemHandler).IsAssignableFrom(type)) + { + for (int index = 0; index < s_EventSystemInterfaces.Count; index++) + { + var eventInterface = s_EventSystemInterfaces[index]; + if (!eventInterface.IsAssignableFrom(type)) + continue; + + if (events == null) + events = new List<int>(); + + events.AddRange(s_InterfaceEventSystemEvents[eventInterface]); + } + } + + if (events != null) + { + componentEvent = new ComponentInterceptedEvents(); + componentEvent.componentName = new GUIContent(type.Name); + componentEvent.interceptedEvents = events.OrderBy(index => s_PossibleEvents[index].text).ToArray(); + } + s_ComponentEvents2.Add(type, componentEvent); + + Profiler.EndSample(); + } + else + { + componentEvent = s_ComponentEvents2[type]; + } + + + if (componentEvent != null) + { + componentEvents.Add(componentEvent); + } + } + + return componentEvents; + } + + private static void InitializeEvetnsInterfaceCacheIfNeeded() + { + if (s_EventSystemInterfaces != null) + return; + + s_EventSystemInterfaces = new List<Type>(); + s_PossibleEvents = new List<GUIContent>(); + s_InterfaceEventSystemEvents = new Dictionary<Type, List<int>>(); + + foreach (var type in GetAccessibleTypesInLoadedAssemblies()) + { + if (!type.IsInterface) + continue; + + if (!typeof(IEventSystemHandler).IsAssignableFrom(type)) + continue; + + s_EventSystemInterfaces.Add(type); + List<int> eventIndexList = new List<int>(); + + MethodInfo[] methodInfos = type.GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); + for (int mi = 0; mi < methodInfos.Length; mi++) + { + MethodInfo methodInfo = methodInfos[mi]; + eventIndexList.Add(s_PossibleEvents.Count); + s_PossibleEvents.Add(new GUIContent(methodInfo.Name)); + } + s_InterfaceEventSystemEvents.Add(type, eventIndexList); + } + } + + private static IEnumerable<Type> GetAccessibleTypesInLoadedAssemblies() + { + var assemblies = AppDomain.CurrentDomain.GetAssemblies(); + for (var i = 0; i < assemblies.Length; ++i) + { + Type[] types; + var assembly = assemblies[i]; + + if (assembly == null) + continue; + + try + { + types = assembly.GetTypes(); + } + catch (ReflectionTypeLoadException e) + { + // assembly.GetTypes() might fail in case the Assembly cannot resolve all its references, + // or in case it was built targetting a newer version of .NET. + // In case the resolution fails for some types, we can still access the ones that have been + // properly loaded. + types = e.Types; + } + + for (var j = 0; j < types.Length; ++j) + { + var type = types[j]; + if (type == null) + continue; + + yield return type; + } + } + } + } +} diff --git a/Assets/uGUI-2017.1/Editor/UI/InterceptedEventsPreview.cs.meta b/Assets/uGUI-2017.1/Editor/UI/InterceptedEventsPreview.cs.meta new file mode 100644 index 0000000..6b1ac00 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/InterceptedEventsPreview.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: d8a1fb8949afd2b4a89786a167d4efbe +timeCreated: 1602119380 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/Editor/UI/LayoutElementEditor.cs b/Assets/uGUI-2017.1/Editor/UI/LayoutElementEditor.cs new file mode 100644 index 0000000..ac80f5a --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/LayoutElementEditor.cs @@ -0,0 +1,102 @@ +using UnityEngine; +using UnityEngine.UI; +using UnityEditorInternal; +using UnityEditor.AnimatedValues; + +namespace UnityEditor.UI +{ + [CustomEditor(typeof(LayoutElement), true)] + [CanEditMultipleObjects] + public class LayoutElementEditor : Editor + { + SerializedProperty m_IgnoreLayout; + SerializedProperty m_MinWidth; + SerializedProperty m_MinHeight; + SerializedProperty m_PreferredWidth; + SerializedProperty m_PreferredHeight; + SerializedProperty m_FlexibleWidth; + SerializedProperty m_FlexibleHeight; + SerializedProperty m_LayoutPriority; + + protected virtual void OnEnable() + { + m_IgnoreLayout = serializedObject.FindProperty("m_IgnoreLayout"); + m_MinWidth = serializedObject.FindProperty("m_MinWidth"); + m_MinHeight = serializedObject.FindProperty("m_MinHeight"); + m_PreferredWidth = serializedObject.FindProperty("m_PreferredWidth"); + m_PreferredHeight = serializedObject.FindProperty("m_PreferredHeight"); + m_FlexibleWidth = serializedObject.FindProperty("m_FlexibleWidth"); + m_FlexibleHeight = serializedObject.FindProperty("m_FlexibleHeight"); + m_LayoutPriority = serializedObject.FindProperty("m_LayoutPriority"); + } + + public override void OnInspectorGUI() + { + serializedObject.Update(); + + EditorGUILayout.PropertyField(m_IgnoreLayout); + + if (!m_IgnoreLayout.boolValue) + { + EditorGUILayout.Space(); + + LayoutElementField(m_MinWidth, 0); + LayoutElementField(m_MinHeight, 0); + LayoutElementField(m_PreferredWidth, t => t.rect.width); + LayoutElementField(m_PreferredHeight, t => t.rect.height); + LayoutElementField(m_FlexibleWidth, 1); + LayoutElementField(m_FlexibleHeight, 1); + } + + EditorGUILayout.PropertyField(m_LayoutPriority); + + serializedObject.ApplyModifiedProperties(); + } + + void LayoutElementField(SerializedProperty property, float defaultValue) + { + LayoutElementField(property, _ => defaultValue); + } + + void LayoutElementField(SerializedProperty property, System.Func<RectTransform, float> defaultValue) + { + Rect position = EditorGUILayout.GetControlRect(); + + // Label + GUIContent label = EditorGUI.BeginProperty(position, null, property); + + // Rects + Rect fieldPosition = EditorGUI.PrefixLabel(position, label); + + Rect toggleRect = fieldPosition; + toggleRect.width = 16; + + Rect floatFieldRect = fieldPosition; + floatFieldRect.xMin += 16; + + // Checkbox + EditorGUI.BeginChangeCheck(); + bool enabled = EditorGUI.ToggleLeft(toggleRect, GUIContent.none, property.floatValue >= 0); + if (EditorGUI.EndChangeCheck()) + { + // This could be made better to set all of the targets to their initial width, but mimizing code change for now + property.floatValue = (enabled ? defaultValue((target as LayoutElement).transform as RectTransform) : -1); + } + + if (!property.hasMultipleDifferentValues && property.floatValue >= 0) + { + // Float field + EditorGUIUtility.labelWidth = 4; // Small invisible label area for drag zone functionality + EditorGUI.BeginChangeCheck(); + float newValue = EditorGUI.FloatField(floatFieldRect, new GUIContent(" "), property.floatValue); + if (EditorGUI.EndChangeCheck()) + { + property.floatValue = Mathf.Max(0, newValue); + } + EditorGUIUtility.labelWidth = 0; + } + + EditorGUI.EndProperty(); + } + } +} diff --git a/Assets/uGUI-2017.1/Editor/UI/LayoutElementEditor.cs.meta b/Assets/uGUI-2017.1/Editor/UI/LayoutElementEditor.cs.meta new file mode 100644 index 0000000..8744d62 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/LayoutElementEditor.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: ffcef66c44c6c174eb838804dcaab7f0 +timeCreated: 1602119380 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/Editor/UI/LayoutPropertiesPreview.cs b/Assets/uGUI-2017.1/Editor/UI/LayoutPropertiesPreview.cs new file mode 100644 index 0000000..6f93c98 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/LayoutPropertiesPreview.cs @@ -0,0 +1,123 @@ +using System.Collections.Generic; +using System.Linq; +using UnityEngine; +using UnityEngine.UI; + +namespace UnityEditor.Events +{ + [CustomPreview(typeof(GameObject))] + class LayoutPropertiesPreview : ObjectPreview + { + private const float kLabelWidth = 110; + private const float kValueWidth = 100; + + class Styles + { + public GUIStyle labelStyle = new GUIStyle(EditorStyles.label); + public GUIStyle headerStyle = new GUIStyle(EditorStyles.boldLabel); + + public Styles() + { + Color fontColor = new Color(0.7f, 0.7f, 0.7f); + labelStyle.padding.right += 4; + labelStyle.normal.textColor = fontColor; + headerStyle.padding.right += 4; + headerStyle.normal.textColor = fontColor; + } + } + + private GUIContent m_Title; + private Styles m_Styles = new Styles(); + + public override void Initialize(UnityEngine.Object[] targets) + { + base.Initialize(targets); + } + + public override GUIContent GetPreviewTitle() + { + if (m_Title == null) + { + m_Title = new GUIContent("Layout Properties"); + } + return m_Title; + } + + public override bool HasPreviewGUI() + { + GameObject go = target as GameObject; + if (!go) + return false; + return go.GetComponent(typeof(ILayoutElement)) != null; + } + + public override void OnPreviewGUI(Rect r, GUIStyle background) + { + if (Event.current.type != EventType.Repaint) + return; + + if (m_Styles == null) + m_Styles = new Styles(); + + GameObject go = target as GameObject; + RectTransform rect = go.transform as RectTransform; + if (rect == null) + return; + + // Apply padding + RectOffset previewPadding = new RectOffset(-5, -5, -5, -5); + r = previewPadding.Add(r); + + // Prepare rects for columns + r.height = EditorGUIUtility.singleLineHeight; + Rect labelRect = r; + Rect valueRect = r; + Rect sourceRect = r; + labelRect.width = kLabelWidth; + valueRect.xMin += kLabelWidth; + valueRect.width = kValueWidth; + sourceRect.xMin += kLabelWidth + kValueWidth; + + // Headers + GUI.Label(labelRect, "Property", m_Styles.headerStyle); + GUI.Label(valueRect, "Value", m_Styles.headerStyle); + GUI.Label(sourceRect, "Source", m_Styles.headerStyle); + labelRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; + valueRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; + sourceRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; + + // Prepare reusable variable for out argument + ILayoutElement source = null; + + // Show properties + + ShowProp(ref labelRect, ref valueRect, ref sourceRect, "Min Width", LayoutUtility.GetLayoutProperty(rect, e => e.minWidth, 0, out source).ToString(), source); + ShowProp(ref labelRect, ref valueRect, ref sourceRect, "Min Height", LayoutUtility.GetLayoutProperty(rect, e => e.minHeight, 0, out source).ToString(), source); + ShowProp(ref labelRect, ref valueRect, ref sourceRect, "Preferred Width", LayoutUtility.GetLayoutProperty(rect, e => e.preferredWidth, 0, out source).ToString(), source); + ShowProp(ref labelRect, ref valueRect, ref sourceRect, "Preferred Height", LayoutUtility.GetLayoutProperty(rect, e => e.preferredHeight, 0, out source).ToString(), source); + + float flexible = 0; + + flexible = LayoutUtility.GetLayoutProperty(rect, e => e.flexibleWidth, 0, out source); + ShowProp(ref labelRect, ref valueRect, ref sourceRect, "Flexible Width", flexible > 0 ? ("enabled (" + flexible.ToString() + ")") : "disabled", source); + flexible = LayoutUtility.GetLayoutProperty(rect, e => e.flexibleHeight, 0, out source); + ShowProp(ref labelRect, ref valueRect, ref sourceRect, "Flexible Height", flexible > 0 ? ("enabled (" + flexible.ToString() + ")") : "disabled", source); + + if (!rect.GetComponent<LayoutElement>()) + { + Rect noteRect = new Rect(labelRect.x, labelRect.y + 10, r.width, EditorGUIUtility.singleLineHeight); + GUI.Label(noteRect, "Add a LayoutElement to override values.", m_Styles.labelStyle); + } + } + + private void ShowProp(ref Rect labelRect, ref Rect valueRect, ref Rect sourceRect, string label, string value, ILayoutElement source) + { + GUI.Label(labelRect, label, m_Styles.labelStyle); + GUI.Label(valueRect, value, m_Styles.labelStyle); + GUI.Label(sourceRect, source == null ? "none" : source.GetType().Name, m_Styles.labelStyle); + labelRect.y += EditorGUIUtility.singleLineHeight; + valueRect.y += EditorGUIUtility.singleLineHeight; + sourceRect.y += EditorGUIUtility.singleLineHeight; + } + } +} diff --git a/Assets/uGUI-2017.1/Editor/UI/LayoutPropertiesPreview.cs.meta b/Assets/uGUI-2017.1/Editor/UI/LayoutPropertiesPreview.cs.meta new file mode 100644 index 0000000..20eb908 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/LayoutPropertiesPreview.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: f103303bf9c7f654492f77f00631a1be +timeCreated: 1602119380 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/Editor/UI/MaskEditor.cs b/Assets/uGUI-2017.1/Editor/UI/MaskEditor.cs new file mode 100644 index 0000000..8a1a486 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/MaskEditor.cs @@ -0,0 +1,28 @@ +using UnityEngine.UI; + +namespace UnityEditor.UI +{ + [CustomEditor(typeof(Mask), true)] + [CanEditMultipleObjects] + public class MaskEditor : Editor + { + SerializedProperty m_ShowMaskGraphic; + + protected virtual void OnEnable() + { + m_ShowMaskGraphic = serializedObject.FindProperty("m_ShowMaskGraphic"); + } + + public override void OnInspectorGUI() + { + var graphic = (target as Mask).GetComponent<Graphic>(); + + if (graphic && !graphic.IsActive()) + EditorGUILayout.HelpBox("Masking disabled due to Graphic component being disabled.", MessageType.Warning); + + serializedObject.Update(); + EditorGUILayout.PropertyField(m_ShowMaskGraphic); + serializedObject.ApplyModifiedProperties(); + } + } +} diff --git a/Assets/uGUI-2017.1/Editor/UI/MaskEditor.cs.meta b/Assets/uGUI-2017.1/Editor/UI/MaskEditor.cs.meta new file mode 100644 index 0000000..925cbdf --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/MaskEditor.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 764bee73159c4d443a00c1c3788a3be9 +timeCreated: 1602119379 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/Editor/UI/MenuOptions.cs b/Assets/uGUI-2017.1/Editor/UI/MenuOptions.cs new file mode 100644 index 0000000..94d0016 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/MenuOptions.cs @@ -0,0 +1,282 @@ +using UnityEngine; +using UnityEngine.EventSystems; +using UnityEngine.UI; + +namespace UnityEditor.UI +{ + /// <summary> + /// This script adds the UI menu options to the Unity Editor. + /// </summary> + + static internal class MenuOptions + { + private const string kUILayerName = "UI"; + + private const string kStandardSpritePath = "UI/Skin/UISprite.psd"; + private const string kBackgroundSpritePath = "UI/Skin/Background.psd"; + private const string kInputFieldBackgroundPath = "UI/Skin/InputFieldBackground.psd"; + private const string kKnobPath = "UI/Skin/Knob.psd"; + private const string kCheckmarkPath = "UI/Skin/Checkmark.psd"; + private const string kDropdownArrowPath = "UI/Skin/DropdownArrow.psd"; + private const string kMaskPath = "UI/Skin/UIMask.psd"; + + static private DefaultControls.Resources s_StandardResources; + + static private DefaultControls.Resources GetStandardResources() + { + if (s_StandardResources.standard == null) + { + s_StandardResources.standard = AssetDatabase.GetBuiltinExtraResource<Sprite>(kStandardSpritePath); + s_StandardResources.background = AssetDatabase.GetBuiltinExtraResource<Sprite>(kBackgroundSpritePath); + s_StandardResources.inputField = AssetDatabase.GetBuiltinExtraResource<Sprite>(kInputFieldBackgroundPath); + s_StandardResources.knob = AssetDatabase.GetBuiltinExtraResource<Sprite>(kKnobPath); + s_StandardResources.checkmark = AssetDatabase.GetBuiltinExtraResource<Sprite>(kCheckmarkPath); + s_StandardResources.dropdown = AssetDatabase.GetBuiltinExtraResource<Sprite>(kDropdownArrowPath); + s_StandardResources.mask = AssetDatabase.GetBuiltinExtraResource<Sprite>(kMaskPath); + } + return s_StandardResources; + } + + private static void SetPositionVisibleinSceneView(RectTransform canvasRTransform, RectTransform itemTransform) + { + // Find the best scene view + SceneView sceneView = SceneView.lastActiveSceneView; + if (sceneView == null && SceneView.sceneViews.Count > 0) + sceneView = SceneView.sceneViews[0] as SceneView; + + // Couldn't find a SceneView. Don't set position. + if (sceneView == null || sceneView.camera == null) + return; + + // Create world space Plane from canvas position. + Vector2 localPlanePosition; + Camera camera = sceneView.camera; + Vector3 position = Vector3.zero; + if (RectTransformUtility.ScreenPointToLocalPointInRectangle(canvasRTransform, new Vector2(camera.pixelWidth / 2, camera.pixelHeight / 2), camera, out localPlanePosition)) + { + // Adjust for canvas pivot + localPlanePosition.x = localPlanePosition.x + canvasRTransform.sizeDelta.x * canvasRTransform.pivot.x; + localPlanePosition.y = localPlanePosition.y + canvasRTransform.sizeDelta.y * canvasRTransform.pivot.y; + + localPlanePosition.x = Mathf.Clamp(localPlanePosition.x, 0, canvasRTransform.sizeDelta.x); + localPlanePosition.y = Mathf.Clamp(localPlanePosition.y, 0, canvasRTransform.sizeDelta.y); + + // Adjust for anchoring + position.x = localPlanePosition.x - canvasRTransform.sizeDelta.x * itemTransform.anchorMin.x; + position.y = localPlanePosition.y - canvasRTransform.sizeDelta.y * itemTransform.anchorMin.y; + + Vector3 minLocalPosition; + minLocalPosition.x = canvasRTransform.sizeDelta.x * (0 - canvasRTransform.pivot.x) + itemTransform.sizeDelta.x * itemTransform.pivot.x; + minLocalPosition.y = canvasRTransform.sizeDelta.y * (0 - canvasRTransform.pivot.y) + itemTransform.sizeDelta.y * itemTransform.pivot.y; + + Vector3 maxLocalPosition; + maxLocalPosition.x = canvasRTransform.sizeDelta.x * (1 - canvasRTransform.pivot.x) - itemTransform.sizeDelta.x * itemTransform.pivot.x; + maxLocalPosition.y = canvasRTransform.sizeDelta.y * (1 - canvasRTransform.pivot.y) - itemTransform.sizeDelta.y * itemTransform.pivot.y; + + position.x = Mathf.Clamp(position.x, minLocalPosition.x, maxLocalPosition.x); + position.y = Mathf.Clamp(position.y, minLocalPosition.y, maxLocalPosition.y); + } + + itemTransform.anchoredPosition = position; + itemTransform.localRotation = Quaternion.identity; + itemTransform.localScale = Vector3.one; + } + + private static void PlaceUIElementRoot(GameObject element, MenuCommand menuCommand) + { + GameObject parent = menuCommand.context as GameObject; + if (parent == null || parent.GetComponentInParent<Canvas>() == null) + { + parent = GetOrCreateCanvasGameObject(); + } + + string uniqueName = GameObjectUtility.GetUniqueNameForSibling(parent.transform, element.name); + element.name = uniqueName; + Undo.RegisterCreatedObjectUndo(element, "Create " + element.name); + Undo.SetTransformParent(element.transform, parent.transform, "Parent " + element.name); + GameObjectUtility.SetParentAndAlign(element, parent); + if (parent != menuCommand.context) // not a context click, so center in sceneview + SetPositionVisibleinSceneView(parent.GetComponent<RectTransform>(), element.GetComponent<RectTransform>()); + + Selection.activeGameObject = element; + } + + // Graphic elements + + [MenuItem("GameObject/UI/Text", false, 2000)] + static public void AddText(MenuCommand menuCommand) + { + GameObject go = DefaultControls.CreateText(GetStandardResources()); + PlaceUIElementRoot(go, menuCommand); + } + + [MenuItem("GameObject/UI/Image", false, 2001)] + static public void AddImage(MenuCommand menuCommand) + { + GameObject go = DefaultControls.CreateImage(GetStandardResources()); + PlaceUIElementRoot(go, menuCommand); + } + + [MenuItem("GameObject/UI/Raw Image", false, 2002)] + static public void AddRawImage(MenuCommand menuCommand) + { + GameObject go = DefaultControls.CreateRawImage(GetStandardResources()); + PlaceUIElementRoot(go, menuCommand); + } + + // Controls + + // Button and toggle are controls you just click on. + + [MenuItem("GameObject/UI/Button", false, 2030)] + static public void AddButton(MenuCommand menuCommand) + { + GameObject go = DefaultControls.CreateButton(GetStandardResources()); + PlaceUIElementRoot(go, menuCommand); + } + + [MenuItem("GameObject/UI/Toggle", false, 2031)] + static public void AddToggle(MenuCommand menuCommand) + { + GameObject go = DefaultControls.CreateToggle(GetStandardResources()); + PlaceUIElementRoot(go, menuCommand); + } + + // Slider and Scrollbar modify a number + + [MenuItem("GameObject/UI/Slider", false, 2033)] + static public void AddSlider(MenuCommand menuCommand) + { + GameObject go = DefaultControls.CreateSlider(GetStandardResources()); + PlaceUIElementRoot(go, menuCommand); + } + + [MenuItem("GameObject/UI/Scrollbar", false, 2034)] + static public void AddScrollbar(MenuCommand menuCommand) + { + GameObject go = DefaultControls.CreateScrollbar(GetStandardResources()); + PlaceUIElementRoot(go, menuCommand); + } + + // More advanced controls below + + [MenuItem("GameObject/UI/Dropdown", false, 2035)] + static public void AddDropdown(MenuCommand menuCommand) + { + GameObject go = DefaultControls.CreateDropdown(GetStandardResources()); + PlaceUIElementRoot(go, menuCommand); + } + + [MenuItem("GameObject/UI/Input Field", false, 2036)] + public static void AddInputField(MenuCommand menuCommand) + { + GameObject go = DefaultControls.CreateInputField(GetStandardResources()); + PlaceUIElementRoot(go, menuCommand); + } + + // Containers + + [MenuItem("GameObject/UI/Canvas", false, 2060)] + static public void AddCanvas(MenuCommand menuCommand) + { + var go = CreateNewUI(); + GameObjectUtility.SetParentAndAlign(go, menuCommand.context as GameObject); + if (go.transform.parent as RectTransform) + { + RectTransform rect = go.transform as RectTransform; + rect.anchorMin = Vector2.zero; + rect.anchorMax = Vector2.one; + rect.anchoredPosition = Vector2.zero; + rect.sizeDelta = Vector2.zero; + } + Selection.activeGameObject = go; + } + + [MenuItem("GameObject/UI/Panel", false, 2061)] + static public void AddPanel(MenuCommand menuCommand) + { + GameObject go = DefaultControls.CreatePanel(GetStandardResources()); + PlaceUIElementRoot(go, menuCommand); + + // Panel is special, we need to ensure there's no padding after repositioning. + RectTransform rect = go.GetComponent<RectTransform>(); + rect.anchoredPosition = Vector2.zero; + rect.sizeDelta = Vector2.zero; + } + + [MenuItem("GameObject/UI/Scroll View", false, 2062)] + static public void AddScrollView(MenuCommand menuCommand) + { + GameObject go = DefaultControls.CreateScrollView(GetStandardResources()); + PlaceUIElementRoot(go, menuCommand); + } + + // Helper methods + + static public GameObject CreateNewUI() + { + // Root for the UI + var root = new GameObject("Canvas"); + root.layer = LayerMask.NameToLayer(kUILayerName); + Canvas canvas = root.AddComponent<Canvas>(); + canvas.renderMode = RenderMode.ScreenSpaceOverlay; + root.AddComponent<CanvasScaler>(); + root.AddComponent<GraphicRaycaster>(); + Undo.RegisterCreatedObjectUndo(root, "Create " + root.name); + + // if there is no event system add one... + CreateEventSystem(false); + return root; + } + + [MenuItem("GameObject/UI/Event System", false, 2100)] + public static void CreateEventSystem(MenuCommand menuCommand) + { + GameObject parent = menuCommand.context as GameObject; + CreateEventSystem(true, parent); + } + + private static void CreateEventSystem(bool select) + { + CreateEventSystem(select, null); + } + + private static void CreateEventSystem(bool select, GameObject parent) + { + var esys = Object.FindObjectOfType<EventSystem>(); + if (esys == null) + { + var eventSystem = new GameObject("EventSystem"); + GameObjectUtility.SetParentAndAlign(eventSystem, parent); + esys = eventSystem.AddComponent<EventSystem>(); + eventSystem.AddComponent<StandaloneInputModule>(); + + Undo.RegisterCreatedObjectUndo(eventSystem, "Create " + eventSystem.name); + } + + if (select && esys != null) + { + Selection.activeGameObject = esys.gameObject; + } + } + + // Helper function that returns a Canvas GameObject; preferably a parent of the selection, or other existing Canvas. + static public GameObject GetOrCreateCanvasGameObject() + { + GameObject selectedGo = Selection.activeGameObject; + + // Try to find a gameobject that is the selected GO or one if its parents. + Canvas canvas = (selectedGo != null) ? selectedGo.GetComponentInParent<Canvas>() : null; + if (canvas != null && canvas.gameObject.activeInHierarchy) + return canvas.gameObject; + + // No canvas in selection or its parents? Then use just any canvas.. + canvas = Object.FindObjectOfType(typeof(Canvas)) as Canvas; + if (canvas != null && canvas.gameObject.activeInHierarchy) + return canvas.gameObject; + + // No canvas in the scene at all? Then create a new one. + return MenuOptions.CreateNewUI(); + } + } +} diff --git a/Assets/uGUI-2017.1/Editor/UI/MenuOptions.cs.meta b/Assets/uGUI-2017.1/Editor/UI/MenuOptions.cs.meta new file mode 100644 index 0000000..17aac1f --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/MenuOptions.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: a30d9ac75138f9e45811070c267b929d +timeCreated: 1602119379 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/Editor/UI/PrefabLayoutRebuilder.cs b/Assets/uGUI-2017.1/Editor/UI/PrefabLayoutRebuilder.cs new file mode 100644 index 0000000..0f933da --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/PrefabLayoutRebuilder.cs @@ -0,0 +1,24 @@ +using UnityEngine; +using UnityEngine.UI; + +namespace UnityEditor.UI +{ + [InitializeOnLoad] + internal class PrefabLayoutRebuilder + { + static PrefabLayoutRebuilder() + { + PrefabUtility.prefabInstanceUpdated += OnPrefabInstanceUpdates; + } + + static void OnPrefabInstanceUpdates(GameObject instance) + { + if (instance) + { + RectTransform rect = instance.transform as RectTransform; + if (rect) + LayoutRebuilder.MarkLayoutForRebuild(rect); + } + } + } +} diff --git a/Assets/uGUI-2017.1/Editor/UI/PrefabLayoutRebuilder.cs.meta b/Assets/uGUI-2017.1/Editor/UI/PrefabLayoutRebuilder.cs.meta new file mode 100644 index 0000000..435b8d5 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/PrefabLayoutRebuilder.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 258eff23cc7cc4a4888c4570caabda7c +timeCreated: 1602119377 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/Editor/UI/PropertyDrawers.meta b/Assets/uGUI-2017.1/Editor/UI/PropertyDrawers.meta new file mode 100644 index 0000000..5514f30 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/PropertyDrawers.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: f6033d0a1e14b0f4f81e73060756cf38 +folderAsset: yes +timeCreated: 1602119280 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/AnimationTriggersDrawer.cs b/Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/AnimationTriggersDrawer.cs new file mode 100644 index 0000000..67cab2e --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/AnimationTriggersDrawer.cs @@ -0,0 +1,33 @@ +using UnityEngine; +using UnityEngine.UI; + +namespace UnityEditor.UI +{ + [CustomPropertyDrawer(typeof(AnimationTriggers), true)] + public class AnimationTriggersDrawer : PropertyDrawer + { + public override void OnGUI(Rect rect, SerializedProperty prop, GUIContent label) + { + Rect drawRect = rect; + drawRect.height = EditorGUIUtility.singleLineHeight; + + SerializedProperty normalTrigger = prop.FindPropertyRelative("m_NormalTrigger"); + SerializedProperty higlightedTrigger = prop.FindPropertyRelative("m_HighlightedTrigger"); + SerializedProperty pressedTrigger = prop.FindPropertyRelative("m_PressedTrigger"); + SerializedProperty disabledTrigger = prop.FindPropertyRelative("m_DisabledTrigger"); + + EditorGUI.PropertyField(drawRect, normalTrigger); + drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; + EditorGUI.PropertyField(drawRect, higlightedTrigger); + drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; + EditorGUI.PropertyField(drawRect, pressedTrigger); + drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; + EditorGUI.PropertyField(drawRect, disabledTrigger); + } + + public override float GetPropertyHeight(SerializedProperty prop, GUIContent label) + { + return 4 * EditorGUIUtility.singleLineHeight + 3 * EditorGUIUtility.standardVerticalSpacing; + } + } +} diff --git a/Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/AnimationTriggersDrawer.cs.meta b/Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/AnimationTriggersDrawer.cs.meta new file mode 100644 index 0000000..f9df6cc --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/AnimationTriggersDrawer.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: c7e8a036dae779446aa880079e2fcd93 +timeCreated: 1602119380 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/ColorBlockDrawer.cs b/Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/ColorBlockDrawer.cs new file mode 100644 index 0000000..a471eeb --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/ColorBlockDrawer.cs @@ -0,0 +1,39 @@ +using UnityEngine; +using UnityEngine.UI; + +namespace UnityEditor.UI +{ + [CustomPropertyDrawer(typeof(ColorBlock), true)] + public class ColorBlockDrawer : PropertyDrawer + { + public override void OnGUI(Rect rect, SerializedProperty prop, GUIContent label) + { + Rect drawRect = rect; + drawRect.height = EditorGUIUtility.singleLineHeight; + + SerializedProperty normalColor = prop.FindPropertyRelative("m_NormalColor"); + SerializedProperty highlighted = prop.FindPropertyRelative("m_HighlightedColor"); + SerializedProperty pressedColor = prop.FindPropertyRelative("m_PressedColor"); + SerializedProperty disabledColor = prop.FindPropertyRelative("m_DisabledColor"); + SerializedProperty colorMultiplier = prop.FindPropertyRelative("m_ColorMultiplier"); + SerializedProperty fadeDuration = prop.FindPropertyRelative("m_FadeDuration"); + + EditorGUI.PropertyField(drawRect, normalColor); + drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; + EditorGUI.PropertyField(drawRect, highlighted); + drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; + EditorGUI.PropertyField(drawRect, pressedColor); + drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; + EditorGUI.PropertyField(drawRect, disabledColor); + drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; + EditorGUI.PropertyField(drawRect, colorMultiplier); + drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; + EditorGUI.PropertyField(drawRect, fadeDuration); + } + + public override float GetPropertyHeight(SerializedProperty prop, GUIContent label) + { + return 6 * EditorGUIUtility.singleLineHeight + 5 * EditorGUIUtility.standardVerticalSpacing; + } + } +} diff --git a/Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/ColorBlockDrawer.cs.meta b/Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/ColorBlockDrawer.cs.meta new file mode 100644 index 0000000..a7ac278 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/ColorBlockDrawer.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 94cd9d005e865c94faaef6f8213faecd +timeCreated: 1602119379 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/DropdownOptionListDrawer.cs b/Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/DropdownOptionListDrawer.cs new file mode 100644 index 0000000..662016c --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/DropdownOptionListDrawer.cs @@ -0,0 +1,59 @@ +using UnityEditorInternal; +using UnityEngine; +using UnityEngine.UI; + +namespace UnityEditor.UI +{ + [CustomPropertyDrawer(typeof(Dropdown.OptionDataList), true)] + class DropdownOptionListDrawer : PropertyDrawer + { + private ReorderableList m_ReorderableList; + + private void Init(SerializedProperty property) + { + if (m_ReorderableList != null) + return; + + SerializedProperty array = property.FindPropertyRelative("m_Options"); + + m_ReorderableList = new ReorderableList(property.serializedObject, array); + m_ReorderableList.drawElementCallback = DrawOptionData; + m_ReorderableList.drawHeaderCallback = DrawHeader; + m_ReorderableList.elementHeight += 16; + } + + public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) + { + Init(property); + + m_ReorderableList.DoList(position); + } + + private void DrawHeader(Rect rect) + { + GUI.Label(rect, "Options"); + } + + private void DrawOptionData(Rect rect, int index, bool isActive, bool isFocused) + { + SerializedProperty itemData = m_ReorderableList.serializedProperty.GetArrayElementAtIndex(index); + SerializedProperty itemText = itemData.FindPropertyRelative("m_Text"); + SerializedProperty itemImage = itemData.FindPropertyRelative("m_Image"); + + RectOffset offset = new RectOffset(0, 0, -1, -3); + rect = offset.Add(rect); + rect.height = EditorGUIUtility.singleLineHeight; + + EditorGUI.PropertyField(rect, itemText, GUIContent.none); + rect.y += EditorGUIUtility.singleLineHeight; + EditorGUI.PropertyField(rect, itemImage, GUIContent.none); + } + + public override float GetPropertyHeight(SerializedProperty property, GUIContent label) + { + Init(property); + + return m_ReorderableList.GetHeight(); + } + } +} diff --git a/Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/DropdownOptionListDrawer.cs.meta b/Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/DropdownOptionListDrawer.cs.meta new file mode 100644 index 0000000..21f09c2 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/DropdownOptionListDrawer.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 0b0e171e6b1b1d943b7da016b41a7f88 +timeCreated: 1602119377 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/FontDataDrawer.cs b/Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/FontDataDrawer.cs new file mode 100644 index 0000000..5db2387 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/FontDataDrawer.cs @@ -0,0 +1,512 @@ +using UnityEngine; +using UnityEngine.UI; + +namespace UnityEditor.UI +{ + [CustomPropertyDrawer(typeof(FontData), true)] + public class FontDataDrawer : PropertyDrawer + { + static private class Styles + { + public static GUIStyle alignmentButtonLeft = new GUIStyle(EditorStyles.miniButtonLeft); + public static GUIStyle alignmentButtonMid = new GUIStyle(EditorStyles.miniButtonMid); + public static GUIStyle alignmentButtonRight = new GUIStyle(EditorStyles.miniButtonRight); + + public static GUIContent m_EncodingContent; + + public static GUIContent m_LeftAlignText; + public static GUIContent m_CenterAlignText; + public static GUIContent m_RightAlignText; + public static GUIContent m_TopAlignText; + public static GUIContent m_MiddleAlignText; + public static GUIContent m_BottomAlignText; + + public static GUIContent m_LeftAlignTextActive; + public static GUIContent m_CenterAlignTextActive; + public static GUIContent m_RightAlignTextActive; + public static GUIContent m_TopAlignTextActive; + public static GUIContent m_MiddleAlignTextActive; + public static GUIContent m_BottomAlignTextActive; + + static Styles() + { + m_EncodingContent = new GUIContent("Rich Text", "Use emoticons and colors"); + + // Horizontal Alignment Icons + m_LeftAlignText = EditorGUIUtility.IconContent(@"GUISystem/align_horizontally_left", "Left Align"); + m_CenterAlignText = EditorGUIUtility.IconContent(@"GUISystem/align_horizontally_center", "Center Align"); + m_RightAlignText = EditorGUIUtility.IconContent(@"GUISystem/align_horizontally_right", "Right Align"); + m_LeftAlignTextActive = EditorGUIUtility.IconContent(@"GUISystem/align_horizontally_left_active", "Left Align"); + m_CenterAlignTextActive = EditorGUIUtility.IconContent(@"GUISystem/align_horizontally_center_active", "Center Align"); + m_RightAlignTextActive = EditorGUIUtility.IconContent(@"GUISystem/align_horizontally_right_active", "Right Align"); + + // Vertical Alignment Icons + m_TopAlignText = EditorGUIUtility.IconContent(@"GUISystem/align_vertically_top", "Top Align"); + m_MiddleAlignText = EditorGUIUtility.IconContent(@"GUISystem/align_vertically_center", "Middle Align"); + m_BottomAlignText = EditorGUIUtility.IconContent(@"GUISystem/align_vertically_bottom", "Bottom Align"); + m_TopAlignTextActive = EditorGUIUtility.IconContent(@"GUISystem/align_vertically_top_active", "Top Align"); + m_MiddleAlignTextActive = EditorGUIUtility.IconContent(@"GUISystem/align_vertically_center_active", "Middle Align"); + m_BottomAlignTextActive = EditorGUIUtility.IconContent(@"GUISystem/align_vertically_bottom_active", "Bottom Align"); + + FixAlignmentButtonStyles(alignmentButtonLeft, alignmentButtonMid, alignmentButtonRight); + } + + static void FixAlignmentButtonStyles(params GUIStyle[] styles) + { + foreach (GUIStyle style in styles) + { + style.padding.left = 2; + style.padding.right = 2; + } + } + } + + private enum VerticalTextAligment + { + Top, + Middle, + Bottom + } + + private enum HorizontalTextAligment + { + Left, + Center, + Right + } + + private const int kAlignmentButtonWidth = 20; + + static int s_TextAlignmentHash = "DoTextAligmentControl".GetHashCode(); + + private SerializedProperty m_SupportEncoding; + private SerializedProperty m_Font; + private SerializedProperty m_FontSize; + private SerializedProperty m_LineSpacing; + private SerializedProperty m_FontStyle; + private SerializedProperty m_ResizeTextForBestFit; + private SerializedProperty m_ResizeTextMinSize; + private SerializedProperty m_ResizeTextMaxSize; + private SerializedProperty m_HorizontalOverflow; + private SerializedProperty m_VerticalOverflow; + private SerializedProperty m_Alignment; + private SerializedProperty m_AlignByGeometry; + + private float m_FontFieldfHeight = 0f; + private float m_FontStyleHeight = 0f; + private float m_FontSizeHeight = 0f; + private float m_LineSpacingHeight = 0f; + private float m_EncodingHeight = 0f; + private float m_ResizeTextForBestFitHeight = 0f; + private float m_ResizeTextMinSizeHeight = 0f; + private float m_ResizeTextMaxSizeHeight = 0f; + private float m_HorizontalOverflowHeight = 0f; + private float m_VerticalOverflowHeight = 0f; + private float m_AlignByGeometryHeight = 0f; + + protected void Init(SerializedProperty property) + { + m_SupportEncoding = property.FindPropertyRelative("m_RichText"); + m_Font = property.FindPropertyRelative("m_Font"); + m_FontSize = property.FindPropertyRelative("m_FontSize"); + m_LineSpacing = property.FindPropertyRelative("m_LineSpacing"); + m_FontStyle = property.FindPropertyRelative("m_FontStyle"); + m_ResizeTextForBestFit = property.FindPropertyRelative("m_BestFit"); + m_ResizeTextMinSize = property.FindPropertyRelative("m_MinSize"); + m_ResizeTextMaxSize = property.FindPropertyRelative("m_MaxSize"); + m_HorizontalOverflow = property.FindPropertyRelative("m_HorizontalOverflow"); + m_VerticalOverflow = property.FindPropertyRelative("m_VerticalOverflow"); + m_Alignment = property.FindPropertyRelative("m_Alignment"); + m_AlignByGeometry = property.FindPropertyRelative("m_AlignByGeometry"); + } + + public override float GetPropertyHeight(SerializedProperty property, GUIContent label) + { + Init(property); + m_FontFieldfHeight = EditorGUI.GetPropertyHeight(m_Font); + m_FontStyleHeight = EditorGUI.GetPropertyHeight(m_FontStyle); + m_FontSizeHeight = EditorGUI.GetPropertyHeight(m_FontSize); + m_LineSpacingHeight = EditorGUI.GetPropertyHeight(m_LineSpacing); + m_EncodingHeight = EditorGUI.GetPropertyHeight(m_SupportEncoding); + m_ResizeTextForBestFitHeight = EditorGUI.GetPropertyHeight(m_ResizeTextForBestFit); + m_ResizeTextMinSizeHeight = EditorGUI.GetPropertyHeight(m_ResizeTextMinSize); + m_ResizeTextMaxSizeHeight = EditorGUI.GetPropertyHeight(m_ResizeTextMaxSize); + m_HorizontalOverflowHeight = EditorGUI.GetPropertyHeight(m_HorizontalOverflow); + m_VerticalOverflowHeight = EditorGUI.GetPropertyHeight(m_VerticalOverflow); + m_AlignByGeometryHeight = EditorGUI.GetPropertyHeight(m_AlignByGeometry); + + var height = m_FontFieldfHeight + + m_FontStyleHeight + + m_FontSizeHeight + + m_LineSpacingHeight + + m_EncodingHeight + + m_ResizeTextForBestFitHeight + + m_HorizontalOverflowHeight + + m_VerticalOverflowHeight + + EditorGUIUtility.singleLineHeight * 3 + + EditorGUIUtility.standardVerticalSpacing * 10 + + m_AlignByGeometryHeight; + + if (m_ResizeTextForBestFit.boolValue) + { + height += m_ResizeTextMinSizeHeight + + m_ResizeTextMaxSizeHeight + + EditorGUIUtility.standardVerticalSpacing * 2; + } + return height; + } + + public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) + { + Init(property); + + Rect rect = position; + rect.height = EditorGUIUtility.singleLineHeight; + + EditorGUI.LabelField(rect, "Character", EditorStyles.boldLabel); + rect.y += rect.height + EditorGUIUtility.standardVerticalSpacing; + ++EditorGUI.indentLevel; + { + Font font = m_Font.objectReferenceValue as Font; + rect.height = m_FontFieldfHeight; + EditorGUI.BeginChangeCheck(); + EditorGUI.PropertyField(rect, m_Font); + if (EditorGUI.EndChangeCheck()) + { + font = m_Font.objectReferenceValue as Font; + if (font != null && !font.dynamic) + m_FontSize.intValue = font.fontSize; + } + + rect.y += rect.height + EditorGUIUtility.standardVerticalSpacing; + rect.height = m_FontStyleHeight; + using (new EditorGUI.DisabledScope(!m_Font.hasMultipleDifferentValues && font != null && !font.dynamic)) + { + EditorGUI.PropertyField(rect, m_FontStyle); + } + + rect.y += rect.height + EditorGUIUtility.standardVerticalSpacing; + rect.height = m_FontSizeHeight; + EditorGUI.PropertyField(rect, m_FontSize); + + rect.y += rect.height + EditorGUIUtility.standardVerticalSpacing; + rect.height = m_LineSpacingHeight; + EditorGUI.PropertyField(rect, m_LineSpacing); + + rect.y += rect.height + EditorGUIUtility.standardVerticalSpacing; + rect.height = m_EncodingHeight; + EditorGUI.PropertyField(rect, m_SupportEncoding, Styles.m_EncodingContent); + } + --EditorGUI.indentLevel; + + rect.y += rect.height + EditorGUIUtility.standardVerticalSpacing; + rect.height = EditorGUIUtility.singleLineHeight; + EditorGUI.LabelField(rect, "Paragraph", EditorStyles.boldLabel); + rect.y += rect.height + EditorGUIUtility.standardVerticalSpacing; + ++EditorGUI.indentLevel; + { + rect.height = EditorGUIUtility.singleLineHeight; + DoTextAligmentControl(rect, m_Alignment); + + rect.y += rect.height + EditorGUIUtility.standardVerticalSpacing; + rect.height = m_HorizontalOverflowHeight; + EditorGUI.PropertyField(rect, m_AlignByGeometry); + + rect.y += rect.height + EditorGUIUtility.standardVerticalSpacing; + rect.height = m_HorizontalOverflowHeight; + EditorGUI.PropertyField(rect, m_HorizontalOverflow); + + rect.y += rect.height + EditorGUIUtility.standardVerticalSpacing; + rect.height = m_VerticalOverflowHeight; + EditorGUI.PropertyField(rect, m_VerticalOverflow); + + rect.y += rect.height + EditorGUIUtility.standardVerticalSpacing; + rect.height = m_ResizeTextMaxSizeHeight; + EditorGUI.PropertyField(rect, m_ResizeTextForBestFit); + + if (m_ResizeTextForBestFit.boolValue) + { + EditorGUILayout.EndFadeGroup(); + rect.y += rect.height + EditorGUIUtility.standardVerticalSpacing; + rect.height = m_ResizeTextMinSizeHeight; + EditorGUI.PropertyField(rect, m_ResizeTextMinSize); + + rect.y += rect.height + EditorGUIUtility.standardVerticalSpacing; + rect.height = m_ResizeTextMaxSizeHeight; + EditorGUI.PropertyField(rect, m_ResizeTextMaxSize); + } + } + --EditorGUI.indentLevel; + } + + private void DoTextAligmentControl(Rect position, SerializedProperty alignment) + { + GUIContent alingmentContent = new GUIContent("Alignment"); + + int id = EditorGUIUtility.GetControlID(s_TextAlignmentHash, FocusType.Keyboard, position); + + EditorGUIUtility.SetIconSize(new Vector2(15, 15)); + EditorGUI.BeginProperty(position, alingmentContent, alignment); + { + Rect controlArea = EditorGUI.PrefixLabel(position, id, alingmentContent); + + float width = kAlignmentButtonWidth * 3; + float spacing = Mathf.Clamp(controlArea.width - width * 2, 2, 10); + + Rect horizontalAligment = new Rect(controlArea.x, controlArea.y, width, controlArea.height); + Rect verticalAligment = new Rect(horizontalAligment.xMax + spacing, controlArea.y, width, controlArea.height); + + DoHorizontalAligmentControl(horizontalAligment, alignment); + DoVerticalAligmentControl(verticalAligment, alignment); + } + EditorGUI.EndProperty(); + EditorGUIUtility.SetIconSize(Vector2.zero); + } + + private static void DoHorizontalAligmentControl(Rect position, SerializedProperty alignment) + { + TextAnchor ta = (TextAnchor)alignment.intValue; + HorizontalTextAligment horizontalAlignment = GetHorizontalAlignment(ta); + + bool leftAlign = (horizontalAlignment == HorizontalTextAligment.Left); + bool centerAlign = (horizontalAlignment == HorizontalTextAligment.Center); + bool rightAlign = (horizontalAlignment == HorizontalTextAligment.Right); + + if (alignment.hasMultipleDifferentValues) + { + foreach (var obj in alignment.serializedObject.targetObjects) + { + Text text = obj as Text; + horizontalAlignment = GetHorizontalAlignment(text.alignment); + leftAlign = leftAlign || (horizontalAlignment == HorizontalTextAligment.Left); + centerAlign = centerAlign || (horizontalAlignment == HorizontalTextAligment.Center); + rightAlign = rightAlign || (horizontalAlignment == HorizontalTextAligment.Right); + } + } + + position.width = kAlignmentButtonWidth; + + EditorGUI.BeginChangeCheck(); + EditorToggle(position, leftAlign, leftAlign ? Styles.m_LeftAlignTextActive : Styles.m_LeftAlignText, Styles.alignmentButtonLeft); + if (EditorGUI.EndChangeCheck()) + { + SetHorizontalAlignment(alignment, HorizontalTextAligment.Left); + } + + position.x += position.width; + EditorGUI.BeginChangeCheck(); + EditorToggle(position, centerAlign, centerAlign ? Styles.m_CenterAlignTextActive : Styles.m_CenterAlignText, Styles.alignmentButtonMid); + if (EditorGUI.EndChangeCheck()) + { + SetHorizontalAlignment(alignment, HorizontalTextAligment.Center); + } + + position.x += position.width; + EditorGUI.BeginChangeCheck(); + EditorToggle(position, rightAlign, rightAlign ? Styles.m_RightAlignTextActive : Styles.m_RightAlignText, Styles.alignmentButtonRight); + if (EditorGUI.EndChangeCheck()) + { + SetHorizontalAlignment(alignment, HorizontalTextAligment.Right); + } + } + + private static void DoVerticalAligmentControl(Rect position, SerializedProperty alignment) + { + TextAnchor ta = (TextAnchor)alignment.intValue; + VerticalTextAligment verticalTextAligment = GetVerticalAlignment(ta); + + bool topAlign = (verticalTextAligment == VerticalTextAligment.Top); + bool middleAlign = (verticalTextAligment == VerticalTextAligment.Middle); + bool bottomAlign = (verticalTextAligment == VerticalTextAligment.Bottom); + + if (alignment.hasMultipleDifferentValues) + { + foreach (var obj in alignment.serializedObject.targetObjects) + { + Text text = obj as Text; + TextAnchor textAlignment = text.alignment; + verticalTextAligment = GetVerticalAlignment(textAlignment); + topAlign = topAlign || (verticalTextAligment == VerticalTextAligment.Top); + middleAlign = middleAlign || (verticalTextAligment == VerticalTextAligment.Middle); + bottomAlign = bottomAlign || (verticalTextAligment == VerticalTextAligment.Bottom); + } + } + + + position.width = kAlignmentButtonWidth; + + // position.x += position.width; + EditorGUI.BeginChangeCheck(); + EditorToggle(position, topAlign, topAlign ? Styles.m_TopAlignTextActive : Styles.m_TopAlignText, Styles.alignmentButtonLeft); + if (EditorGUI.EndChangeCheck()) + { + SetVerticalAlignment(alignment, VerticalTextAligment.Top); + } + + position.x += position.width; + EditorGUI.BeginChangeCheck(); + EditorToggle(position, middleAlign, middleAlign ? Styles.m_MiddleAlignTextActive : Styles.m_MiddleAlignText, Styles.alignmentButtonMid); + if (EditorGUI.EndChangeCheck()) + { + SetVerticalAlignment(alignment, VerticalTextAligment.Middle); + } + + position.x += position.width; + EditorGUI.BeginChangeCheck(); + EditorToggle(position, bottomAlign, bottomAlign ? Styles.m_BottomAlignTextActive : Styles.m_BottomAlignText, Styles.alignmentButtonRight); + if (EditorGUI.EndChangeCheck()) + { + SetVerticalAlignment(alignment, VerticalTextAligment.Bottom); + } + } + + private static bool EditorToggle(Rect position, bool value, GUIContent content, GUIStyle style) + { + int hashCode = "AlignToggle".GetHashCode(); + int id = EditorGUIUtility.GetControlID(hashCode, FocusType.Keyboard, position); + Event evt = Event.current; + + // Toggle selected toggle on space or return key + if (EditorGUIUtility.keyboardControl == id && evt.type == EventType.KeyDown && (evt.keyCode == KeyCode.Space || evt.keyCode == KeyCode.Return || evt.keyCode == KeyCode.KeypadEnter)) + { + value = !value; + evt.Use(); + GUI.changed = true; + } + + if (evt.type == EventType.KeyDown && Event.current.button == 0 && position.Contains(Event.current.mousePosition)) + { + GUIUtility.keyboardControl = id; + EditorGUIUtility.editingTextField = false; + HandleUtility.Repaint(); + } + + bool returnValue = GUI.Toggle(position, id, value, content, style); + + return returnValue; + } + + private static HorizontalTextAligment GetHorizontalAlignment(TextAnchor ta) + { + switch (ta) + { + case TextAnchor.MiddleCenter: + case TextAnchor.UpperCenter: + case TextAnchor.LowerCenter: + return HorizontalTextAligment.Center; + + case TextAnchor.UpperRight: + case TextAnchor.MiddleRight: + case TextAnchor.LowerRight: + return HorizontalTextAligment.Right; + + case TextAnchor.UpperLeft: + case TextAnchor.MiddleLeft: + case TextAnchor.LowerLeft: + return HorizontalTextAligment.Left; + } + + return HorizontalTextAligment.Left; + } + + private static VerticalTextAligment GetVerticalAlignment(TextAnchor ta) + { + switch (ta) + { + case TextAnchor.UpperLeft: + case TextAnchor.UpperCenter: + case TextAnchor.UpperRight: + return VerticalTextAligment.Top; + + case TextAnchor.MiddleLeft: + case TextAnchor.MiddleCenter: + case TextAnchor.MiddleRight: + return VerticalTextAligment.Middle; + + case TextAnchor.LowerLeft: + case TextAnchor.LowerCenter: + case TextAnchor.LowerRight: + return VerticalTextAligment.Bottom; + } + + return VerticalTextAligment.Top; + } + + // We can't go through serialized properties here since we're showing two controls for a single SerializzedProperty. + private static void SetHorizontalAlignment(SerializedProperty alignment, HorizontalTextAligment horizontalAlignment) + { + foreach (var obj in alignment.serializedObject.targetObjects) + { + Text text = obj as Text; + VerticalTextAligment currentVerticalAligment = GetVerticalAlignment(text.alignment); + Undo.RecordObject(text, "Horizontal Alignment"); + text.alignment = GetAnchor(currentVerticalAligment, horizontalAlignment); + EditorUtility.SetDirty(obj); + } + } + + private static void SetVerticalAlignment(SerializedProperty alignment, VerticalTextAligment verticalAlignment) + { + foreach (var obj in alignment.serializedObject.targetObjects) + { + Text text = obj as Text; + HorizontalTextAligment currentHorizontalAligment = GetHorizontalAlignment(text.alignment); + Undo.RecordObject(text, "Vertical Alignment"); + text.alignment = GetAnchor(verticalAlignment, currentHorizontalAligment); + EditorUtility.SetDirty(obj); + } + } + + private static TextAnchor GetAnchor(VerticalTextAligment verticalTextAligment, HorizontalTextAligment horizontalTextAligment) + { + TextAnchor ac = TextAnchor.UpperLeft; + + switch (horizontalTextAligment) + { + case HorizontalTextAligment.Left: + switch (verticalTextAligment) + { + case VerticalTextAligment.Bottom: + ac = TextAnchor.LowerLeft; + break; + case VerticalTextAligment.Middle: + ac = TextAnchor.MiddleLeft; + break; + default: + ac = TextAnchor.UpperLeft; + break; + } + break; + case HorizontalTextAligment.Center: + switch (verticalTextAligment) + { + case VerticalTextAligment.Bottom: + ac = TextAnchor.LowerCenter; + break; + case VerticalTextAligment.Middle: + ac = TextAnchor.MiddleCenter; + break; + default: + ac = TextAnchor.UpperCenter; + break; + } + break; + default: + switch (verticalTextAligment) + { + case VerticalTextAligment.Bottom: + ac = TextAnchor.LowerRight; + break; + case VerticalTextAligment.Middle: + ac = TextAnchor.MiddleRight; + break; + default: + ac = TextAnchor.UpperRight; + break; + } + break; + } + return ac; + } + } +} diff --git a/Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/FontDataDrawer.cs.meta b/Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/FontDataDrawer.cs.meta new file mode 100644 index 0000000..01a9f7b --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/FontDataDrawer.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 9a502f8fd08923f4a804fcbbc63bab90 +timeCreated: 1602119379 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/NavigationDrawer.cs b/Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/NavigationDrawer.cs new file mode 100644 index 0000000..2cfc4d3 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/NavigationDrawer.cs @@ -0,0 +1,83 @@ +using UnityEngine; +using UnityEngine.UI; + +namespace UnityEditor.UI +{ + [CustomPropertyDrawer(typeof(Navigation), true)] + public class NavigationDrawer : PropertyDrawer + { + private class Styles + { + readonly public GUIContent navigationContent; + + public Styles() + { + navigationContent = new GUIContent("Navigation"); + } + } + + private static Styles s_Styles = null; + + public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label) + { + if (s_Styles == null) + s_Styles = new Styles(); + + Rect drawRect = pos; + drawRect.height = EditorGUIUtility.singleLineHeight; + + SerializedProperty navigation = prop.FindPropertyRelative("m_Mode"); + Navigation.Mode navMode = GetNavigationMode(navigation); + + EditorGUI.PropertyField(drawRect, navigation, s_Styles.navigationContent); + + ++EditorGUI.indentLevel; + + drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; + + switch (navMode) + { + case Navigation.Mode.Explicit: + { + SerializedProperty selectOnUp = prop.FindPropertyRelative("m_SelectOnUp"); + SerializedProperty selectOnDown = prop.FindPropertyRelative("m_SelectOnDown"); + SerializedProperty selectOnLeft = prop.FindPropertyRelative("m_SelectOnLeft"); + SerializedProperty selectOnRight = prop.FindPropertyRelative("m_SelectOnRight"); + + EditorGUI.PropertyField(drawRect, selectOnUp); + drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; + EditorGUI.PropertyField(drawRect, selectOnDown); + drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; + EditorGUI.PropertyField(drawRect, selectOnLeft); + drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; + EditorGUI.PropertyField(drawRect, selectOnRight); + drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; + } + break; + } + + --EditorGUI.indentLevel; + } + + static Navigation.Mode GetNavigationMode(SerializedProperty navigation) + { + return (Navigation.Mode)navigation.enumValueIndex; + } + + public override float GetPropertyHeight(SerializedProperty prop, GUIContent label) + { + SerializedProperty navigation = prop.FindPropertyRelative("m_Mode"); + if (navigation == null) + return EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; + + Navigation.Mode navMode = GetNavigationMode(navigation); + + switch (navMode) + { + case Navigation.Mode.None: return EditorGUIUtility.singleLineHeight; + case Navigation.Mode.Explicit: return 5 * EditorGUIUtility.singleLineHeight + 5 * EditorGUIUtility.standardVerticalSpacing; + default: return EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing; + } + } + } +} diff --git a/Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/NavigationDrawer.cs.meta b/Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/NavigationDrawer.cs.meta new file mode 100644 index 0000000..6eb8468 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/NavigationDrawer.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 9fc1ecf033776204b9a224661a28dcfd +timeCreated: 1602119379 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/SpriteStateDrawer.cs b/Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/SpriteStateDrawer.cs new file mode 100644 index 0000000..510db1a --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/SpriteStateDrawer.cs @@ -0,0 +1,30 @@ +using UnityEngine; +using UnityEngine.UI; + +namespace UnityEditor.UI +{ + [CustomPropertyDrawer(typeof(SpriteState), true)] + public class SpriteStateDrawer : PropertyDrawer + { + public override void OnGUI(Rect rect, SerializedProperty prop, GUIContent label) + { + Rect drawRect = rect; + drawRect.height = EditorGUIUtility.singleLineHeight; + SerializedProperty highlightedSprite = prop.FindPropertyRelative("m_HighlightedSprite"); + SerializedProperty pressedSprite = prop.FindPropertyRelative("m_PressedSprite"); + SerializedProperty disabledSprite = prop.FindPropertyRelative("m_DisabledSprite"); + + EditorGUI.PropertyField(drawRect, highlightedSprite); + drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; + EditorGUI.PropertyField(drawRect, pressedSprite); + drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; + EditorGUI.PropertyField(drawRect, disabledSprite); + drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; + } + + public override float GetPropertyHeight(SerializedProperty prop, GUIContent label) + { + return 3 * EditorGUIUtility.singleLineHeight + 2 * EditorGUIUtility.standardVerticalSpacing; + } + } +} diff --git a/Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/SpriteStateDrawer.cs.meta b/Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/SpriteStateDrawer.cs.meta new file mode 100644 index 0000000..cbcad61 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/PropertyDrawers/SpriteStateDrawer.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: cc8f8e0433b0dff4289da30bc91c831d +timeCreated: 1602119380 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/Editor/UI/RawImageEditor.cs b/Assets/uGUI-2017.1/Editor/UI/RawImageEditor.cs new file mode 100644 index 0000000..36e43b1 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/RawImageEditor.cs @@ -0,0 +1,107 @@ +using UnityEngine; +using UnityEngine.UI; + +namespace UnityEditor.UI +{ + /// <summary> + /// Editor class used to edit UI Images. + /// </summary> + [CustomEditor(typeof(RawImage), true)] + [CanEditMultipleObjects] + public class RawImageEditor : GraphicEditor + { + SerializedProperty m_Texture; + SerializedProperty m_UVRect; + GUIContent m_UVRectContent; + + protected override void OnEnable() + { + base.OnEnable(); + + // Note we have precedence for calling rectangle for just rect, even in the Inspector. + // For example in the Camera component's Viewport Rect. + // Hence sticking with Rect here to be consistent with corresponding property in the API. + m_UVRectContent = new GUIContent("UV Rect"); + + m_Texture = serializedObject.FindProperty("m_Texture"); + m_UVRect = serializedObject.FindProperty("m_UVRect"); + + SetShowNativeSize(true); + } + + public override void OnInspectorGUI() + { + serializedObject.Update(); + + EditorGUILayout.PropertyField(m_Texture); + AppearanceControlsGUI(); + RaycastControlsGUI(); + EditorGUILayout.PropertyField(m_UVRect, m_UVRectContent); + SetShowNativeSize(false); + NativeSizeButtonGUI(); + + serializedObject.ApplyModifiedProperties(); + } + + void SetShowNativeSize(bool instant) + { + base.SetShowNativeSize(m_Texture.objectReferenceValue != null, instant); + } + + private static Rect Outer(RawImage rawImage) + { + Rect outer = rawImage.uvRect; + outer.xMin *= rawImage.rectTransform.rect.width; + outer.xMax *= rawImage.rectTransform.rect.width; + outer.yMin *= rawImage.rectTransform.rect.height; + outer.yMax *= rawImage.rectTransform.rect.height; + return outer; + } + + /// <summary> + /// Allow the texture to be previewed. + /// </summary> + + public override bool HasPreviewGUI() + { + RawImage rawImage = target as RawImage; + if (rawImage == null) + return false; + + var outer = Outer(rawImage); + return outer.width > 0 && outer.height > 0; + } + + /// <summary> + /// Draw the Image preview. + /// </summary> + + public override void OnPreviewGUI(Rect rect, GUIStyle background) + { + RawImage rawImage = target as RawImage; + Texture tex = rawImage.mainTexture; + + if (tex == null) + return; + + var outer = Outer(rawImage); + SpriteDrawUtility.DrawSprite(tex, rect, outer, rawImage.uvRect, rawImage.canvasRenderer.GetColor()); + } + + /// <summary> + /// Info String drawn at the bottom of the Preview + /// </summary> + + public override string GetInfoString() + { + RawImage rawImage = target as RawImage; + + // Image size Text + string text = string.Format("RawImage Size: {0}x{1}", + Mathf.RoundToInt(Mathf.Abs(rawImage.rectTransform.rect.width)), + Mathf.RoundToInt(Mathf.Abs(rawImage.rectTransform.rect.height))); + + return text; + } + } +} diff --git a/Assets/uGUI-2017.1/Editor/UI/RawImageEditor.cs.meta b/Assets/uGUI-2017.1/Editor/UI/RawImageEditor.cs.meta new file mode 100644 index 0000000..c5b427a --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/RawImageEditor.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 735e178f724133c42b4eeb469dd13867 +timeCreated: 1602119379 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/Editor/UI/RectMask2DEditor.cs b/Assets/uGUI-2017.1/Editor/UI/RectMask2DEditor.cs new file mode 100644 index 0000000..cad5773 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/RectMask2DEditor.cs @@ -0,0 +1,13 @@ +using UnityEngine.UI; + +namespace UnityEditor.UI +{ + [CustomEditor(typeof(RectMask2D), true)] + [CanEditMultipleObjects] + public class RectMask2DEditor : Editor + { + public override void OnInspectorGUI() + { + } + } +} diff --git a/Assets/uGUI-2017.1/Editor/UI/RectMask2DEditor.cs.meta b/Assets/uGUI-2017.1/Editor/UI/RectMask2DEditor.cs.meta new file mode 100644 index 0000000..02621a3 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/RectMask2DEditor.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: a2e0aadc108e8f342a529c3ff8e70470 +timeCreated: 1602119379 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/Editor/UI/ScrollRectEditor.cs b/Assets/uGUI-2017.1/Editor/UI/ScrollRectEditor.cs new file mode 100644 index 0000000..56e7d64 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/ScrollRectEditor.cs @@ -0,0 +1,172 @@ +using UnityEngine; +using UnityEngine.UI; +using UnityEditor.AnimatedValues; + +namespace UnityEditor.UI +{ + [CustomEditor(typeof(ScrollRect), true)] + [CanEditMultipleObjects] + public class ScrollRectEditor : Editor + { + SerializedProperty m_Content; + SerializedProperty m_Horizontal; + SerializedProperty m_Vertical; + SerializedProperty m_MovementType; + SerializedProperty m_Elasticity; + SerializedProperty m_Inertia; + SerializedProperty m_DecelerationRate; + SerializedProperty m_ScrollSensitivity; + SerializedProperty m_Viewport; + SerializedProperty m_HorizontalScrollbar; + SerializedProperty m_VerticalScrollbar; + SerializedProperty m_HorizontalScrollbarVisibility; + SerializedProperty m_VerticalScrollbarVisibility; + SerializedProperty m_HorizontalScrollbarSpacing; + SerializedProperty m_VerticalScrollbarSpacing; + SerializedProperty m_OnValueChanged; + AnimBool m_ShowElasticity; + AnimBool m_ShowDecelerationRate; + bool m_ViewportIsNotChild, m_HScrollbarIsNotChild, m_VScrollbarIsNotChild; + static string s_HError = "For this visibility mode, the Viewport property and the Horizontal Scrollbar property both needs to be set to a Rect Transform that is a child to the Scroll Rect."; + static string s_VError = "For this visibility mode, the Viewport property and the Vertical Scrollbar property both needs to be set to a Rect Transform that is a child to the Scroll Rect."; + + protected virtual void OnEnable() + { + m_Content = serializedObject.FindProperty("m_Content"); + m_Horizontal = serializedObject.FindProperty("m_Horizontal"); + m_Vertical = serializedObject.FindProperty("m_Vertical"); + m_MovementType = serializedObject.FindProperty("m_MovementType"); + m_Elasticity = serializedObject.FindProperty("m_Elasticity"); + m_Inertia = serializedObject.FindProperty("m_Inertia"); + m_DecelerationRate = serializedObject.FindProperty("m_DecelerationRate"); + m_ScrollSensitivity = serializedObject.FindProperty("m_ScrollSensitivity"); + m_Viewport = serializedObject.FindProperty("m_Viewport"); + m_HorizontalScrollbar = serializedObject.FindProperty("m_HorizontalScrollbar"); + m_VerticalScrollbar = serializedObject.FindProperty("m_VerticalScrollbar"); + m_HorizontalScrollbarVisibility = serializedObject.FindProperty("m_HorizontalScrollbarVisibility"); + m_VerticalScrollbarVisibility = serializedObject.FindProperty("m_VerticalScrollbarVisibility"); + m_HorizontalScrollbarSpacing = serializedObject.FindProperty("m_HorizontalScrollbarSpacing"); + m_VerticalScrollbarSpacing = serializedObject.FindProperty("m_VerticalScrollbarSpacing"); + m_OnValueChanged = serializedObject.FindProperty("m_OnValueChanged"); + + m_ShowElasticity = new AnimBool(Repaint); + m_ShowDecelerationRate = new AnimBool(Repaint); + SetAnimBools(true); + } + + protected virtual void OnDisable() + { + m_ShowElasticity.valueChanged.RemoveListener(Repaint); + m_ShowDecelerationRate.valueChanged.RemoveListener(Repaint); + } + + void SetAnimBools(bool instant) + { + SetAnimBool(m_ShowElasticity, !m_MovementType.hasMultipleDifferentValues && m_MovementType.enumValueIndex == (int)ScrollRect.MovementType.Elastic, instant); + SetAnimBool(m_ShowDecelerationRate, !m_Inertia.hasMultipleDifferentValues && m_Inertia.boolValue == true, instant); + } + + void SetAnimBool(AnimBool a, bool value, bool instant) + { + if (instant) + a.value = value; + else + a.target = value; + } + + void CalculateCachedValues() + { + m_ViewportIsNotChild = false; + m_HScrollbarIsNotChild = false; + m_VScrollbarIsNotChild = false; + if (targets.Length == 1) + { + Transform transform = ((ScrollRect)target).transform; + if (m_Viewport.objectReferenceValue == null || ((RectTransform)m_Viewport.objectReferenceValue).transform.parent != transform) + m_ViewportIsNotChild = true; + if (m_HorizontalScrollbar.objectReferenceValue == null || ((Scrollbar)m_HorizontalScrollbar.objectReferenceValue).transform.parent != transform) + m_HScrollbarIsNotChild = true; + if (m_VerticalScrollbar.objectReferenceValue == null || ((Scrollbar)m_VerticalScrollbar.objectReferenceValue).transform.parent != transform) + m_VScrollbarIsNotChild = true; + } + } + + public override void OnInspectorGUI() + { + SetAnimBools(false); + + serializedObject.Update(); + // Once we have a reliable way to know if the object changed, only re-cache in that case. + CalculateCachedValues(); + + EditorGUILayout.PropertyField(m_Content); + + EditorGUILayout.PropertyField(m_Horizontal); + EditorGUILayout.PropertyField(m_Vertical); + + EditorGUILayout.PropertyField(m_MovementType); + if (EditorGUILayout.BeginFadeGroup(m_ShowElasticity.faded)) + { + EditorGUI.indentLevel++; + EditorGUILayout.PropertyField(m_Elasticity); + EditorGUI.indentLevel--; + } + EditorGUILayout.EndFadeGroup(); + + EditorGUILayout.PropertyField(m_Inertia); + if (EditorGUILayout.BeginFadeGroup(m_ShowDecelerationRate.faded)) + { + EditorGUI.indentLevel++; + EditorGUILayout.PropertyField(m_DecelerationRate); + EditorGUI.indentLevel--; + } + EditorGUILayout.EndFadeGroup(); + + EditorGUILayout.PropertyField(m_ScrollSensitivity); + + EditorGUILayout.Space(); + + EditorGUILayout.PropertyField(m_Viewport); + + EditorGUILayout.PropertyField(m_HorizontalScrollbar); + if (m_HorizontalScrollbar.objectReferenceValue && !m_HorizontalScrollbar.hasMultipleDifferentValues) + { + EditorGUI.indentLevel++; + EditorGUILayout.PropertyField(m_HorizontalScrollbarVisibility, new GUIContent("Visibility")); + + if ((ScrollRect.ScrollbarVisibility)m_HorizontalScrollbarVisibility.enumValueIndex == ScrollRect.ScrollbarVisibility.AutoHideAndExpandViewport + && !m_HorizontalScrollbarVisibility.hasMultipleDifferentValues) + { + if (m_ViewportIsNotChild || m_HScrollbarIsNotChild) + EditorGUILayout.HelpBox(s_HError, MessageType.Error); + EditorGUILayout.PropertyField(m_HorizontalScrollbarSpacing, new GUIContent("Spacing")); + } + + EditorGUI.indentLevel--; + } + + EditorGUILayout.PropertyField(m_VerticalScrollbar); + if (m_VerticalScrollbar.objectReferenceValue && !m_VerticalScrollbar.hasMultipleDifferentValues) + { + EditorGUI.indentLevel++; + EditorGUILayout.PropertyField(m_VerticalScrollbarVisibility, new GUIContent("Visibility")); + + if ((ScrollRect.ScrollbarVisibility)m_VerticalScrollbarVisibility.enumValueIndex == ScrollRect.ScrollbarVisibility.AutoHideAndExpandViewport + && !m_VerticalScrollbarVisibility.hasMultipleDifferentValues) + { + if (m_ViewportIsNotChild || m_VScrollbarIsNotChild) + EditorGUILayout.HelpBox(s_VError, MessageType.Error); + EditorGUILayout.PropertyField(m_VerticalScrollbarSpacing, new GUIContent("Spacing")); + } + + EditorGUI.indentLevel--; + } + + EditorGUILayout.Space(); + + EditorGUILayout.PropertyField(m_OnValueChanged); + + serializedObject.ApplyModifiedProperties(); + } + } +} diff --git a/Assets/uGUI-2017.1/Editor/UI/ScrollRectEditor.cs.meta b/Assets/uGUI-2017.1/Editor/UI/ScrollRectEditor.cs.meta new file mode 100644 index 0000000..4311b0b --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/ScrollRectEditor.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: ff377b0e7561593448ad1c54668efe83 +timeCreated: 1602119380 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/Editor/UI/ScrollbarEditor.cs b/Assets/uGUI-2017.1/Editor/UI/ScrollbarEditor.cs new file mode 100644 index 0000000..73b97d6 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/ScrollbarEditor.cs @@ -0,0 +1,102 @@ +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.UI; + +namespace UnityEditor.UI +{ + [CustomEditor(typeof(Scrollbar), true)] + [CanEditMultipleObjects] + public class ScrollbarEditor : SelectableEditor + { + SerializedProperty m_HandleRect; + SerializedProperty m_Direction; + SerializedProperty m_Value; + SerializedProperty m_Size; + SerializedProperty m_NumberOfSteps; + SerializedProperty m_OnValueChanged; + + protected override void OnEnable() + { + base.OnEnable(); + + m_HandleRect = serializedObject.FindProperty("m_HandleRect"); + m_Direction = serializedObject.FindProperty("m_Direction"); + m_Value = serializedObject.FindProperty("m_Value"); + m_Size = serializedObject.FindProperty("m_Size"); + m_NumberOfSteps = serializedObject.FindProperty("m_NumberOfSteps"); + m_OnValueChanged = serializedObject.FindProperty("m_OnValueChanged"); + } + + public override void OnInspectorGUI() + { + base.OnInspectorGUI(); + EditorGUILayout.Space(); + + serializedObject.Update(); + + // EditorGUILayout.PropertyField(m_HandleRect); + EditorGUI.BeginChangeCheck(); + RectTransform newRectTransform = EditorGUILayout.ObjectField("Handle Rect", m_HandleRect.objectReferenceValue, typeof(RectTransform), true) as RectTransform; + if (EditorGUI.EndChangeCheck()) + { + // Handle Rect will modify its GameObject RectTransform drivenBy, so we need to Record the old and new RectTransform. + List<Object> modifiedObjects = new List<Object>(); + modifiedObjects.Add(newRectTransform); + foreach (var target in m_HandleRect.serializedObject.targetObjects) + { + MonoBehaviour mb = target as MonoBehaviour; + if (mb == null) + continue; + + modifiedObjects.Add(mb); + modifiedObjects.Add(mb.GetComponent<RectTransform>()); + } + Undo.RecordObjects(modifiedObjects.ToArray(), "Change Handle Rect"); + m_HandleRect.objectReferenceValue = newRectTransform; + } + + if (m_HandleRect.objectReferenceValue != null) + { + EditorGUI.BeginChangeCheck(); + EditorGUILayout.PropertyField(m_Direction); + if (EditorGUI.EndChangeCheck()) + { + Scrollbar.Direction direction = (Scrollbar.Direction)m_Direction.enumValueIndex; + foreach (var obj in serializedObject.targetObjects) + { + Scrollbar scrollbar = obj as Scrollbar; + scrollbar.SetDirection(direction, true); + } + } + + EditorGUILayout.PropertyField(m_Value); + EditorGUILayout.PropertyField(m_Size); + EditorGUILayout.PropertyField(m_NumberOfSteps); + + bool warning = false; + foreach (var obj in serializedObject.targetObjects) + { + Scrollbar scrollbar = obj as Scrollbar; + Scrollbar.Direction dir = scrollbar.direction; + if (dir == Scrollbar.Direction.LeftToRight || dir == Scrollbar.Direction.RightToLeft) + warning = (scrollbar.navigation.mode != Navigation.Mode.Automatic && (scrollbar.FindSelectableOnLeft() != null || scrollbar.FindSelectableOnRight() != null)); + else + warning = (scrollbar.navigation.mode != Navigation.Mode.Automatic && (scrollbar.FindSelectableOnDown() != null || scrollbar.FindSelectableOnUp() != null)); + } + + if (warning) + EditorGUILayout.HelpBox("The selected scrollbar direction conflicts with navigation. Not all navigation options may work.", MessageType.Warning); + + EditorGUILayout.Space(); + // Draw the event notification options + EditorGUILayout.PropertyField(m_OnValueChanged); + } + else + { + EditorGUILayout.HelpBox("Specify a RectTransform for the scrollbar handle. It must have a parent RectTransform that the handle can slide within.", MessageType.Info); + } + + serializedObject.ApplyModifiedProperties(); + } + } +} diff --git a/Assets/uGUI-2017.1/Editor/UI/ScrollbarEditor.cs.meta b/Assets/uGUI-2017.1/Editor/UI/ScrollbarEditor.cs.meta new file mode 100644 index 0000000..80bbf88 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/ScrollbarEditor.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 607de83ab7663e74dac5e5d063fb2954 +timeCreated: 1602119378 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/Editor/UI/SelectableEditor.cs b/Assets/uGUI-2017.1/Editor/UI/SelectableEditor.cs new file mode 100644 index 0000000..d3329cc --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/SelectableEditor.cs @@ -0,0 +1,370 @@ +using System.Collections.Generic; +using System.Text; +using System.Linq; +using UnityEngine; +using UnityEngine.UI; +using UnityEditor.AnimatedValues; + +namespace UnityEditor.UI +{ + [CustomEditor(typeof(Selectable), true)] + public class SelectableEditor : Editor + { + SerializedProperty m_Script; + SerializedProperty m_InteractableProperty; + SerializedProperty m_TargetGraphicProperty; + SerializedProperty m_TransitionProperty; + SerializedProperty m_ColorBlockProperty; + SerializedProperty m_SpriteStateProperty; + SerializedProperty m_AnimTriggerProperty; + SerializedProperty m_NavigationProperty; + + GUIContent m_VisualizeNavigation = new GUIContent("Visualize", "Show navigation flows between selectable UI elements."); + + AnimBool m_ShowColorTint = new AnimBool(); + AnimBool m_ShowSpriteTrasition = new AnimBool(); + AnimBool m_ShowAnimTransition = new AnimBool(); + + private static List<SelectableEditor> s_Editors = new List<SelectableEditor>(); + private static bool s_ShowNavigation = false; + private static string s_ShowNavigationKey = "SelectableEditor.ShowNavigation"; + + // Whenever adding new SerializedProperties to the Selectable and SelectableEditor + // Also update this guy in OnEnable. This makes the inherited classes from Selectable not require a CustomEditor. + private string[] m_PropertyPathToExcludeForChildClasses; + + protected virtual void OnEnable() + { + m_Script = serializedObject.FindProperty("m_Script"); + m_InteractableProperty = serializedObject.FindProperty("m_Interactable"); + m_TargetGraphicProperty = serializedObject.FindProperty("m_TargetGraphic"); + m_TransitionProperty = serializedObject.FindProperty("m_Transition"); + m_ColorBlockProperty = serializedObject.FindProperty("m_Colors"); + m_SpriteStateProperty = serializedObject.FindProperty("m_SpriteState"); + m_AnimTriggerProperty = serializedObject.FindProperty("m_AnimationTriggers"); + m_NavigationProperty = serializedObject.FindProperty("m_Navigation"); + + m_PropertyPathToExcludeForChildClasses = new[] + { + m_Script.propertyPath, + m_NavigationProperty.propertyPath, + m_TransitionProperty.propertyPath, + m_ColorBlockProperty.propertyPath, + m_SpriteStateProperty.propertyPath, + m_AnimTriggerProperty.propertyPath, + m_InteractableProperty.propertyPath, + m_TargetGraphicProperty.propertyPath, + }; + + var trans = GetTransition(m_TransitionProperty); + m_ShowColorTint.value = (trans == Selectable.Transition.ColorTint); + m_ShowSpriteTrasition.value = (trans == Selectable.Transition.SpriteSwap); + m_ShowAnimTransition.value = (trans == Selectable.Transition.Animation); + + m_ShowColorTint.valueChanged.AddListener(Repaint); + m_ShowSpriteTrasition.valueChanged.AddListener(Repaint); + + s_Editors.Add(this); + RegisterStaticOnSceneGUI(); + + s_ShowNavigation = EditorPrefs.GetBool(s_ShowNavigationKey); + } + + protected virtual void OnDisable() + { + m_ShowColorTint.valueChanged.RemoveListener(Repaint); + m_ShowSpriteTrasition.valueChanged.RemoveListener(Repaint); + + s_Editors.Remove(this); + RegisterStaticOnSceneGUI(); + } + + private void RegisterStaticOnSceneGUI() + { + SceneView.onSceneGUIDelegate -= StaticOnSceneGUI; + if (s_Editors.Count > 0) + SceneView.onSceneGUIDelegate += StaticOnSceneGUI; + } + + static Selectable.Transition GetTransition(SerializedProperty transition) + { + return (Selectable.Transition)transition.enumValueIndex; + } + + public override void OnInspectorGUI() + { + serializedObject.Update(); + + EditorGUILayout.PropertyField(m_InteractableProperty); + + var trans = GetTransition(m_TransitionProperty); + + var graphic = m_TargetGraphicProperty.objectReferenceValue as Graphic; + if (graphic == null) + graphic = (target as Selectable).GetComponent<Graphic>(); + + var animator = (target as Selectable).GetComponent<Animator>(); + m_ShowColorTint.target = (!m_TransitionProperty.hasMultipleDifferentValues && trans == Button.Transition.ColorTint); + m_ShowSpriteTrasition.target = (!m_TransitionProperty.hasMultipleDifferentValues && trans == Button.Transition.SpriteSwap); + m_ShowAnimTransition.target = (!m_TransitionProperty.hasMultipleDifferentValues && trans == Button.Transition.Animation); + + EditorGUILayout.PropertyField(m_TransitionProperty); + + ++EditorGUI.indentLevel; + { + if (trans == Selectable.Transition.ColorTint || trans == Selectable.Transition.SpriteSwap) + { + EditorGUILayout.PropertyField(m_TargetGraphicProperty); + } + + switch (trans) + { + case Selectable.Transition.ColorTint: + if (graphic == null) + EditorGUILayout.HelpBox("You must have a Graphic target in order to use a color transition.", MessageType.Warning); + break; + + case Selectable.Transition.SpriteSwap: + if (graphic as Image == null) + EditorGUILayout.HelpBox("You must have a Image target in order to use a sprite swap transition.", MessageType.Warning); + break; + } + + if (EditorGUILayout.BeginFadeGroup(m_ShowColorTint.faded)) + { + EditorGUILayout.PropertyField(m_ColorBlockProperty); + } + EditorGUILayout.EndFadeGroup(); + + if (EditorGUILayout.BeginFadeGroup(m_ShowSpriteTrasition.faded)) + { + EditorGUILayout.PropertyField(m_SpriteStateProperty); + } + EditorGUILayout.EndFadeGroup(); + + if (EditorGUILayout.BeginFadeGroup(m_ShowAnimTransition.faded)) + { + EditorGUILayout.PropertyField(m_AnimTriggerProperty); + + if (animator == null || animator.runtimeAnimatorController == null) + { + Rect buttonRect = EditorGUILayout.GetControlRect(); + buttonRect.xMin += EditorGUIUtility.labelWidth; + if (GUI.Button(buttonRect, "Auto Generate Animation", EditorStyles.miniButton)) + { + var controller = GenerateSelectableAnimatorContoller((target as Selectable).animationTriggers, target as Selectable); + if (controller != null) + { + if (animator == null) + animator = (target as Selectable).gameObject.AddComponent<Animator>(); + + Animations.AnimatorController.SetAnimatorController(animator, controller); + } + } + } + } + EditorGUILayout.EndFadeGroup(); + } + --EditorGUI.indentLevel; + + EditorGUILayout.Space(); + + EditorGUILayout.PropertyField(m_NavigationProperty); + + EditorGUI.BeginChangeCheck(); + Rect toggleRect = EditorGUILayout.GetControlRect(); + toggleRect.xMin += EditorGUIUtility.labelWidth; + s_ShowNavigation = GUI.Toggle(toggleRect, s_ShowNavigation, m_VisualizeNavigation, EditorStyles.miniButton); + if (EditorGUI.EndChangeCheck()) + { + EditorPrefs.SetBool(s_ShowNavigationKey, s_ShowNavigation); + SceneView.RepaintAll(); + } + + // We do this here to avoid requiring the user to also write a Editor for their Selectable-derived classes. + // This way if we are on a derived class we dont draw anything else, otherwise draw the remaining properties. + ChildClassPropertiesGUI(); + + serializedObject.ApplyModifiedProperties(); + } + + // Draw the extra SerializedProperties of the child class. + // We need to make sure that m_PropertyPathToExcludeForChildClasses has all the Selectable properties and in the correct order. + // TODO: find a nicer way of doing this. (creating a InheritedEditor class that automagically does this) + private void ChildClassPropertiesGUI() + { + if (IsDerivedSelectableEditor()) + return; + + DrawPropertiesExcluding(serializedObject, m_PropertyPathToExcludeForChildClasses); + } + + private bool IsDerivedSelectableEditor() + { + return GetType() != typeof(SelectableEditor); + } + + private static Animations.AnimatorController GenerateSelectableAnimatorContoller(AnimationTriggers animationTriggers, Selectable target) + { + if (target == null) + return null; + + // Where should we create the controller? + var path = GetSaveControllerPath(target); + if (string.IsNullOrEmpty(path)) + return null; + + // figure out clip names + var normalName = string.IsNullOrEmpty(animationTriggers.normalTrigger) ? "Normal" : animationTriggers.normalTrigger; + var highlightedName = string.IsNullOrEmpty(animationTriggers.highlightedTrigger) ? "Highlighted" : animationTriggers.highlightedTrigger; + var pressedName = string.IsNullOrEmpty(animationTriggers.pressedTrigger) ? "Pressed" : animationTriggers.pressedTrigger; + var disabledName = string.IsNullOrEmpty(animationTriggers.disabledTrigger) ? "Disabled" : animationTriggers.disabledTrigger; + + // Create controller and hook up transitions. + var controller = Animations.AnimatorController.CreateAnimatorControllerAtPath(path); + GenerateTriggerableTransition(normalName, controller); + GenerateTriggerableTransition(highlightedName, controller); + GenerateTriggerableTransition(pressedName, controller); + GenerateTriggerableTransition(disabledName, controller); + + AssetDatabase.ImportAsset(path); + + return controller; + } + + private static string GetSaveControllerPath(Selectable target) + { + var defaultName = target.gameObject.name; + var message = string.Format("Create a new animator for the game object '{0}':", defaultName); + return EditorUtility.SaveFilePanelInProject("New Animation Contoller", defaultName, "controller", message); + } + + private static void SetUpCurves(AnimationClip highlightedClip, AnimationClip pressedClip, string animationPath) + { + string[] channels = { "m_LocalScale.x", "m_LocalScale.y", "m_LocalScale.z" }; + + var highlightedKeys = new[] { new Keyframe(0f, 1f), new Keyframe(0.5f, 1.1f), new Keyframe(1f, 1f) }; + var highlightedCurve = new AnimationCurve(highlightedKeys); + foreach (var channel in channels) + AnimationUtility.SetEditorCurve(highlightedClip, EditorCurveBinding.FloatCurve(animationPath, typeof(Transform), channel), highlightedCurve); + + var pressedKeys = new[] { new Keyframe(0f, 1.15f) }; + var pressedCurve = new AnimationCurve(pressedKeys); + foreach (var channel in channels) + AnimationUtility.SetEditorCurve(pressedClip, EditorCurveBinding.FloatCurve(animationPath, typeof(Transform), channel), pressedCurve); + } + + private static string BuildAnimationPath(Selectable target) + { + // if no target don't hook up any curves. + var highlight = target.targetGraphic; + if (highlight == null) + return string.Empty; + + var startGo = highlight.gameObject; + var toFindGo = target.gameObject; + + var pathComponents = new Stack<string>(); + while (toFindGo != startGo) + { + pathComponents.Push(startGo.name); + + // didn't exist in hierarchy! + if (startGo.transform.parent == null) + return string.Empty; + + startGo = startGo.transform.parent.gameObject; + } + + // calculate path + var animPath = new StringBuilder(); + if (pathComponents.Count > 0) + animPath.Append(pathComponents.Pop()); + + while (pathComponents.Count > 0) + animPath.Append("/").Append(pathComponents.Pop()); + + return animPath.ToString(); + } + + private static AnimationClip GenerateTriggerableTransition(string name, Animations.AnimatorController controller) + { + // Create the clip + var clip = Animations.AnimatorController.AllocateAnimatorClip(name); + AssetDatabase.AddObjectToAsset(clip, controller); + + // Create a state in the animatior controller for this clip + var state = controller.AddMotion(clip); + + // Add a transition property + controller.AddParameter(name, AnimatorControllerParameterType.Trigger); + + // Add an any state transition + var stateMachine = controller.layers[0].stateMachine; + var transition = stateMachine.AddAnyStateTransition(state); + transition.AddCondition(Animations.AnimatorConditionMode.If, 0, name); + return clip; + } + + private static void StaticOnSceneGUI(SceneView view) + { + if (!s_ShowNavigation) + return; + + for (int i = 0; i < Selectable.allSelectables.Count; i++) + { + DrawNavigationForSelectable(Selectable.allSelectables[i]); + } + } + + private static void DrawNavigationForSelectable(Selectable sel) + { + if (sel == null) + return; + + Transform transform = sel.transform; + bool active = Selection.transforms.Any(e => e == transform); + Handles.color = new Color(1.0f, 0.9f, 0.1f, active ? 1.0f : 0.4f); + DrawNavigationArrow(-Vector2.right, sel, sel.FindSelectableOnLeft()); + DrawNavigationArrow(Vector2.right, sel, sel.FindSelectableOnRight()); + DrawNavigationArrow(Vector2.up, sel, sel.FindSelectableOnUp()); + DrawNavigationArrow(-Vector2.up, sel, sel.FindSelectableOnDown()); + } + + const float kArrowThickness = 2.5f; + const float kArrowHeadSize = 1.2f; + + private static void DrawNavigationArrow(Vector2 direction, Selectable fromObj, Selectable toObj) + { + if (fromObj == null || toObj == null) + return; + Transform fromTransform = fromObj.transform; + Transform toTransform = toObj.transform; + + Vector2 sideDir = new Vector2(direction.y, -direction.x); + Vector3 fromPoint = fromTransform.TransformPoint(GetPointOnRectEdge(fromTransform as RectTransform, direction)); + Vector3 toPoint = toTransform.TransformPoint(GetPointOnRectEdge(toTransform as RectTransform, -direction)); + float fromSize = HandleUtility.GetHandleSize(fromPoint) * 0.05f; + float toSize = HandleUtility.GetHandleSize(toPoint) * 0.05f; + fromPoint += fromTransform.TransformDirection(sideDir) * fromSize; + toPoint += toTransform.TransformDirection(sideDir) * toSize; + float length = Vector3.Distance(fromPoint, toPoint); + Vector3 fromTangent = fromTransform.rotation * direction * length * 0.3f; + Vector3 toTangent = toTransform.rotation * -direction * length * 0.3f; + + Handles.DrawBezier(fromPoint, toPoint, fromPoint + fromTangent, toPoint + toTangent, Handles.color, null, kArrowThickness); + Handles.DrawAAPolyLine(kArrowThickness, toPoint, toPoint + toTransform.rotation * (-direction - sideDir) * toSize * kArrowHeadSize); + Handles.DrawAAPolyLine(kArrowThickness, toPoint, toPoint + toTransform.rotation * (-direction + sideDir) * toSize * kArrowHeadSize); + } + + private static Vector3 GetPointOnRectEdge(RectTransform rect, Vector2 dir) + { + if (rect == null) + return Vector3.zero; + if (dir != Vector2.zero) + dir /= Mathf.Max(Mathf.Abs(dir.x), Mathf.Abs(dir.y)); + dir = rect.rect.center + Vector2.Scale(rect.rect.size, dir * 0.5f); + return dir; + } + } +} diff --git a/Assets/uGUI-2017.1/Editor/UI/SelectableEditor.cs.meta b/Assets/uGUI-2017.1/Editor/UI/SelectableEditor.cs.meta new file mode 100644 index 0000000..0384e82 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/SelectableEditor.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 1d4d444b0a1bacb46a743e88cc4da1d0 +timeCreated: 1602119377 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/Editor/UI/SelfControllerEditor.cs b/Assets/uGUI-2017.1/Editor/UI/SelfControllerEditor.cs new file mode 100644 index 0000000..4510d44 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/SelfControllerEditor.cs @@ -0,0 +1,35 @@ +using UnityEngine; +using UnityEngine.UI; + +namespace UnityEditor.UI +{ + public class SelfControllerEditor : Editor + { + static string s_Warning = "Parent has a type of layout group component. A child of a layout group should not have a {0} component, since it should be driven by the layout group."; + + public override void OnInspectorGUI() + { + bool anyHaveLayoutParent = false; + for (int i = 0; i < targets.Length; i++) + { + Component comp = (targets[i] as Component); + ILayoutIgnorer ignorer = comp.GetComponent(typeof(ILayoutIgnorer)) as ILayoutIgnorer; + if (ignorer != null && ignorer.ignoreLayout) + continue; + + RectTransform parent = comp.transform.parent as RectTransform; + if (parent != null) + { + Behaviour layoutGroup = parent.GetComponent(typeof(ILayoutGroup)) as Behaviour; + if (layoutGroup != null && layoutGroup.enabled) + { + anyHaveLayoutParent = true; + break; + } + } + } + if (anyHaveLayoutParent) + EditorGUILayout.HelpBox(string.Format(s_Warning, ObjectNames.NicifyVariableName(target.GetType().Name)), MessageType.Warning); + } + } +} diff --git a/Assets/uGUI-2017.1/Editor/UI/SelfControllerEditor.cs.meta b/Assets/uGUI-2017.1/Editor/UI/SelfControllerEditor.cs.meta new file mode 100644 index 0000000..a088542 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/SelfControllerEditor.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 1c525819dc6fd8d43b99b1eaed430ddd +timeCreated: 1602119377 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/Editor/UI/SliderEditor.cs b/Assets/uGUI-2017.1/Editor/UI/SliderEditor.cs new file mode 100644 index 0000000..f284648 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/SliderEditor.cs @@ -0,0 +1,88 @@ +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.UI; + +namespace UnityEditor.UI +{ + [CustomEditor(typeof(Slider), true)] + [CanEditMultipleObjects] + public class SliderEditor : SelectableEditor + { + SerializedProperty m_Direction; + SerializedProperty m_FillRect; + SerializedProperty m_HandleRect; + SerializedProperty m_MinValue; + SerializedProperty m_MaxValue; + SerializedProperty m_WholeNumbers; + SerializedProperty m_Value; + SerializedProperty m_OnValueChanged; + + protected override void OnEnable() + { + base.OnEnable(); + m_FillRect = serializedObject.FindProperty("m_FillRect"); + m_HandleRect = serializedObject.FindProperty("m_HandleRect"); + m_Direction = serializedObject.FindProperty("m_Direction"); + m_MinValue = serializedObject.FindProperty("m_MinValue"); + m_MaxValue = serializedObject.FindProperty("m_MaxValue"); + m_WholeNumbers = serializedObject.FindProperty("m_WholeNumbers"); + m_Value = serializedObject.FindProperty("m_Value"); + m_OnValueChanged = serializedObject.FindProperty("m_OnValueChanged"); + } + + public override void OnInspectorGUI() + { + base.OnInspectorGUI(); + EditorGUILayout.Space(); + + serializedObject.Update(); + + EditorGUILayout.PropertyField(m_FillRect); + EditorGUILayout.PropertyField(m_HandleRect); + + if (m_FillRect.objectReferenceValue != null || m_HandleRect.objectReferenceValue != null) + { + EditorGUI.BeginChangeCheck(); + EditorGUILayout.PropertyField(m_Direction); + if (EditorGUI.EndChangeCheck()) + { + Slider.Direction direction = (Slider.Direction)m_Direction.enumValueIndex; + foreach (var obj in serializedObject.targetObjects) + { + Slider slider = obj as Slider; + slider.SetDirection(direction, true); + } + } + + EditorGUILayout.PropertyField(m_MinValue); + EditorGUILayout.PropertyField(m_MaxValue); + EditorGUILayout.PropertyField(m_WholeNumbers); + EditorGUILayout.Slider(m_Value, m_MinValue.floatValue, m_MaxValue.floatValue); + + bool warning = false; + foreach (var obj in serializedObject.targetObjects) + { + Slider slider = obj as Slider; + Slider.Direction dir = slider.direction; + if (dir == Slider.Direction.LeftToRight || dir == Slider.Direction.RightToLeft) + warning = (slider.navigation.mode != Navigation.Mode.Automatic && (slider.FindSelectableOnLeft() != null || slider.FindSelectableOnRight() != null)); + else + warning = (slider.navigation.mode != Navigation.Mode.Automatic && (slider.FindSelectableOnDown() != null || slider.FindSelectableOnUp() != null)); + } + + if (warning) + EditorGUILayout.HelpBox("The selected slider direction conflicts with navigation. Not all navigation options may work.", MessageType.Warning); + + // Draw the event notification options + EditorGUILayout.Space(); + EditorGUILayout.PropertyField(m_OnValueChanged); + } + else + { + EditorGUILayout.HelpBox("Specify a RectTransform for the slider fill or the slider handle or both. Each must have a parent RectTransform that it can slide within.", MessageType.Info); + } + + serializedObject.ApplyModifiedProperties(); + } + } +} diff --git a/Assets/uGUI-2017.1/Editor/UI/SliderEditor.cs.meta b/Assets/uGUI-2017.1/Editor/UI/SliderEditor.cs.meta new file mode 100644 index 0000000..b313067 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/SliderEditor.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 778a137b5ae337b4db4a47f1d34442b1 +timeCreated: 1602119379 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/Editor/UI/SpriteDrawUtility.cs b/Assets/uGUI-2017.1/Editor/UI/SpriteDrawUtility.cs new file mode 100644 index 0000000..32b9498 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/SpriteDrawUtility.cs @@ -0,0 +1,200 @@ +using System.Collections.Generic; +using UnityEngine; + +namespace UnityEditor.UI +{ + // Tools for the editor + internal class SpriteDrawUtility + { + static Texture2D s_ContrastTex; + + // Returns a usable texture that looks like a high-contrast checker board. + static Texture2D contrastTexture + { + get + { + if (s_ContrastTex == null) + s_ContrastTex = CreateCheckerTex( + new Color(0f, 0.0f, 0f, 0.5f), + new Color(1f, 1f, 1f, 0.5f)); + return s_ContrastTex; + } + } + + // Create a checker-background texture. + static Texture2D CreateCheckerTex(Color c0, Color c1) + { + Texture2D tex = new Texture2D(16, 16); + tex.name = "[Generated] Checker Texture"; + tex.hideFlags = HideFlags.DontSave; + + for (int y = 0; y < 8; ++y) for (int x = 0; x < 8; ++x) tex.SetPixel(x, y, c1); + for (int y = 8; y < 16; ++y) for (int x = 0; x < 8; ++x) tex.SetPixel(x, y, c0); + for (int y = 0; y < 8; ++y) for (int x = 8; x < 16; ++x) tex.SetPixel(x, y, c0); + for (int y = 8; y < 16; ++y) for (int x = 8; x < 16; ++x) tex.SetPixel(x, y, c1); + + tex.Apply(); + tex.filterMode = FilterMode.Point; + return tex; + } + + // Create a gradient texture. + static Texture2D CreateGradientTex() + { + Texture2D tex = new Texture2D(1, 16); + tex.name = "[Generated] Gradient Texture"; + tex.hideFlags = HideFlags.DontSave; + + Color c0 = new Color(1f, 1f, 1f, 0f); + Color c1 = new Color(1f, 1f, 1f, 0.4f); + + for (int i = 0; i < 16; ++i) + { + float f = Mathf.Abs((i / 15f) * 2f - 1f); + f *= f; + tex.SetPixel(0, i, Color.Lerp(c0, c1, f)); + } + + tex.Apply(); + tex.filterMode = FilterMode.Bilinear; + return tex; + } + + // Draws the tiled texture. Like GUI.DrawTexture() but tiled instead of stretched. + static void DrawTiledTexture(Rect rect, Texture tex) + { + float u = rect.width / tex.width; + float v = rect.height / tex.height; + + Rect texCoords = new Rect(0, 0, u, v); + TextureWrapMode originalMode = tex.wrapMode; + tex.wrapMode = TextureWrapMode.Repeat; + GUI.DrawTextureWithTexCoords(rect, tex, texCoords); + tex.wrapMode = originalMode; + } + + // Draw the specified Image. + public static void DrawSprite(Sprite sprite, Rect drawArea, Color color) + { + if (sprite == null) + return; + + Texture2D tex = sprite.texture; + if (tex == null) + return; + + Rect outer = sprite.rect; + Rect inner = outer; + inner.xMin += sprite.border.x; + inner.yMin += sprite.border.y; + inner.xMax -= sprite.border.z; + inner.yMax -= sprite.border.w; + + Vector4 uv4 = UnityEngine.Sprites.DataUtility.GetOuterUV(sprite); + Rect uv = new Rect(uv4.x, uv4.y, uv4.z - uv4.x, uv4.w - uv4.y); + Vector4 padding = UnityEngine.Sprites.DataUtility.GetPadding(sprite); + padding.x /= outer.width; + padding.y /= outer.height; + padding.z /= outer.width; + padding.w /= outer.height; + + DrawSprite(tex, drawArea, padding, outer, inner, uv, color, null); + } + + // Draw the specified Image. + public static void DrawSprite(Texture tex, Rect drawArea, Rect outer, Rect uv, Color color) + { + DrawSprite(tex, drawArea, Vector4.zero, outer, outer, uv, color, null); + } + + // Draw the specified Image. + private static void DrawSprite(Texture tex, Rect drawArea, Vector4 padding, Rect outer, Rect inner, Rect uv, Color color, Material mat) + { + // Create the texture rectangle that is centered inside rect. + Rect outerRect = drawArea; + outerRect.width = Mathf.Abs(outer.width); + outerRect.height = Mathf.Abs(outer.height); + + if (outerRect.width > 0f) + { + float f = drawArea.width / outerRect.width; + outerRect.width *= f; + outerRect.height *= f; + } + + if (drawArea.height > outerRect.height) + { + outerRect.y += (drawArea.height - outerRect.height) * 0.5f; + } + else if (outerRect.height > drawArea.height) + { + float f = drawArea.height / outerRect.height; + outerRect.width *= f; + outerRect.height *= f; + } + + if (drawArea.width > outerRect.width) + outerRect.x += (drawArea.width - outerRect.width) * 0.5f; + + // Draw the background + EditorGUI.DrawTextureTransparent(outerRect, null, ScaleMode.ScaleToFit, outer.width / outer.height); + + // Draw the Image + GUI.color = color; + + Rect paddedTexArea = new Rect( + outerRect.x + outerRect.width * padding.x, + outerRect.y + outerRect.height * padding.w, + outerRect.width - (outerRect.width * (padding.z + padding.x)), + outerRect.height - (outerRect.height * (padding.w + padding.y)) + ); + + if (mat == null) + { + GL.sRGBWrite = QualitySettings.activeColorSpace == ColorSpace.Linear; + GUI.DrawTextureWithTexCoords(paddedTexArea, tex, uv, true); + GL.sRGBWrite = false; + } + else + { + // NOTE: There is an issue in Unity that prevents it from clipping the drawn preview + // using BeginGroup/EndGroup, and there is no way to specify a UV rect... + EditorGUI.DrawPreviewTexture(paddedTexArea, tex, mat); + } + + // Draw the border indicator lines + GUI.BeginGroup(outerRect); + { + tex = contrastTexture; + GUI.color = Color.white; + + if (inner.xMin != outer.xMin) + { + float x = (inner.xMin - outer.xMin) / outer.width * outerRect.width - 1; + DrawTiledTexture(new Rect(x, 0f, 1f, outerRect.height), tex); + } + + if (inner.xMax != outer.xMax) + { + float x = (inner.xMax - outer.xMin) / outer.width * outerRect.width - 1; + DrawTiledTexture(new Rect(x, 0f, 1f, outerRect.height), tex); + } + + if (inner.yMin != outer.yMin) + { + // GUI.DrawTexture is top-left based rather than bottom-left + float y = (inner.yMin - outer.yMin) / outer.height * outerRect.height - 1; + DrawTiledTexture(new Rect(0f, outerRect.height - y, outerRect.width, 1f), tex); + } + + if (inner.yMax != outer.yMax) + { + float y = (inner.yMax - outer.yMin) / outer.height * outerRect.height - 1; + DrawTiledTexture(new Rect(0f, outerRect.height - y, outerRect.width, 1f), tex); + } + } + + GUI.EndGroup(); + } + } +} diff --git a/Assets/uGUI-2017.1/Editor/UI/SpriteDrawUtility.cs.meta b/Assets/uGUI-2017.1/Editor/UI/SpriteDrawUtility.cs.meta new file mode 100644 index 0000000..eafacaa --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/SpriteDrawUtility.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: fb3e0854e2906b14289d932ddbf67d55 +timeCreated: 1602119380 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/Editor/UI/TextEditor.cs b/Assets/uGUI-2017.1/Editor/UI/TextEditor.cs new file mode 100644 index 0000000..b818f21 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/TextEditor.cs @@ -0,0 +1,40 @@ +using UnityEngine; +using UnityEngine.UI; + +namespace UnityEditor.UI +{ + // TODO REVIEW + // Have material live under text + // move stencil mask into effects *make an efects top level element like there is + // paragraph and character + + /// <summary> + /// Editor class used to edit UI Labels. + /// </summary> + + [CustomEditor(typeof(Text), true)] + [CanEditMultipleObjects] + public class TextEditor : GraphicEditor + { + SerializedProperty m_Text; + SerializedProperty m_FontData; + + protected override void OnEnable() + { + base.OnEnable(); + m_Text = serializedObject.FindProperty("m_Text"); + m_FontData = serializedObject.FindProperty("m_FontData"); + } + + public override void OnInspectorGUI() + { + serializedObject.Update(); + + EditorGUILayout.PropertyField(m_Text); + EditorGUILayout.PropertyField(m_FontData); + AppearanceControlsGUI(); + RaycastControlsGUI(); + serializedObject.ApplyModifiedProperties(); + } + } +} diff --git a/Assets/uGUI-2017.1/Editor/UI/TextEditor.cs.meta b/Assets/uGUI-2017.1/Editor/UI/TextEditor.cs.meta new file mode 100644 index 0000000..04e20ed --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/TextEditor.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: c6bec5fe73b6cdc4486c22e79e6ef095 +timeCreated: 1602119380 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uGUI-2017.1/Editor/UI/ToggleEditor.cs b/Assets/uGUI-2017.1/Editor/UI/ToggleEditor.cs new file mode 100644 index 0000000..632e4d0 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/ToggleEditor.cs @@ -0,0 +1,46 @@ +using UnityEngine; +using UnityEngine.UI; + +namespace UnityEditor.UI +{ + [CustomEditor(typeof(Toggle), true)] + [CanEditMultipleObjects] + public class ToggleEditor : SelectableEditor + { + SerializedProperty m_OnValueChangedProperty; + SerializedProperty m_TransitionProperty; + SerializedProperty m_GraphicProperty; + SerializedProperty m_GroupProperty; + SerializedProperty m_IsOnProperty; + + protected override void OnEnable() + { + base.OnEnable(); + + m_TransitionProperty = serializedObject.FindProperty("toggleTransition"); + m_GraphicProperty = serializedObject.FindProperty("graphic"); + m_GroupProperty = serializedObject.FindProperty("m_Group"); + m_IsOnProperty = serializedObject.FindProperty("m_IsOn"); + m_OnValueChangedProperty = serializedObject.FindProperty("onValueChanged"); + } + + public override void OnInspectorGUI() + { + base.OnInspectorGUI(); + EditorGUILayout.Space(); + + serializedObject.Update(); + EditorGUILayout.PropertyField(m_IsOnProperty); + EditorGUILayout.PropertyField(m_TransitionProperty); + EditorGUILayout.PropertyField(m_GraphicProperty); + EditorGUILayout.PropertyField(m_GroupProperty); + + EditorGUILayout.Space(); + + // Draw the event notification options + EditorGUILayout.PropertyField(m_OnValueChangedProperty); + + serializedObject.ApplyModifiedProperties(); + } + } +} diff --git a/Assets/uGUI-2017.1/Editor/UI/ToggleEditor.cs.meta b/Assets/uGUI-2017.1/Editor/UI/ToggleEditor.cs.meta new file mode 100644 index 0000000..18f05c3 --- /dev/null +++ b/Assets/uGUI-2017.1/Editor/UI/ToggleEditor.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 5c004313ae1b2fb40986d6453e88b8bf +timeCreated: 1602119378 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: |