Пример #1
0
 protected override void OnEnable()
 {
   base.OnEnable();
   this.m_SpriteContent = new GUIContent("Source Image");
   this.m_SpriteTypeContent = new GUIContent("Image Type");
   this.m_ClockwiseContent = new GUIContent("Clockwise");
   this.m_Sprite = this.serializedObject.FindProperty("m_Sprite");
   this.m_Type = this.serializedObject.FindProperty("m_Type");
   this.m_FillCenter = this.serializedObject.FindProperty("m_FillCenter");
   this.m_FillMethod = this.serializedObject.FindProperty("m_FillMethod");
   this.m_FillOrigin = this.serializedObject.FindProperty("m_FillOrigin");
   this.m_FillClockwise = this.serializedObject.FindProperty("m_FillClockwise");
   this.m_FillAmount = this.serializedObject.FindProperty("m_FillAmount");
   this.m_PreserveAspect = this.serializedObject.FindProperty("m_PreserveAspect");
   this.m_ShowType = new AnimBool(this.m_Sprite.objectReferenceValue != (UnityEngine.Object) null);
   this.m_ShowType.valueChanged.AddListener(new UnityAction(((Editor) this).Repaint));
   Image.Type enumValueIndex = (Image.Type) this.m_Type.enumValueIndex;
   this.m_ShowSlicedOrTiled = new AnimBool(!this.m_Type.hasMultipleDifferentValues && enumValueIndex == Image.Type.Sliced);
   this.m_ShowSliced = new AnimBool(!this.m_Type.hasMultipleDifferentValues && enumValueIndex == Image.Type.Sliced);
   this.m_ShowFilled = new AnimBool(!this.m_Type.hasMultipleDifferentValues && enumValueIndex == Image.Type.Filled);
   this.m_ShowSlicedOrTiled.valueChanged.AddListener(new UnityAction(((Editor) this).Repaint));
   this.m_ShowSliced.valueChanged.AddListener(new UnityAction(((Editor) this).Repaint));
   this.m_ShowFilled.valueChanged.AddListener(new UnityAction(((Editor) this).Repaint));
   this.SetShowNativeSize(true);
 }
		public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) {
			
			EditorGUI.PropertyField(position, property, label, includeChildren: true);

			var attribute = PropertyExtensions.GetAttribute<BeginGroupAttribute>(this);
			var otherProp = PropertyExtensions.GetRelativeProperty(property, property.propertyPath, attribute.otherFieldName);

			var isNull = false;
			if (property.propertyType == SerializedPropertyType.ObjectReference) {

				isNull = (property.objectReferenceValue == null);

			}

			if (isNull == true && otherProp != null) {

				if (otherProp.propertyType == SerializedPropertyType.ObjectReference) {

					isNull = (otherProp.objectReferenceValue == null);

				}

			}

			++EditorGUI.indentLevel;
			EditorGUI.BeginDisabledGroup(isNull);

			CustomGUI.Splitter();

		}
 protected virtual void OnEnable()
 {
   this.m_Script = this.serializedObject.FindProperty("m_Script");
   this.m_InteractableProperty = this.serializedObject.FindProperty("m_Interactable");
   this.m_TargetGraphicProperty = this.serializedObject.FindProperty("m_TargetGraphic");
   this.m_TransitionProperty = this.serializedObject.FindProperty("m_Transition");
   this.m_ColorBlockProperty = this.serializedObject.FindProperty("m_Colors");
   this.m_SpriteStateProperty = this.serializedObject.FindProperty("m_SpriteState");
   this.m_AnimTriggerProperty = this.serializedObject.FindProperty("m_AnimationTriggers");
   this.m_NavigationProperty = this.serializedObject.FindProperty("m_Navigation");
   this.m_PropertyPathToExcludeForChildClasses = new string[8]
   {
     this.m_Script.propertyPath,
     this.m_NavigationProperty.propertyPath,
     this.m_TransitionProperty.propertyPath,
     this.m_ColorBlockProperty.propertyPath,
     this.m_SpriteStateProperty.propertyPath,
     this.m_AnimTriggerProperty.propertyPath,
     this.m_InteractableProperty.propertyPath,
     this.m_TargetGraphicProperty.propertyPath
   };
   Selectable.Transition transition = SelectableEditor.GetTransition(this.m_TransitionProperty);
   this.m_ShowColorTint.value = transition == Selectable.Transition.ColorTint;
   this.m_ShowSpriteTrasition.value = transition == Selectable.Transition.SpriteSwap;
   this.m_ShowAnimTransition.value = transition == Selectable.Transition.Animation;
   this.m_ShowColorTint.valueChanged.AddListener(new UnityAction(((Editor) this).Repaint));
   this.m_ShowSpriteTrasition.valueChanged.AddListener(new UnityAction(((Editor) this).Repaint));
   SelectableEditor.s_Editors.Add(this);
   this.RegisterStaticOnSceneGUI();
   SelectableEditor.s_ShowNavigation = EditorPrefs.GetBool(SelectableEditor.s_ShowNavigationKey);
 }
Пример #4
0
        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);

            var height = m_FontFieldfHeight
                + m_FontStyleHeight
                + m_FontSizeHeight
                + m_LineSpacingHeight
                + m_EncodingHeight
                + m_ResizeTextForBestFitHeight
                + m_HorizontalOverflowHeight
                + m_VerticalOverflowHeight
                + EditorGUIUtility.singleLineHeight * 3
                + EditorGUIUtility.standardVerticalSpacing * 10;

            if (m_ResizeTextForBestFit.boolValue)
            {
                height += m_ResizeTextMinSizeHeight
                    + m_ResizeTextMaxSizeHeight
                    + EditorGUIUtility.standardVerticalSpacing * 2;
            }
            return height;
        }
		protected override void OnEnable() {

			base.OnEnable();

			this.transition = this.serializedObject.FindProperty("m_Transition");
			this.transitionExtended = serializedObject.FindProperty("transitionExtended");
			
			extScaleBlockProperty = serializedObject.FindProperty("m_Scale");
			extAlphaBlockProperty = serializedObject.FindProperty("m_Alpha");
			extColorBlockProperty = serializedObject.FindProperty("m_Colors");
			extSpriteStateProperty = serializedObject.FindProperty("m_SpriteState");
			extAnimTriggerProperty = serializedObject.FindProperty("m_AnimationTriggers");
			extTargetGraphicProperty = serializedObject.FindProperty("m_TargetGraphic");

			var trans = GetTransition(this.transitionExtended);
			extShowScale.value = (trans & ButtonExtended.Transition.Scale) != 0;
			extShowAlpha.value = (trans & ButtonExtended.Transition.CanvasGroupAlpha) != 0;
			extShowColorTint.value = (trans & ButtonExtended.Transition.ColorTint) != 0;
			extShowSpriteTrasition.value = (trans & ButtonExtended.Transition.SpriteSwap) != 0;
			extShowAnimTransition.value = (trans & ButtonExtended.Transition.Animation) != 0;
			
			extShowScale.valueChanged.AddListener(Repaint);
			extShowAlpha.valueChanged.AddListener(Repaint);
			extShowColorTint.valueChanged.AddListener(Repaint);
			extShowSpriteTrasition.valueChanged.AddListener(Repaint);

		}
