public static bool XButton(ref Rect position, string tooltip = null, bool rightSide = true) { var w = Mathf.Min(X_BTN_WIDTH, position.width); Rect r; if (rightSide) { r = new Rect(position.xMax - w, position.yMin, w, EditorGUIUtility.singleLineHeight); position = new Rect(position.xMin, position.yMin, position.width - w, position.height); } else { r = new Rect(position.xMin, position.yMin, w, EditorGUIUtility.singleLineHeight); position = new Rect(r.xMax, position.yMin, position.width - w, position.height); } return(GUI.Button(r, EditorHelper.TempContent("X", tooltip))); }
public static System.Reflection.MemberInfo DrawMemberProxy(Rect position, SerializedProperty property, GUIContent label, DynamicMemberAccess memberAccessLevel = DynamicMemberAccess.Read) { var r0 = new Rect(position.xMin, position.yMin, position.width, EditorGUIUtility.singleLineHeight); var r1 = new Rect(position.xMin, r0.yMax, position.width, EditorGUIUtility.singleLineHeight); var targProp = property.FindPropertyRelative("_target"); var memberProp = property.FindPropertyRelative("_memberName"); SPEditorGUI.PropertyField(r0, targProp, label); System.Reflection.MemberInfo selectedMember; memberProp.stringValue = SPEditorGUI.ReflectedPropertyField(r1, EditorHelper.TempContent(" - Property", "The property on the target to set."), targProp.objectReferenceValue, memberProp.stringValue, memberAccessLevel, out selectedMember); return(selectedMember); }
/// <summary> /// Draws all children of a property /// </summary> /// <param name="position"></param> /// <param name="property"></param> /// <returns></returns> public static bool FlatChildPropertyField(SerializedProperty property) { if (property == null) { throw new System.ArgumentNullException("property"); } EditorGUI.BeginChangeCheck(); var iterator = property.Copy(); var end = property.GetEndProperty(); for (bool enterChildren = true; iterator.NextVisible(enterChildren); enterChildren = false) { if (SerializedProperty.EqualContents(iterator, end)) { break; } PropertyField(iterator, EditorHelper.TempContent(iterator.displayName, iterator.tooltip), true); } return(EditorGUI.EndChangeCheck()); }
/// <summary> /// Reflects the available properties and shows them in a dropdown /// </summary> public static string ReflectedPropertyField(Rect position, GUIContent label, object targObj, string selectedMemberName, DynamicMemberAccess access, out System.Reflection.MemberInfo selectedMember) { if (targObj != null) { var members = DynamicUtil.GetEasilySerializedMembers(targObj, System.Reflection.MemberTypes.Field | System.Reflection.MemberTypes.Property, access).ToArray(); var entries = new GUIContent[members.Length]; int index = -1; for (int i = 0; i < members.Length; i++) { var m = members[i]; if ((DynamicUtil.GetMemberAccessLevel(m) & DynamicMemberAccess.Write) != 0) { entries[i] = EditorHelper.TempContent(string.Format("{0} ({1}) -> {2}", m.Name, DynamicUtil.GetReturnType(m).Name, DynamicUtil.GetValueWithMember(m, targObj))); } else { entries[i] = EditorHelper.TempContent(string.Format("{0} (readonly - {1}) -> {2}", m.Name, DynamicUtil.GetReturnType(m).Name, DynamicUtil.GetValueWithMember(m, targObj))); } if (index < 0 && m.Name == selectedMemberName) { index = i; } } index = EditorGUI.Popup(position, label, index, entries); selectedMember = (index >= 0) ? members[index] : null; return((selectedMember != null) ? selectedMember.Name : null); } else { selectedMember = null; EditorGUI.Popup(position, label, -1, new GUIContent[0]); return(null); } }
protected override void OnSPInspectorGUI() { this.serializedObject.Update(); this.DrawPropertyField(EditorHelper.PROP_SCRIPT); var propFileName = this.serializedObject.FindProperty(PROP_BUILDFILENAME); EditorGUILayout.PropertyField(propFileName); if (!string.IsNullOrEmpty(propFileName.stringValue)) { var propBuildDir = this.serializedObject.FindProperty(PROP_BUILDDIR); propBuildDir.stringValue = SPEditorGUILayout.FolderPathTextfield(EditorHelper.TempContent(propBuildDir.displayName, propBuildDir.tooltip), propBuildDir.stringValue, "Build Directory"); } this.DrawPropertyField(PROP_VERSION); this.DrawScenes(); this.DrawBuildOptions(); this.DrawInputSettings(); this.DrawPlayerSettingOverrides(); this.serializedObject.ApplyModifiedProperties(); //build button if (this.serializedObject.isEditingMultipleObjects) { return; } EditorGUILayout.Space(); this.DrawBuildButtons(); }
public static Component SelectComponentField(Rect position, GUIContent label, Component[] components, Component selectedComp) { if (components == null) { throw new System.ArgumentNullException("components"); } System.Type[] availableMechanismTypes = (from c in components select c.GetType()).ToArray(); var availableMechanismTypeNames = availableMechanismTypes.Select((tp) => EditorHelper.TempContent(tp.Name)).ToArray(); var index = System.Array.IndexOf(components, selectedComp); index = EditorGUI.Popup(position, label, index, availableMechanismTypeNames); return((index >= 0) ? components[index] : null); }
public static Component SelectComponentField(Rect position, string label, Component[] components, Component selectedComp) { return(SelectComponentField(position, EditorHelper.TempContent(label), components, selectedComp)); }
public static Component SelectComponentFromSourceField(Rect position, string label, GameObject source, Component selectedComp, System.Predicate <Component> filter = null) { return(SelectComponentFromSourceField(position, EditorHelper.TempContent(label), source, selectedComp, filter)); }
public static WrapMode WrapModeField(Rect position, GUIContent label, WrapMode mode, bool allowDefault = false) { if (allowDefault) { int i = 0; switch (mode) { case WrapMode.Default: i = 0; break; case WrapMode.Once: //case WrapMode.Clamp: //same as once i = 1; break; case WrapMode.Loop: i = 2; break; case WrapMode.PingPong: i = 3; break; case WrapMode.ClampForever: i = 4; break; } i = EditorGUI.Popup(position, label, i, new GUIContent[] { EditorHelper.TempContent("Default"), EditorHelper.TempContent("Once|Clamp"), EditorHelper.TempContent("Loop"), EditorHelper.TempContent("PingPong"), EditorHelper.TempContent("ClampForever") }); switch (i) { case 0: return(WrapMode.Default); case 1: return(WrapMode.Once); case 2: return(WrapMode.Loop); case 3: return(WrapMode.PingPong); case 4: return(WrapMode.ClampForever); default: return(WrapMode.Default); } } else { int i = 0; switch (mode) { case WrapMode.Default: case WrapMode.Once: //case WrapMode.Clamp: //same as once i = 0; break; case WrapMode.Loop: i = 1; break; case WrapMode.PingPong: i = 2; break; case WrapMode.ClampForever: i = 3; break; } i = EditorGUI.Popup(position, label, i, new GUIContent[] { EditorHelper.TempContent("Once|Clamp"), EditorHelper.TempContent("Loop"), EditorHelper.TempContent("PingPong"), EditorHelper.TempContent("ClampForever") }); switch (i) { case 0: return(WrapMode.Once); case 1: return(WrapMode.Loop); case 2: return(WrapMode.PingPong); case 3: return(WrapMode.ClampForever); default: return(WrapMode.Default); } } }
public static WrapMode WrapModeField(Rect position, string label, WrapMode mode, bool allowDefault = false) { return(WrapModeField(position, EditorHelper.TempContent(label), mode, allowDefault)); }
public static System.Enum EnumPopup(string label, System.Enum enumValue) { return(SPEditorGUI.EnumPopup(EditorGUILayout.GetControlRect(true), EditorHelper.TempContent(label), enumValue)); }
public static object DefaultPropertyField(string label, object value, System.Type valueType) { return(SPEditorGUI.DefaultPropertyField(EditorGUILayout.GetControlRect(true), EditorHelper.TempContent(label), value, valueType)); }
public static Component SelectComponentFromSourceField(string label, GameObject source, Component selectedComp, System.Predicate <Component> filter = null) { var position = EditorGUILayout.GetControlRect(true); return(SPEditorGUI.SelectComponentFromSourceField(position, EditorHelper.TempContent(label), source, selectedComp, filter)); }
public static bool XButton(Rect position, string tooltip = null) { var r = new Rect(position.xMin, position.yMin, Mathf.Min(X_BTN_WIDTH, position.width), EditorGUIUtility.singleLineHeight); return(GUI.Button(r, EditorHelper.TempContent("X", tooltip))); }
public static bool XButton(Vector2 pos, string tooltip = null) { var r = new Rect(pos.x, pos.y, X_BTN_WIDTH, EditorGUIUtility.singleLineHeight); return(GUI.Button(r, EditorHelper.TempContent("X", tooltip))); }
public static string ReflectedRecursingPropertyField(GUIContent label, object targObj, string selectedMemberName, DynamicMemberAccess access, out System.Reflection.MemberInfo selectedMember, bool allowSetterMethods = false) { if (targObj is IDynamic || targObj is IProxy) { var mask = allowSetterMethods ? System.Reflection.MemberTypes.Field | System.Reflection.MemberTypes.Property | System.Reflection.MemberTypes.Method : System.Reflection.MemberTypes.Field | System.Reflection.MemberTypes.Property; System.Reflection.MemberInfo[] members = null; System.Type targTp = null; if (targObj is IDynamic) { targTp = targObj.GetType(); members = DynamicUtil.GetEasilySerializedMembers(targObj, mask, access).ToArray(); } else if (targObj is IProxy) { targTp = (targObj as IProxy).GetTargetType(); members = DynamicUtil.GetEasilySerializedMembersFromType(targTp, mask, access).ToArray(); } else { targTp = typeof(object); members = ArrayUtil.Empty <System.Reflection.MemberInfo>(); } var entries = new GUIContent[members.Length + 1]; int index = -1; for (int i = 0; i < members.Length; i++) { var m = members[i]; if ((DynamicUtil.GetMemberAccessLevel(m) & DynamicMemberAccess.Write) != 0) { entries[i] = EditorHelper.TempContent(string.Format("{0} ({1}) -> {2}", m.Name, DynamicUtil.GetReturnType(m).Name, EditorHelper.GetValueWithMemberSafe(m, targObj, true))); } else { entries[i] = EditorHelper.TempContent(string.Format("{0} (readonly - {1}) -> {2}", m.Name, DynamicUtil.GetReturnType(m).Name, EditorHelper.GetValueWithMemberSafe(m, targObj, true))); } if (index < 0 && m.Name == selectedMemberName) { index = i; } } entries[entries.Length - 1] = EditorHelper.TempContent("...Custom"); if (index < 0) { index = entries.Length - 1; } if (index < members.Length) { index = EditorGUILayout.Popup(label, index, entries); selectedMember = (index >= 0 && index < members.Length) ? members[index] : null; return((selectedMember != null) ? selectedMember.Name : null); } else { var position = EditorGUILayout.GetControlRect(label == GUIContent.none); position = EditorGUI.PrefixLabel(position, label); var r0 = new Rect(position.xMin, position.yMin, position.width / 2f, position.height); var r1 = new Rect(r0.xMax, r0.yMin, position.width - r0.width, r0.height); index = EditorGUI.Popup(r0, index, entries); if (index < members.Length) { selectedMember = (index >= 0) ? members[index] : null; return((selectedMember != null) ? selectedMember.Name : null); } else { selectedMemberName = EditorGUI.TextField(r1, selectedMemberName); selectedMember = new DynamicPropertyInfo(selectedMemberName, targTp, typeof(Variant)); return(selectedMemberName); } } } else if (targObj != null) { var arr = string.IsNullOrEmpty(selectedMemberName) ? ArrayUtil.Empty <string>() : selectedMemberName.Split('.'); return(ReflectedRecursingPropertyField(label, targObj.GetType(), arr, 0, access, out selectedMember, allowSetterMethods)); } else { selectedMember = null; EditorGUILayout.Popup(label, -1, new GUIContent[0]); return(null); } }
public override float GetHeight() { return(EditorStyles.helpBox.CalcSize(EditorHelper.TempContent(_message)).y); }
public static System.Enum EnumPopupExcluding(string label, System.Enum enumValue, params System.Enum[] ignoredValues) { return(SPEditorGUI.EnumPopupExcluding(EditorGUILayout.GetControlRect(true), EditorHelper.TempContent(label), enumValue, ignoredValues)); }
public static object DefaultPropertyField(Rect position, string label, object value, System.Type valueType) { return(DefaultPropertyField(position, EditorHelper.TempContent(label), value, valueType)); }
public static Component SelectComponentField(string label, Component[] components, Component selectedComp) { var position = EditorGUILayout.GetControlRect(true); return(SPEditorGUI.SelectComponentField(position, EditorHelper.TempContent(label), components, selectedComp)); }
public static Gradient GradientField(Rect position, string label, Gradient gradient) { return(GradientField(position, EditorHelper.TempContent(label), gradient)); }
public static bool PropertyField(SerializedObject obj, string prop, string label, bool includeChildren) { return(SPEditorGUILayout.PropertyField(obj, prop, EditorHelper.TempContent(label), includeChildren)); }
public static System.Enum EnumPopupExcluding(Rect position, string label, System.Enum enumValue, params System.Enum[] ignoredValues) { return(EnumPopupExcluding(position, EditorHelper.TempContent(label), enumValue, ignoredValues)); }