public override float GetPropertyHeight(SerializedProperty property, GUIContent label) { object component = Introspector.GetParent(property); Sound s = (Sound)Introspector.GetValue(component, property.name); return(s.foldout ? 90 : 18); }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { if (property.name.Substring(0, 1) != "_") { Debug.Log("MethodButton should be named _[name of method]"); } object component = Introspector.GetParent(property); string methodName = property.name.Substring(1); //var value = Introspector.GetValue(component, property.name.Substring(1)); // label = EditorGUI.BeginProperty(position, label, property); MethodButton methodButton = (MethodButton)Introspector.GetValue(component, property.name); if (methodButton != null) { label.tooltip = methodButton.tooltip; } Rect contentPosition = EditorGUI.PrefixLabel(position, label); if (GUI.Button(contentPosition, new GUIContent(methodName + "()", label.tooltip))) { MethodInfo methodInfo = Introspector.GetMethod(component, methodName); if (methodInfo != null) { methodInfo.Invoke(component, null); } } }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { if (property.name.Substring(0, 1) != "_") { Debug.Log("LockedView should be named _[name of viewed member]"); } object component = Introspector.GetParent(property); string fieldName = property.name.Substring(1); var value = Introspector.GetValue(component, fieldName); //var value = Introspector.GetValue(component, property.name.Substring(1)); //label = EditorGUI.BeginProperty(position, label, property); LockedView lockedView = (LockedView)Introspector.GetValue(component, property.name); if (lockedView != null) { label.tooltip = lockedView.tooltip; } Rect contentPosition = EditorGUI.PrefixLabel(position, label); EditorGUI.LabelField(contentPosition, (value == null)?"Null":value.ToString()); EditorUtility.SetDirty((UnityEngine.Object)component); }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { object component = Introspector.GetParent(property); Sound s = (Sound)Introspector.GetValue(component, property.name); label = EditorGUI.BeginProperty(position, label, property); position.height = 16; Rect contentPosition = EditorGUI.PrefixLabel(position, label); Rect buttonPosition = position; buttonPosition.x = contentPosition.x - 40; buttonPosition.width = 39; if (/*EditorApplication.isPlaying &&*/ GUI.Button(buttonPosition, "Play")) { if (s.mySource != null && s.mySource.isPlaying) { s.Stop(); } else { s.Play(); } } EditorGUI.PropertyField(contentPosition, property.FindPropertyRelative("audioClip"), GUIContent.none); if (s.foldout = EditorGUI.Foldout(position, s.foldout, GUIContent.none, true)) { EditorGUI.indentLevel = 1; position.y += 18; EditorGUI.PropertyField(position, property.FindPropertyRelative("loop")); position.y += 18; EditorGUI.PropertyField(position, property.FindPropertyRelative("volume")); position.y += 18; EditorGUI.PropertyField(position, property.FindPropertyRelative("pan")); position.y += 18; EditorGUI.PropertyField(position, property.FindPropertyRelative("pitch")); } EditorGUI.EndProperty(); }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { label = EditorGUI.BeginProperty(position, label, property); UnityEngine.Object comp = (UnityEngine.Object)Introspector.GetParent(property); ComponentField componentField = (ComponentField)Introspector.GetValue(comp, property.name); EditorGUI.HelpBox(position, "", MessageType.None); // label position.height = 16; EditorGUI.PrefixLabel(position, label); // component Component originalComponent = componentField.component; EditorGUI.indentLevel += 1; position.y += 16; int buttonWidth = 50; Rect tempPosition = position; tempPosition.width -= buttonWidth + 3; EditorGUI.PropertyField(tempPosition, property.FindPropertyRelative("component")); // button tempPosition.x = tempPosition.x + tempPosition.width + 3; tempPosition.width = buttonWidth; bool copiedComponent = stEditor.clipboard is Component; var tooltip = (copiedComponent) ? stEditor.clipboard.ToString() : "Use Get Component\nin component menu"; var button = new GUIContent("Put", tooltip); if (GUI.Button(tempPosition, button) && copiedComponent) { Undo.RecordObject(comp, "Set ComponentField '" + property.name + "' Component"); componentField.component = stEditor.clipboard; } GUI.enabled = true; //member if (componentField.component != originalComponent) { componentField.member = ""; } position.y += 16; if (componentField.component == null) { EditorGUI.Popup(position, "Member", 0, new string[] {}); } else { var availableMembers = Introspector .GetSmartMemberList(componentField.component); int memberIndex = availableMembers.ToList().FindIndex(member => member == componentField.member); int selected = EditorGUI.Popup(position, "Member", memberIndex, availableMembers); if (selected >= 0) { Undo.RecordObject(comp, "Set ComponentField '" + property.name + "' Member"); componentField.member = availableMembers[selected]; } } //EditorGUI.PropertyField( position, property.FindPropertyRelative("member") ); EditorGUI.EndProperty(); }