/// <summary> /// Draws the lock field. /// </summary> /// <param name="position">Position.</param> /// <param name="prop">Property.</param> private void LockField(Rect position, SerializedProperty prop) { Texture2D trueTexture = EditorResourceCache.GetResource <Texture2D>("HydraCommon", "Textures", PADLOCK_CLOSED_NAME); Texture2D falseTexture = EditorResourceCache.GetResource <Texture2D>("HydraCommon", "Textures", PADLOCK_OPEN_NAME); HydraEditorUtils.ToggleTexturesField(position, GUIContent.none, prop, trueTexture, falseTexture); }
/// <summary> /// Draws the content. /// </summary> /// <param name="position">Position.</param> /// <param name="locked">Locked.</param> protected override void DrawContent(Rect position, bool locked) { HydraEditorUtils.DrawUnindented( () => GUI.Box(position, GUIContent.none, HydraEditorGUIStyles.vector3CurvesBackgroundStyle)); // Draw the curves Rect curvesBounds = GetCurvesBoundingRect(); if (locked) { DrawCurveSwatch(position, m_CurveXProperty, s_LockedColor, curvesBounds); m_CurveYProperty.animationCurveValue = m_CurveXProperty.animationCurveValue; m_CurveZProperty.animationCurveValue = m_CurveXProperty.animationCurveValue; } else { DrawCurveSwatch(position, m_CurveXProperty, s_ColorX, curvesBounds); DrawCurveSwatch(position, m_CurveYProperty, s_ColorY, curvesBounds); DrawCurveSwatch(position, m_CurveZProperty, s_ColorZ, curvesBounds); } // Draw the foreground button DrawForegroundButton(position, locked); }
/// <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); // Draw the preview texture Rect textureRect = new Rect(position); textureRect.x += textureRect.width - PREVIEW_TEXTURE_SIZE; textureRect.width = PREVIEW_TEXTURE_SIZE; textureRect.height = PREVIEW_TEXTURE_SIZE; DrawPreviewTexture(textureRect); // Draw the fields Rect contentRect = new Rect(position); contentRect.width -= textureRect.width + HydraEditorUtils.STANDARD_HORIZONTAL_SPACING * 2.0f; HydraEditorUtils.Vector3Field(contentRect, s_NoiseFrequencyLabel, m_FrequencyProp); contentRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; HydraEditorUtils.Vector3Field(contentRect, s_NoisePhaseLabel, m_PhaseProp); EditorGUI.EndProperty(); }
/// <summary> /// Draws the content. /// </summary> /// <param name="position">Position.</param> protected override void DrawContent(Rect position) { HydraEditorUtils.DrawUnindented( () => HydraEditorUtils.EnumPopupField <MouseButtonInputAttribute.Buttons>(position, GUIContent.none, m_InputProperty, HydraEditorGUIStyles.enumStyle)); }
/// <summary> /// Called to draw the GUI in scene view. /// </summary> /// <param name="sceneView">Scene View.</param> protected override void OnSceneViewGUI(SceneView sceneView) { base.OnSceneViewGUI(sceneView); Rect cameraRect = sceneView.camera.pixelRect; Rect guiRect = new Rect(cameraRect.width - (WIDTH + SCREEN_PADDING_X), cameraRect.height - (HEIGHT + SCREEN_PADDING_Y), WIDTH, HEIGHT); Color backgroundColor = GUI.backgroundColor; if (!EditorGUIUtility.isProSkin) { GUI.backgroundColor = new Color(backgroundColor.r, backgroundColor.g, backgroundColor.b, 0.8f); } Rect windowRect = GUILayout.Window(s_WindowId, guiRect, DrawWindowContents, GetWindowTitle(), HydraEditorGUIStyles.windowStyle); GUI.backgroundColor = backgroundColor; // Correct for the header windowRect.y -= 16; HydraEditorUtils.EatMouseInput(windowRect, s_WindowId); }
/// <summary> /// Draws the foreground button. /// </summary> /// <param name="position">Position.</param> /// <param name="locked">Locked.</param> private void DrawForegroundButton(Rect position, bool locked) { string name = m_CurveXProperty.GetHashCode().ToString(); GUI.SetNextControlName(name); bool pressed = HydraEditorUtils.DrawUnindented( () => GUI.Button(position, GUIContent.none, HydraEditorGUIStyles.vector3CurvesForegroundStyle)); if (!pressed) { return; } GUI.FocusControl(name); Vector3CurvesAttribute parent = m_CurveXProperty.GetParent() as Vector3CurvesAttribute; if (locked) { EditCurve(parent.curveX, "Edit XYZ", s_LockedColor); } else { GenericMenu menu = new GenericMenu(); menu.AddItem(new GUIContent("Edit X"), false, () => EditCurve(parent.curveX, "Edit X", s_ColorX)); menu.AddItem(new GUIContent("Edit Y"), false, () => EditCurve(parent.curveY, "Edit Y", s_ColorY)); menu.AddItem(new GUIContent("Edit Z"), false, () => EditCurve(parent.curveZ, "Edit Z", s_ColorZ)); menu.ShowAsContext(); } }
/// <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); // Draw the lock Rect lockPosition = new Rect(position); lockPosition.width = lockPosition.height; HydraEditorUtils.DrawUnindented(() => LockField(lockPosition, m_LockedProperty)); // Draw the contents Rect contentPosition = new Rect(position); float offset = lockPosition.width + HydraEditorUtils.STANDARD_HORIZONTAL_SPACING; contentPosition.x += offset; contentPosition.width -= offset; DrawContent(contentPosition, m_LockedProperty.boolValue); EditorGUI.EndProperty(); }
/// <summary> /// Draws the tangents. /// </summary> private void DrawTangents(Rect position) { HydraEditorUtils.DrawUnindented(() => HydraEditorUtils.Vector3Field2Dp(position, s_InLabel, m_InTangentProp)); position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; HydraEditorUtils.DrawUnindented(() => HydraEditorUtils.Vector3Field2Dp(position, s_OutLabel, m_OutTangentProp)); }
/// <summary> /// Raises when Random Between Two Constants has been selected. /// </summary> /// <param name="position">Position.</param> private void OnRandomBetweenTwoConstants(Rect position) { Rect gradientRect = new Rect(position); gradientRect.width = (position.width - HydraEditorUtils.STANDARD_HORIZONTAL_SPACING) / 2.0f; HydraEditorUtils.DrawUnindented(() => EditorGUI.PropertyField(gradientRect, m_ConstValueAProperty, GUIContent.none)); gradientRect.x += gradientRect.width + HydraEditorUtils.STANDARD_HORIZONTAL_SPACING; HydraEditorUtils.DrawUnindented(() => EditorGUI.PropertyField(gradientRect, m_ConstValueBProperty, GUIContent.none)); }
/// <summary> /// Raises when Gradient has been selected. /// </summary> /// <param name="position">Position.</param> private void OnGradient(Rect position) { HydraEditorUtils.DrawUnindented(() => GradientWrapField(position)); position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; HydraEditorUtils.DrawUnindented( () => EditorGUI.PropertyField(position, m_GradientLengthProperty, s_GradientLengthLabel)); position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; HydraEditorUtils.DrawUnindented(() => EditorGUI.PropertyField(position, m_GradientAProperty, GUIContent.none)); }
/// <summary> /// Draws the content. /// </summary> /// <param name="position">Position.</param> /// <param name="locked">Locked.</param> protected override void DrawContent(Rect position, bool locked) { if (locked) { HydraEditorUtils.DrawUnindented( () => HydraEditorUtils.UniformVector3Field(position, GUIContent.none, m_VectorProperty)); return; } HydraEditorUtils.DrawUnindented(() => HydraEditorUtils.Vector3Field(position, GUIContent.none, m_VectorProperty)); }
/// <summary> /// Raises when Random Between Two Curves has been selected. /// </summary> /// <param name="position">Position.</param> private void OnRandomBetweenTwoCurves(Rect position) { position.height = EditorGUIUtility.singleLineHeight; HydraEditorUtils.DrawUnindented(() => HydraEditorUtils.ToggleLeftField(position, s_LinearLabel, m_LinearProperty)); Rect vector3Rect = new Rect(position); vector3Rect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; HydraEditorUtils.DrawUnindented(() => EditorGUI.PropertyField(vector3Rect, m_CurvesAProperty, GUIContent.none)); vector3Rect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; HydraEditorUtils.DrawUnindented(() => EditorGUI.PropertyField(vector3Rect, m_CurvesBProperty, GUIContent.none)); }
/// <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); // Range Mode Rect rangeModePosition = new Rect(position); rangeModePosition.x += (rangeModePosition.width - 12); rangeModePosition.width = 12; HydraEditorUtils.DrawUnindented( () => HydraEditorUtils.EnumPopupField <Vector3RangeAttribute.RangeMode>(rangeModePosition, GUIContent.none, m_RangeModeProperty, HydraEditorGUIStyles.enumStyle)); // Range Mode Fields Rect rangeModeFieldsPosition = new Rect(position); rangeModeFieldsPosition.width -= (rangeModePosition.width + HydraEditorUtils.STANDARD_HORIZONTAL_SPACING); switch (m_RangeModeProperty.GetEnumValue <Vector3RangeAttribute.RangeMode>()) { case Vector3RangeAttribute.RangeMode.Constant: OnConstant(rangeModeFieldsPosition); break; case Vector3RangeAttribute.RangeMode.CurveSet: OnCurve(rangeModeFieldsPosition); break; case Vector3RangeAttribute.RangeMode.RandomBetweenTwoConstants: OnRandomBetweenTwoConstants(rangeModeFieldsPosition); break; case Vector3RangeAttribute.RangeMode.RandomBetweenTwoCurveSets: OnRandomBetweenTwoCurves(rangeModeFieldsPosition); 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); FindProperties(prop); HydraEditorUtils.SceneField(position, label, m_GuidProp, HydraEditorGUIStyles.enumStyle); string path = AssetDatabase.GUIDToAssetPath(m_GuidProp.stringValue); m_NameProp.stringValue = string.IsNullOrEmpty(path) ? string.Empty : EditorSceneUtils.GetSceneName(path); m_IndexProp.intValue = string.IsNullOrEmpty(path) ? 0 : EditorSceneUtils.GetSceneIndex(path); 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.height = EditorGUIUtility.singleLineHeight; position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label); float oldLabelWidth = EditorGUIUtility.labelWidth; EditorGUIUtility.labelWidth = LABEL_WIDTH; HydraEditorUtils.DrawUnindented(() => HydraEditorUtils.Vector3Field2Dp(position, s_PositionLabel, m_PositionProp)); position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; HydraEditorUtils.DrawUnindented( () => HydraEditorUtils.EnumPopupField <TangentMode>(position, s_SmoothingLabel, m_TangentModeProp, HydraEditorGUIStyles.enumStyle)); position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; switch (m_TangentModeProp.GetEnumValue <TangentMode>()) { case TangentMode.Auto: break; case TangentMode.Corner: DrawTangents(position); break; case TangentMode.Smooth: DrawTangents(position); break; case TangentMode.Symmetric: break; default: throw new ArgumentOutOfRangeException(); } EditorGUIUtility.labelWidth = oldLabelWidth; EditorGUI.EndProperty(); }
/// <summary> /// Raises when Random Between Two Constants has been selected. /// </summary> /// <param name="position">Position.</param> private void OnRandomBetweenTwoConstants(Rect position) { HydraEditorUtils.DrawUnindented(() => HydraEditorUtils.ToggleLeftField(position, s_LinearLabel, m_LinearProperty)); position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; HydraEditorUtils.DrawUnindented(() => RandomBlendField(position)); Rect gradientRect = new Rect(position); gradientRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; gradientRect.width = (gradientRect.width - HydraEditorUtils.STANDARD_HORIZONTAL_SPACING) / 2.0f; HydraEditorUtils.DrawUnindented(() => EditorGUI.PropertyField(gradientRect, m_ConstValueAProperty, GUIContent.none)); gradientRect.x += gradientRect.width; HydraEditorUtils.DrawUnindented(() => EditorGUI.PropertyField(gradientRect, m_ConstValueBProperty, GUIContent.none)); }
/// <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); FindProperties(prop); position.height = EditorGUIUtility.singleLineHeight; position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label); position.width = HORIZONTAL_SPACING; HydraEditorUtils.DrawUnindented(() => HydraEditorUtils.ToggleLeftField(position, s_XLabel, m_XProperty)); position.x += HORIZONTAL_SPACING; HydraEditorUtils.DrawUnindented(() => HydraEditorUtils.ToggleLeftField(position, s_YLabel, m_YProperty)); position.x += HORIZONTAL_SPACING; HydraEditorUtils.DrawUnindented(() => HydraEditorUtils.ToggleLeftField(position, s_ZLabel, m_ZProperty)); 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> /// Draws the content. /// </summary> /// <param name="position">Position.</param> protected override void DrawContent(Rect position) { HydraEditorUtils.DrawUnindented( () => HydraEditorUtils.AxisInputField(position, GUIContent.none, m_InputProperty, HydraEditorGUIStyles.enumStyle)); }
/// <summary> /// Draws the preview texture. /// </summary> private void DrawPreviewTexture(Rect position) { Texture2D texture = GetTexture(m_FrequencyProp, m_PhaseProp); HydraEditorUtils.PreviewTexture(position, texture); }
/// <summary> /// Raises when constant has been selected. /// </summary> /// <param name="position">Position.</param> private void OnConstant(Rect position) { HydraEditorUtils.DrawUnindented(() => EditorGUI.PropertyField(position, m_ConstValueAProperty, GUIContent.none)); }
/// <summary> /// Raises when curve has been selected. /// </summary> /// <param name="position">Position.</param> private void OnCurve(Rect position) { position.height = EditorGUIUtility.singleLineHeight; HydraEditorUtils.DrawUnindented(() => EditorGUI.PropertyField(position, m_CurvesAProperty, GUIContent.none)); }
/// <summary> /// Raises when Random In Gradient has been selected. /// </summary> /// <param name="position">Position.</param> private void OnRandomInGradient(Rect position) { HydraEditorUtils.DrawUnindented(() => EditorGUI.PropertyField(position, m_GradientAProperty, GUIContent.none)); }
/// <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); }
/// <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); }