/// <summary> /// Override this method to make your own GUI for the property /// </summary> /// <param name="position">Position</param> /// <param name="prop">Property</param> /// <param name="label">Label</param> public override void OnGUI(Rect position, SerializedProperty prop, GUIContent label) { label = EditorGUI.BeginProperty(position, label, prop); FindProperties(prop); position.height = EditorGUIUtility.singleLineHeight; position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label); HydraEditorUtils.DrawUnindented( () => HydraEditorUtils.EnumPopupField <ColorRangeAttribute.RangeMode>(position, GUIContent.none, m_RangeModeProperty, HydraEditorGUIStyles.enumStyle)); position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; switch (m_RangeModeProperty.GetEnumValue <ColorRangeAttribute.RangeMode>()) { case ColorRangeAttribute.RangeMode.Constant: OnConstant(position); break; case ColorRangeAttribute.RangeMode.Gradient: OnGradient(position); break; case ColorRangeAttribute.RangeMode.RandomInGradient: OnRandomInGradient(position); break; case ColorRangeAttribute.RangeMode.RandomBetweenTwoConstants: OnRandomBetweenTwoConstants(position); break; case ColorRangeAttribute.RangeMode.RandomBetweenTwoGradients: OnRandomBetweenTwoGradients(position); break; default: throw new ArgumentOutOfRangeException(); } EditorGUI.EndProperty(); }
/// <summary> /// Override this method to make your own GUI for the property /// </summary> /// <param name="position">Position</param> /// <param name="prop">Property</param> /// <param name="label">Label</param> public override void OnGUI(Rect position, SerializedProperty prop, GUIContent label) { label = EditorGUI.BeginProperty(position, label, prop); position.height = EditorGUIUtility.singleLineHeight; Rect contents = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label); FindProperties(prop); // Draw the preview texture Rect textureRect = new Rect(contents); textureRect.x += textureRect.width - PREVIEW_TEXTURE_SIZE; textureRect.width = PREVIEW_TEXTURE_SIZE; textureRect.height = PREVIEW_TEXTURE_SIZE; EditorGUI.BeginChangeCheck(); HydraEditorUtils.DrawUnindented( () => HydraEditorUtils.TextureField(textureRect, GUIContent.none, m_TextureProp, true)); // Draw the fields Rect contentRect = new Rect(contents); contentRect.width -= textureRect.width + HydraEditorUtils.STANDARD_HORIZONTAL_SPACING * 2.0f; HydraEditorUtils.DrawUnindented( () => HydraEditorUtils.EnumPopupField <Texture2DAttribute.Wrap>(contentRect, GUIContent.none, m_WrapProp, HydraEditorGUIStyles.enumStyle)); // Clear the cache if the texture changes if (EditorGUI.EndChangeCheck()) { m_WrappedTextureProp.objectReferenceValue = null; } EditorGUI.EndProperty(); }
/// <summary> /// Override this method to make your own GUI for the property /// </summary> /// <param name="position">Position</param> /// <param name="prop">Property</param> /// <param name="label">Label</param> public override void OnGUI(Rect position, SerializedProperty prop, GUIContent label) { label = EditorGUI.BeginProperty(position, label, prop); FindProperties(prop); position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label); Rect rangeModePosition = new Rect(position); rangeModePosition.x += (rangeModePosition.width - 12); rangeModePosition.width = 12; Rect rangeModeFieldsPosition = new Rect(position); rangeModeFieldsPosition.width -= (rangeModePosition.width + HydraEditorUtils.STANDARD_HORIZONTAL_SPACING); HydraEditorUtils.DrawUnindented( () => HydraEditorUtils.EnumPopupField <IntRangeAttribute.RangeMode>(rangeModePosition, GUIContent.none, m_RangeModeProperty, HydraEditorGUIStyles.enumStyle)); switch (m_RangeModeProperty.GetEnumValue <IntRangeAttribute.RangeMode>()) { case IntRangeAttribute.RangeMode.Constant: OnConstant(rangeModeFieldsPosition); break; case IntRangeAttribute.RangeMode.RandomBetweenTwoConstants: OnRandomBetweenTwoConstants(rangeModeFieldsPosition); break; default: throw new ArgumentOutOfRangeException(); } EditorGUI.EndProperty(); }
/// <summary> /// Draws the gradient wrap field. /// </summary> /// <param name="position">Position.</param> private void GradientWrapField(Rect position) { HydraEditorUtils.EnumPopupField <GradientExtensions.GradientWrapMode>(position, s_GradientWrapModeLabel, m_GradientWrapModeProperty, HydraEditorGUIStyles.enumStyle); }
/// <summary> /// Draws the random blend field. /// </summary> /// <param name="position">Position.</param> private void RandomBlendField(Rect position) { HydraEditorUtils.EnumPopupField <ColorUtils.Gamut>(position, s_RandomBlendLabel, m_RandomBlendProperty, HydraEditorGUIStyles.enumStyle); }