Пример #6
0
        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);
        }
Пример #7
0
        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_ShowFilled = new AnimBool(!m_Type.hasMultipleDifferentValues && typeEnum == Image.Type.Filled);
            m_ShowSlicedOrTiled.valueChanged.AddListener(Repaint);
            m_ShowSliced.valueChanged.AddListener(Repaint);
            m_ShowFilled.valueChanged.AddListener(Repaint);

            SetShowNativeSize(true);
        }
Пример #8
0
 public override void OnEnable()
 {
     m_Colored = FindSetting((Settings x) => x.colored);
     m_Intensity = FindSetting((Settings x) => x.intensity);
     m_Size = FindSetting((Settings x) => x.size);
     m_LuminanceContribution = FindSetting((Settings x) => x.luminanceContribution);
 }
Пример #9
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            var attribute = (GetSetAttribute)base.attribute;

            EditorGUI.BeginChangeCheck();
            EditorGUI.PropertyField(position, property, label);

            if (EditorGUI.EndChangeCheck())
            {
                attribute.dirty = true;
            }
            else if (attribute.dirty)
            {
                var parent = ReflectionUtils.GetParentObject(property.propertyPath, property.serializedObject.targetObject);

                var type = parent.GetType();
                var info = type.GetProperty(attribute.name);

                if (info == null)
                    Debug.LogError("Invalid property name \"" + attribute.name + "\"");
                else
                    info.SetValue(parent, fieldInfo.GetValue(parent), null);

                attribute.dirty = false;
            }
        }
 public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
 {
   if (NavigationDrawer.s_Styles == null)
     NavigationDrawer.s_Styles = new NavigationDrawer.Styles();
   Rect position = pos;
   position.height = EditorGUIUtility.singleLineHeight;
   SerializedProperty propertyRelative1 = prop.FindPropertyRelative("m_Mode");
   Navigation.Mode navigationMode = NavigationDrawer.GetNavigationMode(propertyRelative1);
   EditorGUI.PropertyField(position, propertyRelative1, NavigationDrawer.s_Styles.navigationContent);
   ++EditorGUI.indentLevel;
   position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
   if (navigationMode == Navigation.Mode.Explicit)
   {
     SerializedProperty propertyRelative2 = prop.FindPropertyRelative("m_SelectOnUp");
     SerializedProperty propertyRelative3 = prop.FindPropertyRelative("m_SelectOnDown");
     SerializedProperty propertyRelative4 = prop.FindPropertyRelative("m_SelectOnLeft");
     SerializedProperty propertyRelative5 = prop.FindPropertyRelative("m_SelectOnRight");
     EditorGUI.PropertyField(position, propertyRelative2);
     position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
     EditorGUI.PropertyField(position, propertyRelative3);
     position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
     EditorGUI.PropertyField(position, propertyRelative4);
     position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
     EditorGUI.PropertyField(position, propertyRelative5);
     position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
   }
   --EditorGUI.indentLevel;
 }
        public override void OnGUI(Rect rect, SerializedProperty prop, GUIContent label)
        {
            Rect position = rect;
            position.height = EditorGUIUtility.singleLineHeight;
            SerializedProperty property = prop.FindPropertyRelative("m_NormalTrigger");
            SerializedProperty property2 = prop.FindPropertyRelative("m_HighlightedTrigger");
            SerializedProperty property3 = prop.FindPropertyRelative("m_PressedTrigger");
            SerializedProperty property4 = prop.FindPropertyRelative("m_ActiveTrigger");
            SerializedProperty property5 = prop.FindPropertyRelative("m_ActiveHighlightedTrigger");
            SerializedProperty property6 = prop.FindPropertyRelative("m_ActivePressedTrigger");
            SerializedProperty property7 = prop.FindPropertyRelative("m_DisabledTrigger");

            EditorGUI.PropertyField(position, property);
            position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
            EditorGUI.PropertyField(position, property2);
            position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
            EditorGUI.PropertyField(position, property3);
            position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
            EditorGUI.PropertyField(position, property4);
            position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
            EditorGUI.PropertyField(position, property5);
            position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
            EditorGUI.PropertyField(position, property6);
            position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
            EditorGUI.PropertyField(position, property7);
        }
Пример #12
0
        public static bool Header(string title, SerializedProperty group)
        {
            var rect = GUILayoutUtility.GetRect(16f, 22f, FxStyles.header);
            GUI.Box(rect, title, FxStyles.header);

            var display = group == null || group.isExpanded;

            var foldoutRect = new Rect(rect.x + 4f, rect.y + 2f, 13f, 13f);
            var e = Event.current;

            if (e.type == EventType.Repaint)
                FxStyles.headerFoldout.Draw(foldoutRect, false, false, display, false);

            if (e.type == EventType.MouseDown)
            {
                if (rect.Contains(e.mousePosition))
                {
                    display = !display;

                    if (group != null)
                        group.isExpanded = !group.isExpanded;

                    e.Use();
                }
            }

            return display;
        }
Пример #13
0
            void EditorMode()
            {
                EditorGUILayout.LabelField("Built in fields", EditorStyles.boldLabel);
                EditorGUILayout.Separator();
                foreach (string name in System.Enum.GetNames(typeof(NetworkFields.SynchronizedField))) {
                    if (name.StartsWith("Userdef")) {
                        continue;
                    }
                    string propName;
                    SerializedProperty prop;
                    string baseName = System.Char.ToLowerInvariant(name[0]) + name.Substring(1);

                    propName = baseName + "Enabled";
                    prop = so.FindProperty(propName);

                    if (prop != null) {
                        prop.boolValue = EditorGUILayout.Toggle(prop.displayName.Replace("Enabled", ""), prop.boolValue);
                    }

                }

                EditorGUILayout.Separator();
                EditorGUILayout.Separator();
                EditorGUILayout.LabelField("User defined fields", EditorStyles.boldLabel);
                EditorGUILayout.Separator();
                foreach (string name in System.Enum.GetNames(typeof(NetworkFields.SynchronizedField))) {

                    if (!name.StartsWith("Userdef")) {
                        continue;
                    }
                    string propName;
                    SerializedProperty prop;
                    string baseName = System.Char.ToLowerInvariant(name[0]) + name.Substring(1);

                    propName = baseName + "Enabled";
                    prop = so.FindProperty(propName);

                    if (prop != null) {
                        prop.boolValue = EditorGUILayout.Toggle(prop.displayName.Replace("Enabled", ""), prop.boolValue);
                    }

                    propName = baseName + "Type";
                    prop = so.FindProperty(propName);
                    string label = baseName;
                    //EditorGUILayout.LabelField(prop.displayName);

                    prop = so.FindProperty(propName);
                    if (prop != null) {
                        prop.enumValueIndex = EditorGUILayout.Popup("Type", prop.enumValueIndex, System.Enum.GetNames(typeof(NetworkFields.UserDefValue)));
                    }

                    string friendlyName = baseName + "Name";
                    prop = so.FindProperty(friendlyName);
                    if (prop != null) {
                        prop.stringValue = EditorGUILayout.TextField("Name", prop.stringValue);
                    }
                    EditorGUILayout.Separator();
                }
            }
		protected override void OnEnable() {
			
			base.OnEnable();
			
			this.label = base.serializedObject.FindProperty("label");
			this.labelColor = base.serializedObject.FindProperty("labelColor");
			
		}
		protected override void OnEnable() {

			base.OnEnable();
			
			this.rootButton = base.serializedObject.FindProperty("rootButton");
			this.referenceButton = base.serializedObject.FindProperty("referenceButton");

		}
