public override bool VisitComponent(UTinyObject tinyObject) { var gradient = tinyObject.As <Gradient>(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("gradient"); var rect = EditorGUILayout.GetControlRect(); EditorGUI.BeginChangeCheck(); var method = typeof(EditorGUI) .GetMethods(BindingFlags.NonPublic | BindingFlags.Static) .First(t => t.Name == "GradientField"); gradient = (Gradient)method.Invoke(null, new object[] { rect, gradient }); EditorGUILayout.EndHorizontal(); if (EditorGUI.EndChangeCheck()) { tinyObject.AssignFrom(gradient); var container = tinyObject.Properties; PushChange(container, container.PropertyBag.FindProperty("mode")); PushChange(container, container.PropertyBag.FindProperty("stops")); } return(true); }
private static void SetQuaternionFromEuler(UTinyObject quaternion, UTinyObject euler) { var localQuat = new Quaternion(); localQuat.eulerAngles = euler.As <Vector3>(); quaternion["x"] = localQuat.x; quaternion["y"] = localQuat.y; quaternion["z"] = localQuat.z; quaternion["w"] = localQuat.w; }
public override bool VisitComponent(UTinyObject tinyObject) { var curve = tinyObject.As <AnimationCurve>(); EditorGUI.BeginChangeCheck(); curve = EditorGUILayout.CurveField("curve", curve); if (EditorGUI.EndChangeCheck()) { tinyObject.AssignFrom(curve); var container = tinyObject.Properties; PushChange(container, container.PropertyBag.FindProperty("mode")); PushChange(container, container.PropertyBag.FindProperty("stops")); } return(true); }
public override bool VisitStruct(UTinyObject tinyObject, GUIContent label) { var value = tinyObject.As <Color>(); EditorGUI.BeginChangeCheck(); UTinyEditorUtility.SetEditorBoldDefault(tinyObject.IsOverridden); value = EditorGUILayout.ColorField(string.IsNullOrEmpty(label.text) ? GUIContent.none : label, value); UTinyEditorUtility.SetEditorBoldDefault(false); if (EditorGUI.EndChangeCheck()) { tinyObject.AssignFrom(value); foreach (var prop in tinyObject.Properties.PropertyBag.Properties) { PushChange(tinyObject.Properties, prop); } } return(true); }