A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.unity3d.com/Manual/../ScriptReference/SerializedProperty-gradientValue.html below:

Unity - Scripting API: SerializedProperty.gradientValue

SerializedProperty.gradientValue Suggest a change Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close Your name Your email Suggestion*

Cancel

Description

Value of a gradient property.

Additional resources: propertyType, SerializedPropertyType.Gradient, Gradient.

using System;
using UnityEditor;
using UnityEngine;

[CreateAssetMenu] public class SerializedPropertyGradientExample : ScriptableObject { public Gradient m_Gradient;

[Range(0, 1)] public float m_EvaluationTime;

public SerializedPropertyGradientExample() { // Establish a default gradient var colorKeys = new GradientColorKey[] { new GradientColorKey() { color = Color.red, time = 0.0f }, new GradientColorKey() { color = Color.green, time = 0.5f }, new GradientColorKey() { color = Color.blue, time = 1.0f } }; var alphaKeys = new GradientAlphaKey[] { new GradientAlphaKey() { alpha = 0.5f, time = 0.0f }, new GradientAlphaKey() { alpha = 1.0f, time = 1.0f } }; m_Gradient = new Gradient(); m_Gradient.SetKeys(colorKeys, alphaKeys); } }

// Override the default inspector behavior to add extra text line after the two properties [CustomEditor(typeof(SerializedPropertyGradientExample))] public class SerializedPropertyGradientExampleEditor : Editor { public override void OnInspectorGUI() { DrawDefaultInspector();

var gradient = serializedObject.FindProperty("m_Gradient").gradientValue; var evalPoint = serializedObject.FindProperty("m_EvaluationTime").floatValue; GUILayout.Label($"Gradiant at time {evalPoint}: {gradient.Evaluate(evalPoint)}"); } }


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4