Пример #16
0
 public override void OnEnable()
 {
     m_FocusDistance = FindSetting((Settings x) => x.focusDistance);
     m_Aperture = FindSetting((Settings x) => x.aperture);
     m_FocalLength = FindSetting((Settings x) => x.focalLength);
     m_UseCameraFov = FindSetting((Settings x) => x.useCameraFov);
     m_KernelSize = FindSetting((Settings x) => x.kernelSize);
 }
		public void OnEnable() {
			
			this.prefab = this.serializedObject.FindProperty("prefab");
			this.prefabParameters = this.serializedObject.FindProperty("prefabParameters");

			this.oldComponent = this.prefab.objectReferenceValue as WindowComponent;

		}
Пример #18
0
 protected override void OnEnable()
 {
   base.OnEnable();
   this.m_UVRectContent = new GUIContent("UV Rect");
   this.m_Texture = this.serializedObject.FindProperty("m_Texture");
   this.m_UVRect = this.serializedObject.FindProperty("m_UVRect");
   this.SetShowNativeSize(true);
 }
 protected virtual void OnEnable()
 {
     m_Padding = serializedObject.FindProperty("m_Padding");
     m_Spacing = serializedObject.FindProperty("m_Spacing");
     m_ChildAlignment = serializedObject.FindProperty("m_ChildAlignment");
     m_ChildForceExpandWidth = serializedObject.FindProperty("m_ChildForceExpandWidth");
     m_ChildForceExpandHeight = serializedObject.FindProperty("m_ChildForceExpandHeight");
 }
Пример #20
0
 protected override void OnEnable()
 {
   base.OnEnable();
   this.m_TransitionProperty = this.serializedObject.FindProperty("toggleTransition");
   this.m_GraphicProperty = this.serializedObject.FindProperty("graphic");
   this.m_GroupProperty = this.serializedObject.FindProperty("m_Group");
   this.m_IsOnProperty = this.serializedObject.FindProperty("m_IsOn");
   this.m_OnValueChangedProperty = this.serializedObject.FindProperty("onValueChanged");
 }
 private void LayoutElementField(SerializedProperty property, float defaultValue)
 {
   // ISSUE: object of a compiler-generated type is created
   // ISSUE: reference to a compiler-generated method
   this.LayoutElementField(property, new Func<RectTransform, float>(new LayoutElementEditor.\u003CLayoutElementField\u003Ec__AnonStorey2()
   {
     defaultValue = defaultValue
   }.\u003C\u003Em__7));
 }
		public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) {

			EditorGUI.PropertyField(position, property, label, includeChildren: true);

			CustomGUI.Splitter();

			EditorGUI.EndDisabledGroup();
			--EditorGUI.indentLevel;

		}
Пример #23
0
 protected virtual void OnEnable()
 {
   this.m_CorrectButtonContent = new GUIContent("Set Native Size", "Sets the size to match the content.");
   this.m_Script = this.serializedObject.FindProperty("m_Script");
   this.m_Color = this.serializedObject.FindProperty("m_Color");
   this.m_Material = this.serializedObject.FindProperty("m_Material");
   this.m_RaycastTarget = this.serializedObject.FindProperty("m_RaycastTarget");
   this.m_ShowNativeSize = new AnimBool(false);
   this.m_ShowNativeSize.valueChanged.AddListener(new UnityAction(((Editor) this).Repaint));
 }
		public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) {

			base.OnGUI(position, property, label);

			CustomGUI.Splitter();

			EditorGUI.EndDisabledGroup();
			--EditorGUI.indentLevel;

		}
 private void Init(SerializedProperty property)
 {
   if (this.m_ReorderableList != null)
     return;
   SerializedProperty propertyRelative = property.FindPropertyRelative("m_Options");
   this.m_ReorderableList = new ReorderableList(property.serializedObject, propertyRelative);
   this.m_ReorderableList.drawElementCallback = new ReorderableList.ElementCallbackDelegate(this.DrawOptionData);
   this.m_ReorderableList.drawHeaderCallback = new ReorderableList.HeaderCallbackDelegate(this.DrawHeader);
   this.m_ReorderableList.elementHeight += 16f;
 }
 protected override void OnEnable()
 {
   base.OnEnable();
   this.m_HandleRect = this.serializedObject.FindProperty("m_HandleRect");
   this.m_Direction = this.serializedObject.FindProperty("m_Direction");
   this.m_Value = this.serializedObject.FindProperty("m_Value");
   this.m_Size = this.serializedObject.FindProperty("m_Size");
   this.m_NumberOfSteps = this.serializedObject.FindProperty("m_NumberOfSteps");
   this.m_OnValueChanged = this.serializedObject.FindProperty("m_OnValueChanged");
 }
 protected virtual void OnEnable()
 {
   this.m_IgnoreLayout = this.serializedObject.FindProperty("m_IgnoreLayout");
   this.m_MinWidth = this.serializedObject.FindProperty("m_MinWidth");
   this.m_MinHeight = this.serializedObject.FindProperty("m_MinHeight");
   this.m_PreferredWidth = this.serializedObject.FindProperty("m_PreferredWidth");
   this.m_PreferredHeight = this.serializedObject.FindProperty("m_PreferredHeight");
   this.m_FlexibleWidth = this.serializedObject.FindProperty("m_FlexibleWidth");
   this.m_FlexibleHeight = this.serializedObject.FindProperty("m_FlexibleHeight");
 }
