public static WrapMode WrapModeField(string label, WrapMode mode, bool allowDefault = false) { var position = EditorGUILayout.GetControlRect(true); return(SPEditorGUI.WrapModeField(position, 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 System.Enum EnumPopupExcluding(GUIContent label, System.Enum enumValue, params System.Enum[] ignoredValues) { return(SPEditorGUI.EnumPopupExcluding(EditorGUILayout.GetControlRect(label != null && label != GUIContent.none), label, enumValue, ignoredValues)); }
public static Component SelectComponentField(GUIContent label, Component[] components, GUIContent[] componentLabels, Component selectedComp) { var position = EditorGUILayout.GetControlRect(true); return(SPEditorGUI.SelectComponentField(position, label, components, componentLabels, selectedComp)); }
/// <summary> /// Reflects the available properties and shows them in a dropdown /// </summary> public static string ReflectedPropertyField(GUIContent label, System.Type targType, string selectedMemberName, out System.Reflection.MemberInfo selectedMember) { var position = EditorGUILayout.GetControlRect(label == GUIContent.none); return(SPEditorGUI.ReflectedPropertyField(position, label, targType, selectedMemberName, out selectedMember)); }
public static Quaternion QuaternionField(GUIContent label, Quaternion value, bool useRadians = false) { var position = EditorGUILayout.GetControlRect(true); return(SPEditorGUI.QuaternionField(position, label, value, useRadians)); }
public static Component SelectComponentFromSourceField(GUIContent label, GameObject source, Component selectedComp, System.Predicate <Component> filter = null) { var position = EditorGUILayout.GetControlRect(true); return(SPEditorGUI.SelectComponentFromSourceField(position, label, source, selectedComp, filter)); }
public static string OptionPopupWithCustom(GUIContent label, string value, string[] options) { return(SPEditorGUI.OptionPopupWithCustom(EditorGUILayout.GetControlRect(false), label, value, options)); }
public static int EnumFlagField(System.Type enumType, int[] acceptedFlags, GUIContent label, int value) { var position = EditorGUILayout.GetControlRect(true); return(SPEditorGUI.EnumFlagField(position, enumType, acceptedFlags, label, value)); }
public static object DefaultPropertyField(Rect position, GUIContent label, object value, System.Type valueType) { var propertyType = (valueType != null) ? EditorHelper.GetPropertyType(valueType) : SerializedPropertyType.Generic; switch (propertyType) { case SerializedPropertyType.Integer: EditorGUI.BeginChangeCheck(); int num1 = EditorGUI.IntField(position, label, ConvertUtil.ToInt(value)); if (EditorGUI.EndChangeCheck()) { return(num1); } else { break; } case SerializedPropertyType.Boolean: EditorGUI.BeginChangeCheck(); bool flag2 = EditorGUI.Toggle(position, label, ConvertUtil.ToBool(value)); if (EditorGUI.EndChangeCheck()) { return(flag2); } else { break; } case SerializedPropertyType.Float: EditorGUI.BeginChangeCheck(); float num2 = EditorGUI.FloatField(position, label, ConvertUtil.ToSingle(value)); if (EditorGUI.EndChangeCheck()) { return(num2); } else { break; } case SerializedPropertyType.String: EditorGUI.BeginChangeCheck(); string str1 = EditorGUI.TextField(position, label, ConvertUtil.ToString(value)); if (EditorGUI.EndChangeCheck()) { return(str1); } else { break; } case SerializedPropertyType.Color: EditorGUI.BeginChangeCheck(); Color color = EditorGUI.ColorField(position, label, ConvertUtil.ToColor(value)); if (EditorGUI.EndChangeCheck()) { return(color); } else { break; } case SerializedPropertyType.ObjectReference: EditorGUI.BeginChangeCheck(); object obj = EditorGUI.ObjectField(position, label, value as UnityEngine.Object, valueType, true); if (EditorGUI.EndChangeCheck()) { return(obj); } break; case SerializedPropertyType.LayerMask: EditorGUI.BeginChangeCheck(); LayerMask mask = (value is LayerMask) ? (LayerMask)value : (LayerMask)ConvertUtil.ToInt(value); mask = SPEditorGUI.LayerMaskField(position, label, mask); if (EditorGUI.EndChangeCheck()) { return(mask); } break; case SerializedPropertyType.Enum: if (valueType.GetCustomAttributes(typeof(System.FlagsAttribute), false).Any()) { EditorGUI.BeginChangeCheck(); var e = SPEditorGUI.EnumFlagField(position, label, ConvertUtil.ToEnumOfType(valueType, value)); if (EditorGUI.EndChangeCheck()) { return(e); } } else { EditorGUI.BeginChangeCheck(); var e = SPEditorGUI.EnumPopupExcluding(position, label, ConvertUtil.ToEnumOfType(valueType, value)); if (EditorGUI.EndChangeCheck()) { return(e); } } break; case SerializedPropertyType.Vector2: EditorGUI.BeginChangeCheck(); var v2 = EditorGUI.Vector2Field(position, label, ConvertUtil.ToVector2(value)); if (EditorGUI.EndChangeCheck()) { return(v2); } break; case SerializedPropertyType.Vector3: EditorGUI.BeginChangeCheck(); var v3 = EditorGUI.Vector3Field(position, label, ConvertUtil.ToVector3(value)); if (EditorGUI.EndChangeCheck()) { return(v3); } break; case SerializedPropertyType.Vector4: EditorGUI.BeginChangeCheck(); var v4 = EditorGUI.Vector4Field(position, label.text, ConvertUtil.ToVector4(value)); if (EditorGUI.EndChangeCheck()) { return(v4); } break; case SerializedPropertyType.Rect: EditorGUI.BeginChangeCheck(); Rect rect = (value is Rect) ? (Rect)value : new Rect(); rect = EditorGUI.RectField(position, label, rect); if (EditorGUI.EndChangeCheck()) { return(rect); } break; case SerializedPropertyType.ArraySize: EditorGUI.BeginChangeCheck(); int num3 = EditorGUI.IntField(position, label, ConvertUtil.ToInt(value), EditorStyles.numberField); if (EditorGUI.EndChangeCheck()) { return(num3); } break; case SerializedPropertyType.Character: bool changed = GUI.changed; GUI.changed = false; string str2 = EditorGUI.TextField(position, label, new string(ConvertUtil.ToChar(value), 1)); if (GUI.changed) { if (str2.Length == 1) { return(str2[0]); } else { GUI.changed = false; } } GUI.changed = GUI.changed | changed; break; case SerializedPropertyType.AnimationCurve: EditorGUI.BeginChangeCheck(); AnimationCurve curve = value as AnimationCurve; curve = EditorGUI.CurveField(position, label, curve); if (EditorGUI.EndChangeCheck()) { return(curve); } break; case SerializedPropertyType.Bounds: EditorGUI.BeginChangeCheck(); Bounds bnds = (value is Bounds) ? (Bounds)value : new Bounds(); bnds = EditorGUI.BoundsField(position, label, bnds); if (EditorGUI.EndChangeCheck()) { return(bnds); } break; case SerializedPropertyType.Gradient: EditorGUI.BeginChangeCheck(); Gradient grad = value as Gradient; grad = SPEditorGUI.GradientField(position, label, grad); if (EditorGUI.EndChangeCheck()) { return(grad); } break; default: EditorGUI.PrefixLabel(position, label); break; } return(value); }
public static void MultiFloatField(Rect position, GUIContent[] subLabels, float[] values) { //EditorGUI.MultiFloatField(position, subLabels, values); SPEditorGUI.MultiFloatField(position, subLabels, values, 13f); }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { var r0 = new Rect(position.xMin, position.yMin, position.width / 2f, position.height); var r1 = new Rect(r0.xMax, position.yMin, position.width - r0.width, position.height); var propName = property.FindPropertyRelative(PROP_NAME); var propValue = property.FindPropertyRelative(PROP_VALUE); var propRef = property.FindPropertyRelative(PROP_REF); int index = System.Array.IndexOf(_knownPlayerSettingPropNames, propName.stringValue); EditorGUI.BeginChangeCheck(); index = EditorGUI.Popup(r0, GUIContent.none, index, _knownPlayerSettingPropNamesPretty); if (EditorGUI.EndChangeCheck()) { if (index >= 0 && index < _knownPlayerSettingPropNames.Length) { propName.stringValue = _knownPlayerSettingPropNames[index]; } else { propName.stringValue = string.Empty; } propValue.stringValue = string.Empty; propRef.objectReferenceValue = null; } if (index < 0 || index >= _knownPlayerSettings.Length) { return; } var info = _knownPlayerSettings[index]; if (info.PropertyType.IsEnum) { int ei = ConvertUtil.ToInt(propValue.stringValue); propValue.stringValue = ConvertUtil.ToInt(EditorGUI.EnumPopup(r1, ConvertUtil.ToEnumOfType(info.PropertyType, ei))).ToString(); propRef.objectReferenceValue = null; } else { var etp = VariantReference.GetVariantType(info.PropertyType); switch (etp) { case VariantType.Null: propValue.stringValue = string.Empty; propRef.objectReferenceValue = null; break; case VariantType.String: propValue.stringValue = EditorGUI.TextField(r1, propValue.stringValue); propRef.objectReferenceValue = null; break; case VariantType.Boolean: propValue.stringValue = ConvertUtil.Stringify(EditorGUI.Toggle(r1, GUIContent.none, ConvertUtil.ToBool(propValue.stringValue))); propRef.objectReferenceValue = null; break; case VariantType.Integer: propValue.stringValue = EditorGUI.IntField(r1, GUIContent.none, ConvertUtil.ToInt(propValue.stringValue)).ToString(); propRef.objectReferenceValue = null; break; case VariantType.Float: propValue.stringValue = EditorGUI.FloatField(r1, GUIContent.none, ConvertUtil.ToSingle(propValue.stringValue)).ToString(); propRef.objectReferenceValue = null; break; case VariantType.Double: propValue.stringValue = EditorGUI.DoubleField(r1, GUIContent.none, ConvertUtil.ToDouble(propValue.stringValue)).ToString(); propRef.objectReferenceValue = null; break; case VariantType.Vector2: propValue.stringValue = ConvertUtil.Stringify(EditorGUI.Vector2Field(r1, GUIContent.none, ConvertUtil.ToVector2(propValue.stringValue))); propRef.objectReferenceValue = null; break; case VariantType.Vector3: propValue.stringValue = ConvertUtil.Stringify(EditorGUI.Vector3Field(r1, GUIContent.none, ConvertUtil.ToVector3(propValue.stringValue))); propRef.objectReferenceValue = null; break; case VariantType.Vector4: propValue.stringValue = ConvertUtil.Stringify(EditorGUI.Vector4Field(r1, (string)null, ConvertUtil.ToVector4(propValue.stringValue))); propRef.objectReferenceValue = null; break; case VariantType.Quaternion: propValue.stringValue = ConvertUtil.Stringify(SPEditorGUI.QuaternionField(r1, GUIContent.none, ConvertUtil.ToQuaternion(propValue.stringValue))); propRef.objectReferenceValue = null; break; case VariantType.Color: propValue.stringValue = ConvertUtil.Stringify(EditorGUI.ColorField(r1, ConvertUtil.ToColor(propValue.stringValue))); propRef.objectReferenceValue = null; break; case VariantType.DateTime: //TODO - should never actually occur propValue.stringValue = string.Empty; propRef.objectReferenceValue = null; break; case VariantType.GameObject: case VariantType.Component: case VariantType.Object: propValue.stringValue = string.Empty; propRef.objectReferenceValue = EditorGUI.ObjectField(r1, GUIContent.none, propValue.objectReferenceValue, info.PropertyType, false); break; case VariantType.LayerMask: propValue.stringValue = SPEditorGUI.LayerMaskField(r1, GUIContent.none, ConvertUtil.ToInt(propValue.stringValue)).ToString(); propRef.objectReferenceValue = null; break; case VariantType.Rect: //TODO - should never actually occur propValue.stringValue = string.Empty; propRef.objectReferenceValue = null; break; case VariantType.Numeric: break; } } }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { this.Init(property); EditorGUI.BeginProperty(position, label, property); //################################ //FIRST LINE var rect = new Rect(position.xMin, position.yMin, position.width, EditorGUIUtility.singleLineHeight); rect = EditorGUI.PrefixLabel(rect, label); var targetProp = property.FindPropertyRelative(PROP_TARGET); var w0 = Mathf.Min(rect.width * 0.3f, 80f); var w1 = rect.width - w0; var r0 = new Rect(rect.xMin, rect.yMin, w0, rect.height); var r1 = new Rect(r0.xMax, rect.yMin, w1, rect.height); var searchProp = property.FindPropertyRelative(PROP_SEARCHBY); var queryProp = property.FindPropertyRelative(PROP_QUERY); var eSearchBy = (SearchByAlt)searchProp.GetEnumValue <SearchBy>(); EditorGUI.BeginChangeCheck(); eSearchBy = (SearchByAlt)EditorGUI.EnumPopup(r0, eSearchBy); if (EditorGUI.EndChangeCheck()) { searchProp.SetEnumValue((SearchBy)eSearchBy); } switch (eSearchBy) { case SearchByAlt.Direct: { var tp = (_configAttrib != null) ? _configAttrib.TargetType : typeof(UnityEngine.Object); targetProp.objectReferenceValue = EditorGUI.ObjectField(r1, targetProp.objectReferenceValue, tp, true); } break; case SearchByAlt.Tag: { queryProp.stringValue = EditorGUI.TagField(r1, queryProp.stringValue); targetProp.objectReferenceValue = null; } break; case SearchByAlt.Name: { queryProp.stringValue = EditorGUI.TextField(r1, queryProp.stringValue); targetProp.objectReferenceValue = null; } break; case SearchByAlt.Type: { var tp = TypeUtil.FindType(queryProp.stringValue); if (!TypeUtil.IsType(tp, typeof(UnityEngine.Object))) { tp = null; } tp = SPEditorGUI.TypeDropDown(r1, GUIContent.none, typeof(UnityEngine.Object), tp); queryProp.stringValue = (tp != null) ? tp.FullName : null; targetProp.objectReferenceValue = null; } break; } EditorGUI.EndProperty(); }
public static System.Enum EnumPopup(GUIContent label, System.Enum enumValue) { return(SPEditorGUI.EnumPopup(EditorGUILayout.GetControlRect(label != null && label != GUIContent.none), label, enumValue)); }
public static WrapMode WrapModeField(GUIContent label, WrapMode mode, bool allowDefault = false) { var position = EditorGUILayout.GetControlRect(label != null && label != GUIContent.none); return(SPEditorGUI.WrapModeField(position, label, mode, allowDefault)); }
public static object DefaultPropertyField(GUIContent label, object value, System.Type valueType) { return(SPEditorGUI.DefaultPropertyField(EditorGUILayout.GetControlRect(true), label, value, valueType)); }
public static System.Type TypeDropDown(GUIContent label, System.Type baseType, System.Type selectedType, bool allowAbstractTypes = false, bool allowInterfaces = false, System.Type defaultType = null, System.Type[] excludedTypes = null, TypeDropDownListingStyle listType = TypeDropDownListingStyle.Namespace) { var position = EditorGUILayout.GetControlRect(true); return(SPEditorGUI.TypeDropDown(position, label, baseType, selectedType, allowAbstractTypes, allowInterfaces, defaultType, excludedTypes, listType)); }
public static string FolderPathTextfield(GUIContent label, string path, string popupTitle) { return(SPEditorGUI.FolderPathTextfield(EditorGUILayout.GetControlRect(true), label, path, popupTitle)); }
public static Component ComponentField(GUIContent label, Component value, System.Type inheritsFromType, bool allowSceneObjects) { var position = EditorGUILayout.GetControlRect(true); return(SPEditorGUI.ComponentField(position, label, value, inheritsFromType, allowSceneObjects)); }
public static string SaveFilePathTextfield(GUIContent label, string path, string popupTitle, string extension) { return(SPEditorGUI.SaveFilePathTextfield(EditorGUILayout.GetControlRect(true), label, path, popupTitle, extension)); }
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 System.Enum EnumPopupExcluding(System.Enum enumValue, params System.Enum[] ignoredValues) { return(SPEditorGUI.EnumPopupExcluding(EditorGUILayout.GetControlRect(false), enumValue, ignoredValues)); }
/// <summary> /// Reflects the available properties and shows them in a dropdown /// </summary> public static string ReflectedPropertyField(GUIContent label, object targObj, string selectedMemberName, com.spacepuppy.Dynamic.DynamicMemberAccess access, out System.Reflection.MemberInfo selectedMember) { var position = EditorGUILayout.GetControlRect(label == GUIContent.none); return(SPEditorGUI.ReflectedPropertyField(position, label, targObj, selectedMemberName, access, out selectedMember)); }
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(string label, object value, System.Type valueType) { return(SPEditorGUI.DefaultPropertyField(EditorGUILayout.GetControlRect(true), EditorHelper.TempContent(label), value, valueType)); }
public static System.Enum EnumPopup(System.Enum enumValue) { return(SPEditorGUI.EnumPopup(EditorGUILayout.GetControlRect(false), enumValue)); }