public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { var sor = new SceneObjectReference(property); var origColor = GUI.color; if (!sor.ReferenceResolved) { label.text = "(Not resolved) " + label.text; GUI.color = Color.red; } label = EditorGUI.BeginProperty(position, label, property); position = EditorGUI.PrefixLabel(position, label); GUI.color = origColor; Object obj = sor.ReferencedObject; if (!sor.ReferenceResolved) { obj = sor.ReferenceScene; } EditorGUI.BeginChangeCheck(); var newObj = EditorGUI.ObjectField(position, obj, typeof(Object), true); if (EditorGUI.EndChangeCheck()) { sor.Update(newObj); } EditorGUI.EndProperty(); }
public LockablePropertyReference(string sceneObjectName, Type type) { Target = new SceneObjectReference(sceneObjectName); Type = type.AssemblyQualifiedName; }
public LockablePropertyReference(LockableProperty property) { Target = new SceneObjectReference(property.SceneObject.UniqueName); Type = property.GetType().AssemblyQualifiedName; }
public ScalingBehavior(SceneObjectReference target, Vector3 targetScale, float duration) { Data.Target = target; Data.TargetScale = targetScale; Data.Duration = duration; }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { var sceneObjectReferenceProperty = property.FindPropertyRelative(k_SceneObjectReferencePath); var futureObjectReferenceProperty = property.FindPropertyRelative(k_FutureObjectReferencePath); var origColor = GUI.color; UnityObject obj; SceneObjectReference sceneObjectReference = null; if (futureObjectReferenceProperty.objectReferenceValue != null) { label.text = "(Future) " + label.text; GUI.color = Color.cyan; obj = futureObjectReferenceProperty.objectReferenceValue; } else { sceneObjectReference = new SceneObjectReference(sceneObjectReferenceProperty); if (!sceneObjectReference.ReferenceResolved) { label.text = "(Not resolved) " + label.text; GUI.color = Color.red; } obj = sceneObjectReference.ReferencedObject; if (!sceneObjectReference.ReferenceResolved) { obj = sceneObjectReference.ReferenceScene; } } label = EditorGUI.BeginProperty(position, label, property); position = EditorGUI.PrefixLabel(position, label); GUI.color = origColor; EditorGUI.BeginChangeCheck(); var newObj = EditorGUI.ObjectField(position, obj, typeof(Object), true); if (EditorGUI.EndChangeCheck()) { if (newObj is FutureObjectReference) { futureObjectReferenceProperty.objectReferenceValue = newObj; } else { futureObjectReferenceProperty.objectReferenceValue = null; if (sceneObjectReference == null) { sceneObjectReference = new SceneObjectReference(sceneObjectReferenceProperty); } sceneObjectReference.Update(newObj); } } EditorGUI.EndProperty(); }
public void InitManager() { reference = new SceneObjectReference(); SaveScene(); }