Пример #28
0
 public override void OnEnable()
 {
     m_Intensity = FindSetting((Settings x) => x.intensity);
     m_Radius = FindSetting((Settings x) => x.radius);
     m_SampleCount = FindSetting((Settings x) => x.sampleCount);
     m_Downsampling = FindSetting((Settings x) => x.downsampling);
     m_ForceForwardCompatibility = FindSetting((Settings x) => x.forceForwardCompatibility);
     m_AmbientOnly = FindSetting((Settings x) => x.ambientOnly);
     m_HighPrecision = FindSetting((Settings x) => x.highPrecision);
 }
Пример #29
0
 public override void OnEnable()
 {
     m_Mode = FindSetting((Settings x) => x.mode);
     m_Color = FindSetting((Settings x) => x.color);
     m_Center = FindSetting((Settings x) => x.center);
     m_Intensity = FindSetting((Settings x) => x.intensity);
     m_Smoothness = FindSetting((Settings x) => x.smoothness);
     m_Roundness = FindSetting((Settings x) => x.roundness);
     m_Mask = FindSetting((Settings x) => x.mask);
     m_Opacity = FindSetting((Settings x) => x.opacity);
 }
 protected virtual void OnEnable()
 {
   this.m_Padding = this.serializedObject.FindProperty("m_Padding");
   this.m_CellSize = this.serializedObject.FindProperty("m_CellSize");
   this.m_Spacing = this.serializedObject.FindProperty("m_Spacing");
   this.m_StartCorner = this.serializedObject.FindProperty("m_StartCorner");
   this.m_StartAxis = this.serializedObject.FindProperty("m_StartAxis");
   this.m_ChildAlignment = this.serializedObject.FindProperty("m_ChildAlignment");
   this.m_Constraint = this.serializedObject.FindProperty("m_Constraint");
   this.m_ConstraintCount = this.serializedObject.FindProperty("m_ConstraintCount");
 }
Пример #31
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            drawPrefixLabel = false;

            Begin(position, property, label);

            EditorGUI.BeginChangeCheck();

            var enumValues = Enum.GetValues(fieldInfo.FieldType);
            int value      = (int)enumValues.GetValue(property.GetValue <int>());
            var options    = GetDisplayOptions();

            value = EditorGUI.MaskField(currentPosition, label, value, options);

            if (EditorGUI.EndChangeCheck())
            {
                object enumValue = value == -1 ? Array.IndexOf(enumValues, Enum.ToObject(fieldInfo.FieldType, SumOptions(options))) : Array.IndexOf(enumValues, Enum.ToObject(fieldInfo.FieldType, value));
                property.SetValue(enumValue);
            }

            End();
        }
Пример #32
0
        public static bool EditorDrawBoolProperty(SerializedObject serializedObject, string propertyName, string label = null, string tooltip = null)
        {
            SerializedProperty serializedProperty = GetSerializedProperty(serializedObject, propertyName);

            if (serializedProperty != null)
            {
                if (label == null)
                {
                    EditorGUILayout.PropertyField(serializedProperty);
                }
                else if (label.Length == 0)
                {
                    EditorGUILayout.PropertyField(serializedProperty, GUIContent.none);
                }
                else
                {
                    EditorGUILayout.PropertyField(serializedProperty, new GUIContent(label, tooltip));
                }
                return(true);
            }
            return(false);
        }
Пример #33
0
        //https://forum.unity.com/threads/loop-through-serializedproperty-children.435119/#post-5333913

        /// <summary>
        /// Gets visible children of `SerializedProperty` at 1 level depth.
        /// </summary>
        /// <param name="serializedProperty">Parent `SerializedProperty`.</param>
        /// <returns>Collection of `SerializedProperty` children.</returns>
        public static IEnumerable <SerializedProperty> GetVisibleChildren(this SerializedProperty serializedProperty)
        {
            SerializedProperty currentProperty     = serializedProperty.Copy();
            SerializedProperty nextSiblingProperty = serializedProperty.Copy();

            {
                nextSiblingProperty.NextVisible(false);
            }

            if (currentProperty.NextVisible(true))
            {
                do
                {
                    if (SerializedProperty.EqualContents(currentProperty, nextSiblingProperty))
                    {
                        break;
                    }

                    yield return(currentProperty.Copy());
                }while (currentProperty.NextVisible(false));
            }
        }
Пример #34
0
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        EditorGUI.BeginProperty(position, label, property);
        position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);

        var indent = EditorGUI.indentLevel;

        EditorGUI.indentLevel = 0;


        // Calculate rects
        var typeRect  = new Rect(position.x, position.y, 100, position.height);
        var spawnRect = new Rect(position.x + 105, position.y, 150, position.height);

        // Draw fields - passs GUIContent.none to each so they are drawn without labels
        EditorGUI.PropertyField(typeRect, property.FindPropertyRelative("type"), GUIContent.none);
        EditorGUI.indentLevel = 0;
        EditorGUI.PropertyField(spawnRect, property.FindPropertyRelative("prefab"), GUIContent.none);

        EditorGUI.indentLevel = indent;
        EditorGUI.EndProperty();
    }
Пример #35
0
    int AddTag(SerializedProperty tagsProp, string newTag, TagType type)
    {
        bool found = false;

        //check tag doesnt already exist
        for (int i = 0; i < tagsProp.arraySize; i++)
        {
            SerializedProperty t = tagsProp.GetArrayElementAtIndex(i);
            if (t.stringValue.Equals(newTag))
            {
                found = true;
                return(i);
            }
        }
        //else add new tag
        if (!found && type == TagType.Tag)
        {
            tagsProp.InsertArrayElementAtIndex(0);
            SerializedProperty newTagProp = tagsProp.GetArrayElementAtIndex(0);
            newTagProp.stringValue = newTag;
        }
        //add new layer
        else if (!found && type == TagType.Layer)
        {
            //looping from 8 as in unity user editable layers start from layer 8
            for (int j = 8; j < tagsProp.arraySize; j++)
            {
                SerializedProperty newLayer = tagsProp.GetArrayElementAtIndex(j);
                //add new layer in empty slot
                if (newLayer.stringValue == "")
                {
                    //Debug.Log("adding new layer :" + newTag);
                    newLayer.stringValue = newTag;
                    return(j);
                }
            }
        }
        return(-1);
    }
Пример #36
0
 public override void OnGUI(Rect rect, SerializedProperty prop, GUIContent label)
 {
   Rect position = rect;
   position.height = EditorGUIUtility.singleLineHeight;
   SerializedProperty propertyRelative1 = prop.FindPropertyRelative("m_NormalColor");
   SerializedProperty propertyRelative2 = prop.FindPropertyRelative("m_HighlightedColor");
   SerializedProperty propertyRelative3 = prop.FindPropertyRelative("m_PressedColor");
   SerializedProperty propertyRelative4 = prop.FindPropertyRelative("m_DisabledColor");
   SerializedProperty propertyRelative5 = prop.FindPropertyRelative("m_ColorMultiplier");
   SerializedProperty propertyRelative6 = prop.FindPropertyRelative("m_FadeDuration");
   EditorGUI.PropertyField(position, propertyRelative1);
   position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
   EditorGUI.PropertyField(position, propertyRelative2);
   position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
   EditorGUI.PropertyField(position, propertyRelative3);
   position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
   EditorGUI.PropertyField(position, propertyRelative4);
   position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
   EditorGUI.PropertyField(position, propertyRelative5);
   position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
   EditorGUI.PropertyField(position, propertyRelative6);
 }
        public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
        {
            Initialize(property);
            _toShow = ConditionalFieldUtility.PropertyIsVisible(property, _conditionalToTarget[property]);

            if (!_toShow)
            {
                return(0);
            }

            if (_genericAttributeDrawerInstance != null)
            {
                return(_genericAttributeDrawerInstance.GetPropertyHeight(property, label));
            }

            if (_genericTypeDrawerInstance != null)
            {
                return(_genericTypeDrawerInstance.GetPropertyHeight(property, label));
            }

            return(EditorGUI.GetPropertyHeight(property));
        }
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        //TODO: move this to somewhere called less frequently
        CSActionWrapper actionWrapper = EditorHelper.GetObjectFromSerializedProperty(property) as CSActionWrapper;

        if (actionWrapper == null)
        {
            return;
        }

        actionWrapper.Load();

        if (GUI.Button(position, actionWrapper.ToString()))
        {
            CSActionWrapperWindow window = EditorWindow.GetWindow(typeof(CSActionWrapperWindow)) as CSActionWrapperWindow;

            //Set the window object reference
            window.actionWrapper    = actionWrapper;
            window.serializedObject = property.serializedObject;
            window.Show();
        }
    }
Пример #39
0
        protected override void OnEnable()
        {
            base.OnEnable();

            if (!MixedRealityInspectorUtility.CheckMixedRealityConfigured(false))
            {
                return;
            }

            if (!MixedRealityToolkit.Instance.ActiveProfile.IsInputSystemEnabled ||
                MixedRealityToolkit.Instance.ActiveProfile.InputSystemProfile.InputActionsProfile == null)
            {
                return;
            }

            recognizerStartBehaviour   = serializedObject.FindProperty("startBehavior");
            recognitionConfidenceLevel = serializedObject.FindProperty("recognitionConfidenceLevel");

            speechCommands = serializedObject.FindProperty("speechCommands");
            actionLabels   = MixedRealityToolkit.Instance.ActiveProfile.InputSystemProfile.InputActionsProfile.InputActions.Select(action => new GUIContent(action.Description)).Prepend(new GUIContent("None")).ToArray();
            actionIds      = MixedRealityToolkit.Instance.ActiveProfile.InputSystemProfile.InputActionsProfile.InputActions.Select(action => (int)action.Id).Prepend(0).ToArray();
        }
Пример #40
0
        internal void DrawChild(Rect r, int index, bool isActive, bool isFocused) {
            SerializedProperty prefab = spawnListProperty.GetArrayElementAtIndex(index);
            GameObject go = (GameObject)prefab.objectReferenceValue;

            GUIContent label;
            if (go == null) {
                label = new GUIContent("Empty", "Drag a prefab with a NetworkIdentity here");
            } else {
                NetworkIdentity identity = go.GetComponent<NetworkIdentity>();
                label = new GUIContent(go.name, identity != null ? "AssetId: [" + identity.assetId + "]" : "No Network Identity");
            }

            GameObject newGameObject = (GameObject)EditorGUI.ObjectField(r, label, go, typeof(GameObject), false);

            if (newGameObject != go) {
                if (newGameObject != null && !newGameObject.GetComponent<NetworkIdentity>()) {
                    Debug.LogError("Prefab " + newGameObject + " cannot be added as spawnable as it doesn't have a NetworkIdentity.");
                    return;
                }
                prefab.objectReferenceValue = newGameObject;
            }
        }
        private void ParseAction(TreeViewItem parentTreeItem, SerializedProperty actionMapProperty, SerializedProperty actionsArrayProperty, int index, int depth)
        {
            var bindingsArrayProperty = actionMapProperty.FindPropertyRelative("m_Bindings");
            var actionMapName = actionMapProperty.FindPropertyRelative("m_Name").stringValue;
            var actionProperty = actionsArrayProperty.GetArrayElementAtIndex(index);

            var actionItem = new ActionTreeItem(actionMapProperty, actionProperty, index);
            actionItem.depth = depth;
            var actionName = actionItem.actionName;

            ParseBindings(actionItem, actionMapName, actionName, bindingsArrayProperty, depth + 1);

            bool actionSearchMatched = IsSearching() && actionName.ToLower().Contains(m_NameFilter.ToLower());
            if (actionSearchMatched || IsSearching() && actionItem.children != null && actionItem.children.Any())
            {
                parentTreeItem.AddChild(actionItem);
            }
            else if (!IsSearching())
            {
                parentTreeItem.AddChild(actionItem);
            }
        }
Пример #42
0
	public override float GetPropertyHeight (SerializedProperty prop, GUIContent label)
	{
		SerializedProperty targetProp = prop.FindPropertyRelative("mTarget");
		if (targetProp.objectReferenceValue == null) return 2 * lineHeight;
		int lines = 3 * lineHeight;

		SerializedProperty methodProp = prop.FindPropertyRelative("mMethodName");

		EventDelegate del = new EventDelegate();
		del.target = targetProp.objectReferenceValue as MonoBehaviour;
		del.methodName = methodProp.stringValue;

		SerializedProperty paramArrayProp = prop.FindPropertyRelative("mParameters");
		EventDelegate.Parameter[] ps = del.parameters;

		if (ps != null)
		{
			paramArrayProp.arraySize = ps.Length;

			for (int i = 0; i < ps.Length; i++)
			{
				lines += lineHeight;

				SerializedProperty paramProp = paramArrayProp.GetArrayElementAtIndex(i);
				SerializedProperty objProp = paramProp.FindPropertyRelative("obj");
				UnityEngine.Object obj = objProp.objectReferenceValue;

				if (obj != null)
				{
					System.Type type = obj.GetType();
					GameObject selGO = null;
					if (type == typeof(GameObject)) selGO = obj as GameObject;
					else if (type.IsSubclassOf(typeof(Component))) selGO = (obj as Component).gameObject;
					if (selGO != null) lines += lineHeight;
				}
			}
		}
		return lines;
	}
Пример #43
0
    void ShowList(SerializedProperty list)
    {
        EditorGUILayout.PropertyField(list);
        EditorGUI.indentLevel++;

        if (list.isExpanded)
        {
            EditorGUILayout.PropertyField(list.FindPropertyRelative("Array.size"));
            for (int i = 0; i < list.arraySize; i++)
            {
                SerializedProperty listProp = list.GetArrayElementAtIndex(i);
                float propertyHeight        = 34f;
                if (listProp.FindPropertyRelative("longerDialog").boolValue == true)
                {
                    propertyHeight = 68f;
                }
                EditorGUILayout.PropertyField(listProp, GUIContent.none, GUILayout.Height(propertyHeight));                 //48
            }
        }

        EditorGUI.indentLevel--;
    }
 public static T GetTargetObject<T>(SerializedProperty property)
 {
     object targetObject = property.serializedObject.targetObject;
     int pathPosition = 0;
     string[] allPaths = property.propertyPath.Split('.');
     while (pathPosition < allPaths.Length)
     {
         string path = allPaths[pathPosition];
         Type type = targetObject.GetType();                
         FieldInfo field = type.GetField(path, BINDING_FLAGS);
         if (type.IsArray)
         {
             pathPosition = FindObjectInArray(allPaths, pathPosition, ref targetObject);
         }
         else
         {
             targetObject = field.GetValue(targetObject);
         }
         pathPosition++;
     }
     return (T)targetObject;
 }
Пример #45
0
        void OnEnable()
        {
            _footDistance  = serializedObject.FindProperty("_footDistance");
            _stepFrequency = serializedObject.FindProperty("_stepFrequency");
            _stepHeight    = serializedObject.FindProperty("_stepHeight");
            _stepAngle     = serializedObject.FindProperty("_stepAngle");

            _hipHeight        = serializedObject.FindProperty("_hipHeight");
            _hipPositionNoise = serializedObject.FindProperty("_hipPositionNoise");
            _hipRotationNoise = serializedObject.FindProperty("_hipRotationNoise");

            _spineBend          = serializedObject.FindProperty("_spineBend");
            _spineRotationNoise = serializedObject.FindProperty("_spineRotationNoise");

            _handPosition      = serializedObject.FindProperty("_handPosition");
            _handPositionNoise = serializedObject.FindProperty("_handPositionNoise");

            _headMove = serializedObject.FindProperty("_headMove");

            _noiseFrequency = serializedObject.FindProperty("_noiseFrequency");
            _randomSeed     = serializedObject.FindProperty("_randomSeed");
        }
Пример #46
0
    void DrawAudio()
    {
        m_Property = m_Object.FindProperty("useSounds");
        EditorGUILayout.PropertyField(m_Property, new GUIContent("Use Audio :"), true);
        m_Object.ApplyModifiedProperties();

        if (m_Object.FindProperty("useSounds").boolValue == true)
        {
            m_Property = m_Object.FindProperty("sounds");
            EditorGUILayout.PropertyField(m_Property, new GUIContent("Audio Source :"), true);
            m_Object.ApplyModifiedProperties();
            m_Property = m_Object.FindProperty("openSound");
            EditorGUILayout.PropertyField(m_Property, new GUIContent("Open Clip :"), true);
            m_Object.ApplyModifiedProperties();
            if (m_Object.FindProperty("useCloseAnim").boolValue == true)
            {
                m_Property = m_Object.FindProperty("closeSound");
                EditorGUILayout.PropertyField(m_Property, new GUIContent("Close Clip :"), true);
                m_Object.ApplyModifiedProperties();
            }
        }
    }
Пример #47
0
    public bool ShouldDisable(SerializedProperty property) {
      foreach (var name in propertyNames) {
        var prop = property.serializedObject.FindProperty(name);

        bool result = shouldDisable(prop);
        if (isAndOperation) {
          if (!result) {
            return false;
          }
        } else {
          if (result) {
            return true;
          }
        }
      }

      if (isAndOperation) {
        return true;
      } else {
        return false;
      }
    }
Пример #48
0
        //コンポーネントやScriptableObjectにあるメソッドを名前で呼び出す
        public static object CallFunction(SerializedProperty property, string functionName, object[] args = null)
        {
            var obj  = property.serializedObject.targetObject;                  //コンポーネントやScriptableObject
            var type = obj.GetType();                                           //その型を取得

            //メソッドを名前で検索
            var method = type.GetMethod(functionName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);                          //メソッドを名前で検索

            if (method != null)
            {
                return(method.Invoke(obj, args));                                                   //メソッド呼び出し
            }
            //プロパティを名前で検索
            var prop = type.GetProperty(functionName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.GetProperty);

            if (prop != null)
            {
                return(prop.GetValue(obj, args));                                                //メソッド呼び出し
            }
            Assert.IsTrue(true, functionName + " is not found in " + type.ToString());
            return(null);
        }
Пример #49
0
            // Add an initial value for the given parameter to all selected objects that don't have one.
            private void AddParameter(EditorParamRef parameter)
            {
                foreach (SerializedObject serializedTarget in serializedTargets)
                {
                    StudioEventEmitter emitter = serializedTarget.targetObject as StudioEventEmitter;

                    if (Array.FindIndex(emitter.Params, p => p.Name == parameter.Name) < 0)
                    {
                        SerializedProperty paramsProperty = serializedTarget.FindProperty("Params");

                        int index = paramsProperty.arraySize;
                        paramsProperty.InsertArrayElementAtIndex(index);

                        SerializedProperty arrayElement = paramsProperty.GetArrayElementAtIndex(index);

                        arrayElement.FindPropertyRelative("Name").stringValue = parameter.Name;
                        arrayElement.FindPropertyRelative("Value").floatValue = parameter.Default;

                        serializedTarget.ApplyModifiedProperties();
                    }
                }
            }
Пример #50
0
        protected override void init(SerializedProperty property)
        {
            base.init(property);

            var           channelFeature = LeapGraphicEditor.currentFeature as LeapSpriteFeature;
            Func <string> nameFunc       = () => {
                if (channelFeature == null)
                {
                    return(null);
                }
                else
                {
                    return(channelFeature.propertyName);
                }
            };

            var spriteProp = property.FindPropertyRelative("_sprite");

            drawCustom(rect => {
                if (rect.height != 0)
                {
                    var indentedRect = EditorGUI.IndentedRect(rect);
                    EditorGUI.HelpBox(indentedRect, "Sprite is not packed!", MessageType.Error);
                }
            }, () => {
                Sprite sprite = spriteProp.objectReferenceValue as Sprite;
                if (sprite != null && !sprite.packed)
                {
                    return(EditorGUIUtility.singleLineHeight * 2);
                }
                else
                {
                    return(0);
                }
            });

            drawProperty("_sprite", nameFunc);
        }
Пример #51
0
        static public void LabelField(SerializedProperty property,
                                      GUIContent labelText,
                                      Block block)
        {
            List <string> labelKeys    = new List <string>();
            List <Label>  labelObjects = new List <Label>();

            labelKeys.Add("<None>");
            labelObjects.Add(null);

            Label selectedLabel = property.objectReferenceValue as Label;

            int index         = 0;
            int selectedIndex = 0;

            foreach (Command command in block.commandList)
            {
                Label label = command as Label;
                if (label == null)
                {
                    continue;
                }

                labelKeys.Add(label.key);
                labelObjects.Add(label);

                index++;

                if (label == selectedLabel)
                {
                    selectedIndex = index;
                }
            }

            selectedIndex = EditorGUILayout.Popup(labelText.text, selectedIndex, labelKeys.ToArray());

            property.objectReferenceValue = labelObjects[selectedIndex];
        }
Пример #52
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            MalbersEditor.DrawDescription("Plays the sound matching the physic material on the hit object\nInvoke the method 'PlayMaterialSound'");

            EditorGUI.BeginChangeCheck();
            {
                EditorGUILayout.BeginVertical(MTools.StyleGray);
                {
                    EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                    EditorGUILayout.PropertyField(serializedObject.FindProperty("audioSource"));
                    EditorGUILayout.PropertyField(serializedObject.FindProperty("DefaultSound"));
                    EditorGUILayout.EndVertical();

                    list.DoLayoutList();

                    if (list.index != -1)
                    {
                        EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                        {
                            SerializedProperty Element      = soundbymaterial.GetArrayElementAtIndex(list.index);
                            SerializedProperty SoundElement = Element.FindPropertyRelative("Sounds");

                            MalbersEditor.Arrays(SoundElement);
                        }
                        EditorGUILayout.EndVertical();
                    }
                }

                EditorGUILayout.EndVertical();
            }
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(target, "SoundByMat Inspector");
            }
            serializedObject.ApplyModifiedProperties();
        }
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        int originalIndentLevel = EditorGUI.indentLevel;
        EditorGUI.BeginProperty(position, label, property);
        position =
            EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);
        EditorGUI.indentLevel = 0;
        SerializedProperty minProperty = property.FindPropertyRelative("min");
        SerializedProperty maxProperty = property.FindPropertyRelative("max");
        float minValue = minProperty.floatValue;
        float maxValue = maxProperty.floatValue;
        float fieldWidth = position.width / 4f - 4f;
        float sliderWidth = position.width / 2f;
        position.width = fieldWidth;
        minValue = EditorGUI.FloatField(position, minValue);
        position.x += position.width + 4f;
        position.width = sliderWidth;
        var limit = attribute as FloatRangeSliderAttribute;
        EditorGUI.MinMaxSlider(position, ref minValue, ref maxValue, limit.Min, limit.Max);
        position.x += sliderWidth + 4f;
        position.width = fieldWidth;
        maxValue = EditorGUI.FloatField(position, maxValue);
        maxValue = EditorGUI.FloatField(position, maxValue);
        if (minValue < limit.Min)
            minValue = limit.Min;

        if (maxValue < minValue)
            maxValue = minValue;

        if (limit.Max < maxValue)
            maxValue = limit.Max;


        minProperty.floatValue = minValue;
        maxProperty.floatValue = maxValue;
        EditorGUI.EndProperty();
        EditorGUI.indentLevel = originalIndentLevel;
    }
Пример #54
0
        public override VisualElement CreatePropertyGUI(SerializedProperty settingsProperty)
        {
            VisualElement settings = new VisualElement();

            settings.Bind(settingsProperty.serializedObject);

            settings.Add(CreateHideInInspectorField(settingsProperty));
            var mode = CreateSettingsField(settingsProperty, nameof(IntParameter.IntSettings.mode), "Mode");
            var min  = CreateSettingsField(settingsProperty, nameof(IntParameter.IntSettings.min), "Min");
            var max  = CreateSettingsField(settingsProperty, nameof(IntParameter.IntSettings.max), "Max");

            mode.RegisterValueChangeCallback(e => UpdateVisibility(e.changedProperty));
            UpdateVisibility(settingsProperty.FindPropertyRelative(nameof(IntParameter.IntSettings.mode)));

            void UpdateVisibility(SerializedProperty property)
            {
                if (property == null)
                {
                    return;
                }
                var newValue = (IntParameter.IntMode)property.intValue;

                if (newValue == IntParameter.IntMode.Slider)
                {
                    min.style.display = max.style.display = DisplayStyle.Flex;
                }
                else
                {
                    min.style.display = max.style.display = DisplayStyle.None;
                }
            }

            settings.Add(mode);
            settings.Add(min);
            settings.Add(max);

            return(settings);
        }
Пример #55
0
    void CustomField(SerializedProperty ct, SerializedProperty f)
    {
        EditorGUILayout.BeginHorizontal();
        ct.boolValue = EditorGUILayout.Toggle(ct.boolValue, GUILayout.Width(20));
        GUI.enabled  = ct.boolValue;
        EditorGUILayout.PropertyField(f);
        EditorGUILayout.EndHorizontal();
        GUI.enabled = true;



        // bool ShowCustom = false;
        // EditorGUI.BeginChangeCheck();
        // EditorGUILayout.PropertyField(ct, new GUIContent(name));
        // if (EditorGUI.EndChangeCheck() || !ct.hasMultipleDifferentValues)
        // {
        //     ShowCustom = ct.boolValue;
        //
        // }
        //
        // anim.target = ct.boolValue;
        //
        // if (ShowCustom)
        // {
        //     if (EditorGUILayout.BeginFadeGroup(anim.faded))
        //     {
        //         EditorGUI.indentLevel++;
        //         //EditorGUI.BeginChangeCheck();
        //         //float v = EditorGUILayout.Slider(new GUIContent((f.hasMultipleDifferentValues ? "Variation" : " ")), f.floatValue, min, max);
        //         //if (EditorGUI.EndChangeCheck()) { f.floatValue = v; }
        //         EditorGUILayout.PropertyField(f, new GUIContent(" "));
        //         EditorGUI.indentLevel--;
        //     }
        //     EditorGUILayout.EndFadeGroup();
        // }
        //
        //
    }
        bool DrawLayerMask(SerializedProperty prop, ref LayerMask mask, GUIContent style)
        {
            var  layers      = InternalEditorUtility.layers;
            bool hasChanged  = false;
            var  controlRect = BeginProperty(prop, style);

            EditorGUI.BeginChangeCheck();

            // LayerMask needs to be converted to be used in a MaskField...
            int field = 0;

            for (int c = 0; c < layers.Length; c++)
            {
                if ((mask & (1 << LayerMask.NameToLayer(layers[c]))) != 0)
                {
                    field |= 1 << c;
                }
            }

            field = EditorGUI.MaskField(controlRect, style, field, InternalEditorUtility.layers);
            if (EditorGUI.EndChangeCheck())
            {
                hasChanged = true;
            }

            // ...and converted back.
            mask = 0;
            for (int c = 0; c < layers.Length; c++)
            {
                if ((field & (1 << c)) != 0)
                {
                    mask |= 1 << LayerMask.NameToLayer(layers[c]);
                }
            }

            EndProperty();
            return(hasChanged);
        }
        public void OnEnable()
        {
            // General properties
            hostTransform        = serializedObject.FindProperty("hostTransform");
            manipulationType     = serializedObject.FindProperty("manipulationType");
            allowFarManipulation = serializedObject.FindProperty("allowFarManipulation");

            // One handed
            oneHandRotationModeNear = serializedObject.FindProperty("oneHandRotationModeNear");
            oneHandRotationModeFar  = serializedObject.FindProperty("oneHandRotationModeFar");

            // Two handed
            twoHandedManipulationType = serializedObject.FindProperty("twoHandedManipulationType");

            // Physics
            releaseBehavior = serializedObject.FindProperty("releaseBehavior");
            useForcesForNearManipulation = serializedObject.FindProperty("useForcesForNearManipulation");

            // Smoothing
            smoothingFar   = serializedObject.FindProperty("smoothingFar");
            smoothingNear  = serializedObject.FindProperty("smoothingNear");
            moveLerpTime   = serializedObject.FindProperty("moveLerpTime");
            rotateLerpTime = serializedObject.FindProperty("rotateLerpTime");
            scaleLerpTime  = serializedObject.FindProperty("scaleLerpTime");

            // Constraints
            enableConstraints = serializedObject.FindProperty("enableConstraints");
            constraintManager = serializedObject.FindProperty("constraintsManager");

            // Elastics
            elasticsManager = serializedObject.FindProperty("elasticsManager");

            // Manipulation Events
            onManipulationStarted = serializedObject.FindProperty("onManipulationStarted");
            onManipulationEnded   = serializedObject.FindProperty("onManipulationEnded");
            onHoverEntered        = serializedObject.FindProperty("onHoverEntered");
            onHoverExited         = serializedObject.FindProperty("onHoverExited");
        }
        public override void OnInspectorGUI ()
        {
            base.OnInspectorGUI ();

            SerializedProperty componentProp = serializedObject.FindProperty ("Component");
            SerializedProperty methodNameProp = serializedObject.FindProperty ("MethodName");
            SerializedProperty runInEditorModeProp = serializedObject.FindProperty ("RunInEditorMode");

            UnityEngine.Object obj = componentProp.exposedReferenceValue;
            if (obj != null) {
                Type type = componentProp.exposedReferenceValue.GetType ();
                string[] methodInfos = type
                    .GetMethods (BindingFlags.Public | BindingFlags.Instance)
                    .Where (x => !x.IsSpecialName && x.GetParameters ().Length == 0)
                    .Select (x => x.Name)
                    .OrderBy (x => x)
                    .ToArray ();
                int index = Array.IndexOf (methodInfos, methodNameProp.stringValue);
                if (index < 0)
                    index = 0;
                else
                    index++;

                index = EditorGUILayout.Popup (
                    "Method",
                    index,
                    new[] {"<None>"}
                        .Concat (methodInfos.Select (x => x.Substring (0, 1) + "/" + x))
                        .ToArray ());

                methodNameProp.stringValue = index == 0 ? null : methodInfos[index - 1];                
            }
            

            EditorGUILayout.PropertyField (runInEditorModeProp);
            
            serializedObject.ApplyModifiedProperties ();
        }
Пример #59
0
 private void Eve(Rect pos, SerializedProperty property)
 {
     Event e = Event.current;
     if (!pos.Zoom( AnchorType.MiddleCenter,new Vector2(4, 0)).Contains(e.mousePosition) || e.type!= EventType.MouseDrag) return;
     float width = e.mousePosition.x - pos.x;
     if (property.propertyType == SerializedPropertyType.Float)
     {
         property.floatValue = width / pos.width * (Bar.maxValue - Bar.minValue) + Bar.minValue;
         if (e.mousePosition.x > pos.xMax)
         {
             property.floatValue = Bar.maxValue;
         }
         if (e.mousePosition.x < pos.xMin)
         {
             property.floatValue = Bar.minValue;
         }
     }
     else
     {
         float space = pos.width / (Bar.maxValue - Bar.minValue);
         float real = (property.intValue - Bar.minValue) * space ;
         if (real < width - space)
         {
             property.intValue++;
         }
         else if (real > width + space)
             property.intValue--;
         if (e.mousePosition.x>pos.xMax)
         {
             property.intValue = (int)Bar.maxValue;
         }
         if (e.mousePosition.x < pos.xMin)
         {
             property.intValue = (int)Bar.minValue;
         }
     }
     e.Use();
 } 
Пример #60
0
        }//end HorizVert

        public void HorizVertDisplay(string[] names, SerializedProperty option, string property, bool showHoriz, int indentLevel, bool line) {//a list of bool options
            if (line) {
                EditorGUI.indentLevel = indentLevel - 1;
                EditorGUILayout.LabelField("", "", "PopupCurveSwatchBackground", GUILayout.MaxHeight(0f));
            }

            EditorGUI.indentLevel = indentLevel;
            if (showHoriz) {//if showing items horizontally
                for (int b = 0; b < option.arraySize; b = b + 2) {//add 2 each time because 2 option are being displayed

                    if (line && b > 0)
                        EditorGUILayout.LabelField("", "", "PopupCurveSwatchBackground", GUILayout.MaxHeight(0f));

                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.PropertyField(option.GetArrayElementAtIndex(b).FindPropertyRelative(property), new GUIContent(names[b]));
                    if (b < option.arraySize - 1)//show the RH option if is less than length -1
                        EditorGUILayout.PropertyField(option.GetArrayElementAtIndex(b + 1).FindPropertyRelative(property), new GUIContent(names[b + 1]));
                    else
                        EditorGUILayout.LabelField("");
                    EditorGUILayout.EndHorizontal();
                }//end for show items
            } else {//if showing items vertically
                int half = Mathf.CeilToInt(option.arraySize / 2f);//get the halfway item rounded up so that an odd number will be displayed
                for (int b = 0; b < half; b++) {//only need to go through half

                    if (line && b > 0)
                        EditorGUILayout.LabelField("", "", "PopupCurveSwatchBackground", GUILayout.MaxHeight(0f));

                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.PropertyField(option.GetArrayElementAtIndex(b).FindPropertyRelative(property), new GUIContent(names[b]));
                    if (half + b < option.arraySize)
                        EditorGUILayout.PropertyField(option.GetArrayElementAtIndex(half + b).FindPropertyRelative(property), new GUIContent(names[half + b]));
                    else
                        EditorGUILayout.LabelField("");
                    EditorGUILayout.EndHorizontal();
                }//end for show items
            }//end else show vertically
        }//end HorizVertToDisplay for bools in other options