protected override TElement DrawElement(Rect rect, TElement value) { bool ediable = !this.TableMatrixAttribute.IsReadOnly; value = SirenixEditorFields.PreviewObjectField(rect, value, false, ediable, ediable); return(value); }
/// <summary> /// Draws the property. /// </summary> protected override void DrawPropertyLayout(GUIContent label) { var entry = this.ValueEntry; if (!drawAsPreview) { if (entry.BaseValueType.IsInterface) { entry.WeakSmartValue = SirenixEditorFields.PolymorphicObjectField( label, entry.WeakSmartValue, entry.BaseValueType, entry.Property.GetAttribute <AssetsOnlyAttribute>() == null); } else { entry.WeakSmartValue = SirenixEditorFields.UnityObjectField( label, entry.WeakSmartValue as UnityEngine.Object, entry.BaseValueType, entry.Property.GetAttribute <AssetsOnlyAttribute>() == null); } } else { entry.WeakSmartValue = SirenixEditorFields.UnityPreviewObjectField( label, entry.WeakSmartValue as UnityEngine.Object, entry.BaseValueType, entry.Property.GetAttribute <AssetsOnlyAttribute>() == null, GeneralDrawerConfig.Instance.SquareUnityObjectFieldHeight, GeneralDrawerConfig.Instance.SquareUnityObjectAlignment); } }
/// <summary> /// Not yet documented. /// </summary> protected override void DrawPropertyLayout(GUIContent label) { // Display evt. errors in creating context. if (this.parentPath.ErrorMessage != null) { SirenixEditorGUI.ErrorMessageBox(this.parentPath.ErrorMessage); } // Gotta check that constantly, the value can change from outside the inspector! //if (this.requireExistingPath && Event.current.type == EventType.Layout) //{ // this.exists = this.PathExists(this.ValueEntry.SmartValue, this.parentPath.GetString(this.Property)); //} // Display required valid path error if enabled. //if (this.requireExistingPath && this.exists == false) //{ // SirenixEditorGUI.ErrorMessageBox("The path does not exist."); //} // Draw field. EditorGUI.BeginChangeCheck(); this.ValueEntry.SmartValue = SirenixEditorFields.FolderPathField(label, this.ValueEntry.SmartValue, this.parentPath.GetString(this.Property), this.Attribute.AbsolutePath, this.Attribute.UseBackslashes); // Update existing check //if (EditorGUI.EndChangeCheck() && requireExistingPath) //{ // this.exists = this.PathExists(this.ValueEntry.SmartValue, this.parentPath.GetString(this.Property)); //} }
private void DrawInlinePropertyReferencePicker() { EditorGUI.BeginChangeCheck(); var prev = EditorGUI.showMixedValue; if (this.ValueEntry.ValueState == PropertyValueState.ReferenceValueConflict) { EditorGUI.showMixedValue = true; } var newValue = SirenixEditorFields.PolymorphicObjectField(this.ValueEntry.WeakSmartValue, this.ValueEntry.BaseValueType, this.allowSceneObjects); EditorGUI.showMixedValue = prev; if (EditorGUI.EndChangeCheck()) { this.ValueEntry.Property.Tree.DelayActionUntilRepaint(() => { this.ValueEntry.WeakValues[0] = newValue; for (int j = 1; j < this.ValueEntry.ValueCount; j++) { this.ValueEntry.WeakValues[j] = SerializationUtility.CreateCopy(newValue); } }); } }
/// <summary> /// Draws the property. /// </summary> protected override void DrawPropertyLayout(GUIContent label) { // TODO: There's currently no SirenixEditorFields.DoubleRangeField, so we're making do with the float field. This should be fixed. double value = this.ValueEntry.SmartValue; if (value < float.MinValue) { value = float.MinValue; } else if (value > float.MaxValue) { value = float.MaxValue; } double min = this.getterMinValue != null?this.getterMinValue.GetValue() : this.Attribute.Min; double max = this.getterMaxValue != null?this.getterMaxValue.GetValue() : this.Attribute.Max; if (this.getterMinValue != null && this.getterMinValue.ErrorMessage != null) { SirenixEditorGUI.ErrorMessageBox(this.getterMinValue.ErrorMessage); } if (this.getterMaxValue != null && this.getterMaxValue.ErrorMessage != null) { SirenixEditorGUI.ErrorMessageBox(this.getterMaxValue.ErrorMessage); } EditorGUI.BeginChangeCheck(); value = SirenixEditorFields.RangeFloatField(label, (float)value, (float)Math.Min(min, max), (float)Math.Max(min, max)); if (EditorGUI.EndChangeCheck()) { this.ValueEntry.SmartValue = value; } }
/// <summary> /// Draws a slider for the passed <see cref="SerializedProperty"/> values. /// </summary> /// <param name="valueProp"></param> /// <param name="minProp"></param> /// <param name="maxProp"></param> public static void DrawClampRangeLayout( SerializedProperty valueProp, SerializedProperty minProp, SerializedProperty maxProp) { var valueType = GetType(valueProp); if (SUPPORTED_INT_TYPES.Contains(valueType)) { #if ODIN_INSPECTOR valueProp.intValue = SirenixEditorFields.RangeIntField( new GUIContent(valueProp.displayName), valueProp.intValue, minProp.intValue, maxProp.intValue); #else EditorGUILayout.IntSlider(valueProp, minProp.intValue, maxProp.intValue); #endif } else if (SUPPORTED_FLOAT_TYPES.Contains(valueType)) { #if ODIN_INSPECTOR valueProp.floatValue = SirenixEditorFields.RangeFloatField( new GUIContent(valueProp.displayName), valueProp.floatValue, minProp.floatValue, maxProp.floatValue); #else EditorGUILayout.Slider(valueProp, minProp.floatValue, maxProp.floatValue); #endif } }
/// <summary> /// Draws the property. /// </summary> protected override void DrawPropertyLayout(GUIContent label) { ulong min = this.getterMinValue != null?this.getterMinValue.GetValue() : (ulong)this.Attribute.Min; ulong max = this.getterMaxValue != null?this.getterMaxValue.GetValue() : (ulong)this.Attribute.Max; if (this.getterMinValue != null && this.getterMinValue.ErrorMessage != null) { SirenixEditorGUI.ErrorMessageBox(this.getterMinValue.ErrorMessage); } if (this.getterMaxValue != null && this.getterMaxValue.ErrorMessage != null) { SirenixEditorGUI.ErrorMessageBox(this.getterMaxValue.ErrorMessage); } EditorGUI.BeginChangeCheck(); int value = SirenixEditorFields.RangeIntField(label, (int)this.ValueEntry.SmartValue, (int)Mathf.Min(min, max), (int)Mathf.Max(min, max)); if (EditorGUI.EndChangeCheck()) { if (value < (int)ulong.MinValue) { value = (int)ulong.MinValue; } else { this.ValueEntry.SmartValue = (ulong)value; } this.ValueEntry.SmartValue = (ulong)value; } }
private static CatalogTuple DrawCell(Rect rect, CatalogTuple tuple) { tuple.Value = (GameObject)SirenixEditorFields.UnityPreviewObjectField( new Rect(rect) { x = rect.x - 8f, yMax = rect.yMax - 16f }, tuple.Value, typeof(GameObject), dragOnly: false, allowMove: true, allowSwap: true, allowSceneObjects: false ); tuple.Key = SirenixEditorFields.TextField( new Rect(rect) { yMin = rect.yMax - 16f }, tuple.Key ); return(tuple); }
/// <summary> /// Draws the property. /// </summary> protected override void DrawPropertyLayout(GUIContent label) { var entry = this.ValueEntry; if (entry.ValueState == PropertyValueState.ReferenceValueConflict) { GUIHelper.PushGUIEnabled(GUI.enabled && entry.IsEditable); if (typeof(UnityEngine.Object).IsAssignableFrom(entry.TypeOfValue)) { bool prev = EditorGUI.showMixedValue; EditorGUI.showMixedValue = true; this.CallNextDrawer(label); EditorGUI.showMixedValue = prev; } else { bool prev = EditorGUI.showMixedValue; EditorGUI.showMixedValue = true; entry.SmartValue = SirenixEditorFields.PolymorphicObjectField(label, entry.SmartValue, entry.BaseValueType, entry.Property.Info.GetAttribute <AssetsOnlyAttribute>() == null) as T; EditorGUI.showMixedValue = prev; } GUIHelper.PopGUIEnabled(); } else { this.CallNextDrawer(label); } }
/// <summary> /// Draws the property. /// </summary> protected override void DrawPropertyLayout(IPropertyValueEntry <Vector2Int> entry, GUIContent label) { GUILayout.BeginHorizontal(); if (label != null) { EditorGUI.BeginChangeCheck(); var value = SirenixEditorFields.VectorPrefixLabel(label, (Vector2)entry.SmartValue); if (EditorGUI.EndChangeCheck()) { entry.SmartValue = new Vector2Int((int)value.x, (int)value.y); } } var r = GUIHelper.GetCurrentLayoutRect(); bool showLabels = !(SirenixEditorFields.ResponsiveVectorComponentFields && (label != null ? r.width - EditorGUIUtility.labelWidth : r.width) < 185); GUIHelper.PushLabelWidth(SirenixEditorFields.SingleLetterStructLabelWidth); GUIHelper.PushIndentLevel(0); entry.Property.Children[0].Draw(showLabels ? GUIHelper.TempContent("X") : null); entry.Property.Children[1].Draw(showLabels ? GUIHelper.TempContent("Y") : null); GUIHelper.PopIndentLevel(); GUIHelper.PopLabelWidth(); GUILayout.EndHorizontal(); }
/// <summary> /// Draws the property. /// </summary> protected override void DrawPropertyLayout(GUIContent label) { ValueResolver.DrawErrors(this.minGetter, this.maxGetter, this.vector2IntMinMaxGetter); // Get the range of the slider from the attribute or from member references. Vector2 range; if (this.vector2IntMinMaxGetter != null && !this.vector2IntMinMaxGetter.HasError) { range = (Vector2)this.vector2IntMinMaxGetter.GetValue(); } else { range.x = this.minGetter.GetValue(); range.y = this.maxGetter.GetValue(); } EditorGUI.BeginChangeCheck(); Vector2 value = SirenixEditorFields.MinMaxSlider(label, (Vector2)this.ValueEntry.SmartValue, range, this.Attribute.ShowFields); if (EditorGUI.EndChangeCheck()) { this.ValueEntry.SmartValue = new Vector2Int((int)value.x, (int)value.y); } }
/// <summary> /// Draws the property. /// </summary> protected override void DrawPropertyLayout(GUIContent label) { var entry = this.ValueEntry; var attribute = this.Attribute; EditorGUI.BeginChangeCheck(); ObjectFieldAlignment alignment; if (attribute.AlignmentHasValue) { alignment = (ObjectFieldAlignment)attribute.Alignment; } else { alignment = GeneralDrawerConfig.Instance.SquareUnityObjectAlignment; } entry.WeakSmartValue = SirenixEditorFields.UnityPreviewObjectField( label, entry.WeakSmartValue as UnityEngine.Object, entry.BaseValueType, entry.Property.Info.GetAttribute <AssetsOnlyAttribute>() == null, attribute.Height == 0 ? GeneralDrawerConfig.Instance.SquareUnityObjectFieldHeight : attribute.Height, alignment); if (EditorGUI.EndChangeCheck()) { entry.Values.ForceMarkDirty(); } }
protected override void DrawPropertyLayout(GUIContent label) { Rect labelRect; Rect contentRect = SirenixEditorGUI.BeginHorizontalPropertyLayout(label, out labelRect); { // Slide rect { var val = this.ValueEntry.SmartValue; EditorGUI.BeginChangeCheck(); var vec = SirenixEditorFields.VectorPrefixSlideRect(labelRect, new Vector4((float)val.x, (float)val.y, (float)val.z, (float)val.w)); val = new double4(vec.x, vec.y, vec.z, vec.w); if (EditorGUI.EndChangeCheck()) { this.ValueEntry.SmartValue = val; } } var showLabels = !this.isMatrixChild && SirenixEditorFields.ResponsiveVectorComponentFields && contentRect.width >= 185; GUIHelper.PushLabelWidth(SirenixEditorFields.SingleLetterStructLabelWidth); this.ValueEntry.Property.Children[0].Draw(showLabels ? GUIHelper.TempContent("X") : null); this.ValueEntry.Property.Children[1].Draw(showLabels ? GUIHelper.TempContent("Y") : null); this.ValueEntry.Property.Children[2].Draw(showLabels ? GUIHelper.TempContent("Z") : null); this.ValueEntry.Property.Children[3].Draw(showLabels ? GUIHelper.TempContent("W") : null); GUIHelper.PopLabelWidth(); } SirenixEditorGUI.EndHorizontalPropertyLayout(); }
public override void OnPreviewGUI(Rect r, GUIStyle background) { var layoutDropdown = new Rect(r.x + 5, r.y + 5, r.width - 10, 20); var layoutImage = new Rect(r.x, layoutDropdown.yMax + 5, r.width, r.yMax - layoutDropdown.yMax - 5); var currentChannel = _currentPreviewChannels[target]; currentChannel = SirenixEditorFields.Dropdown(layoutDropdown, currentChannel, target.GetChannelIdentifiers()); if (target.GetImage(currentChannel)?.Texture != null) { var image = target.GetImage(currentChannel); var s = new GUIStyle { normal = { textColor = Color.white }, alignment = TextAnchor.MiddleCenter, fontSize = r.width > 200 ? 12 : 10 }; GUI.DrawTexture(layoutImage.SubYMax(s.fontSize * 1.5f), image.Texture, ScaleMode.ScaleToFit, true); GUI.Box(layoutImage.AlignBottom(s.fontSize * 1.5f), $"{image.Width} x {image.Height} {image.Format} Image", s); } else { var s = new GUIStyle { normal = { textColor = Color.gray }, alignment = TextAnchor.MiddleCenter }; GUI.Box(layoutImage, "Empty Image", s); } _currentPreviewChannels[target] = currentChannel; }
protected override void DrawPropertyLayout(GUIContent label) { string text = this.ValueEntry.SmartValue.text; int number = this.ValueEntry.SmartValue.number; Vector3 location = this.ValueEntry.SmartValue.location; Rect rect = EditorGUILayout.GetControlRect(); if (label != null) { rect = EditorGUI.PrefixLabel(rect, label); } rect = EditorGUILayout.GetControlRect(); GUIHelper.PushLabelWidth(75); text = SirenixEditorFields.TextField(rect.Split(0, 2), "Text", text); number = SirenixEditorFields.IntField(rect.Split(1, 2), "Number", number); location = SirenixEditorFields.Vector3Field("Location", location); GUIHelper.PopLabelWidth(); this.ValueEntry.SmartValue.text = text; this.ValueEntry.SmartValue.number = number; this.ValueEntry.SmartValue.location = location; }
private int DrawCacheSize(int value, GUIContent label) { value /= 1000; value = SirenixEditorFields.DelayedIntField("Max Cache Size", value); value = value < 1 ? 1 : value > 10000 ? 10000 : value; return(value * 1000); }
/// <summary> /// Draws the property. /// </summary> protected override void DrawPropertyLayout(IPropertyValueEntry <T> entry, GUIContent label) { EditorGUI.BeginChangeCheck(); var drawAsPreview = entry.Context.Get(this, "drawPreview", (bool?)null); if (drawAsPreview.Value == null) { var flags = GeneralDrawerConfig.Instance.SquareUnityObjectEnableFor; drawAsPreview.Value = (int)flags != 0 && ( (flags & GeneralDrawerConfig.UnityObjectType.Components) != 0 && typeof(Component).IsAssignableFrom(typeof(T)) || (flags & GeneralDrawerConfig.UnityObjectType.GameObjects) != 0 && typeof(GameObject).IsAssignableFrom(typeof(T)) || (flags & GeneralDrawerConfig.UnityObjectType.Materials) != 0 && typeof(Material).IsAssignableFrom(typeof(T)) || (flags & GeneralDrawerConfig.UnityObjectType.Sprites) != 0 && typeof(Sprite).IsAssignableFrom(typeof(T)) || (flags & GeneralDrawerConfig.UnityObjectType.Textures) != 0 && typeof(Texture).IsAssignableFrom(typeof(T))); if (!drawAsPreview.Value.Value && (flags & GeneralDrawerConfig.UnityObjectType.Others) != 0) { bool isOther = !typeof(Component).IsAssignableFrom(typeof(T)) && !typeof(GameObject).IsAssignableFrom(typeof(T)) && !typeof(Material).IsAssignableFrom(typeof(T)) && !typeof(Sprite).IsAssignableFrom(typeof(T)) && !typeof(Texture).IsAssignableFrom(typeof(T)); if (isOther) { drawAsPreview.Value = true; } } } if (!drawAsPreview.Value.Value) { entry.WeakSmartValue = SirenixEditorFields.UnityObjectField( label, entry.WeakSmartValue as UnityEngine.Object, entry.BaseValueType, entry.Property.Info.GetAttribute <AssetsOnlyAttribute>() == null); } else { entry.WeakSmartValue = SirenixEditorFields.UnityPreviewObjectField( label, entry.WeakSmartValue as UnityEngine.Object, entry.BaseValueType, entry.Property.Info.GetAttribute <AssetsOnlyAttribute>() == null, GeneralDrawerConfig.Instance.SquareUnityObjectFieldHeight, GeneralDrawerConfig.Instance.SquareUnityObjectAlignment); } if (EditorGUI.EndChangeCheck()) { entry.Values.ForceMarkDirty(); } }
/// <summary> /// Draws the property. /// </summary> protected override void DrawPropertyLayout(IPropertyValueEntry <decimal> entry, PropertyRangeAttribute attribute, GUIContent label) { EditorGUI.BeginChangeCheck(); float value = SirenixEditorFields.RangeFloatField(label, (float)entry.SmartValue, (float)attribute.Min, (float)attribute.Max); if (EditorGUI.EndChangeCheck()) { entry.SmartValue = (decimal)value; } }
protected override void DrawPropertyLayout(IPropertyValueEntry <Wall> entry, GUIContent label) { EditorGUI.BeginChangeCheck(); var info = SirenixEditorFields.EnumDropdown(entry.Property.Info.PropertyName, entry.SmartValue.Info); if (EditorGUI.EndChangeCheck()) { entry.SmartValue = new Wall(entry.SmartValue.buildingPosition, entry.SmartValue.direction, (WallInfo)info); } }
protected override void DrawPropertyLayout(IPropertyValueEntry <Wall> entry, GUIContent label) { EditorGUI.BeginChangeCheck(); var info = SirenixEditorFields.EnumDropdown("Info", entry.SmartValue.Info); if (EditorGUI.EndChangeCheck()) { entry.SmartValue.Info = (WallInfo)info; } }
/// <summary> /// Draws a progress bar for a decimal property. /// </summary> protected override decimal DrawProgressBar(Rect rect, GUIContent label, double min, double max, ProgressBarConfig config, string valueLabel) { if (this.Attribute.Segmented) { return((decimal)SirenixEditorFields.SegmentedProgressBarField(rect, label, (long)this.ValueEntry.SmartValue, (long)min, (long)max, config, valueLabel)); } else { return((decimal)SirenixEditorFields.ProgressBarField(rect, label, (double)this.ValueEntry.SmartValue, min, max, config, valueLabel)); } }
/// <summary> /// Draws the property. /// </summary> protected override void DrawPropertyLayout(IPropertyValueEntry <T> entry, GUIContent label) { if (GeneralDrawerConfig.Instance.UseImprovedEnumDropDown) { entry.SmartValue = EnumSelector <T> .DrawEnumField(label, entry.SmartValue); } else { entry.WeakSmartValue = SirenixEditorFields.EnumDropdown(label, (Enum)entry.WeakSmartValue); } }
/// <summary> /// Draws the property. /// </summary> protected override void DrawPropertyLayout(IPropertyValueEntry <ulong> entry, GUIContent label) { long value = SirenixEditorFields.LongField(label, (long)entry.SmartValue); if (value < 0) { value = 0; } entry.SmartValue = (ulong)value; }
/// <summary> /// Draws a progress bar for a decimal property. /// </summary> protected override decimal DrawProgressBar(Rect rect, GUIContent label, decimal value, ProgressBarAttribute attribute, ProgressBarConfig config, string valueLabel) { if (attribute.Segmented) { return((decimal)SirenixEditorFields.SegmentedProgressBarField(rect, label, (long)value, (long)attribute.Min, (long)attribute.Max, config, valueLabel)); } else { return((decimal)SirenixEditorFields.ProgressBarField(rect, label, (double)value, attribute.Min, attribute.Max, config, valueLabel)); } }
private float Bar(float value, GUIContent content) { Rect rect = EditorGUILayout.GetControlRect(); ProgressBarConfig config = new ProgressBarConfig(); config.Height = Convert.ToInt16(rect.height); config.ForegroundColor = GetHealthBarColor(CurrentHealth); return((float)SirenixEditorFields.ProgressBarField(rect, CurrentHealth, 0, MaxHealth, config)); }
/// <summary> /// Draws the property. /// </summary> protected override void DrawPropertyLayout(GUIContent label) { EditorGUI.BeginChangeCheck(); string s = new string(this.ValueEntry.SmartValue, 1); s = SirenixEditorFields.DelayedTextField(label, s, GUILayoutOptions.MinWidth(0)); if (EditorGUI.EndChangeCheck() && s.Length > 0) { this.ValueEntry.SmartValue = s[0]; } }
/// <summary> /// Draws the property. /// </summary> protected override void DrawPropertyLayout(GUIContent label) { decimal value = this.ValueEntry.SmartValue; string str = value.ToString(); str = SirenixEditorFields.DelayedTextField(label, str, GUILayoutOptions.MinWidth(0)); if (GUI.changed && decimal.TryParse(str, out value)) { this.ValueEntry.SmartValue = value; } }
/// <summary> /// Draws the property. /// </summary> protected override void DrawPropertyLayout(IPropertyValueEntry <char> entry, GUIContent label) { EditorGUI.BeginChangeCheck(); string s = new string(entry.SmartValue, 1); s = SirenixEditorFields.TextField(label, s); if (EditorGUI.EndChangeCheck() && s.Length > 0) { entry.SmartValue = s[0]; } }
/// <summary> /// Draws the property. /// </summary> protected override void DrawPropertyLayout(GUIContent label) { // Get the range of the slider from the attribute or from member references. Vector2 range; if (vector2IntMinMaxGetter != null && errorMessage == null) { range = (Vector2)vector2IntMinMaxGetter.GetValue(); } else { if (intMinGetter != null) { range.x = intMinGetter.GetValue(); } else if (floatMinGetter != null) { range.x = floatMinGetter.GetValue(); } else { range.x = Attribute.MinValue; } if (intMaxGetter != null) { range.y = intMaxGetter.GetValue(); } else if (floatMaxGetter != null) { range.y = floatMaxGetter.GetValue(); } else { range.y = Attribute.MaxValue; } } // Display evt. error message. if (errorMessage != null) { SirenixEditorGUI.ErrorMessageBox(errorMessage); } EditorGUI.BeginChangeCheck(); var value = SirenixEditorFields.MinMaxSlider(label, (Vector2)ValueEntry.SmartValue, range, Attribute.ShowFields); if (EditorGUI.EndChangeCheck()) { ValueEntry.SmartValue = new Vector2Int((int)value.x, (int)value.y); } }
/// <summary> /// Draws the property. /// </summary> protected override void DrawPropertyLayout(GUIContent label) { var entry = this.ValueEntry; var attribute = this.Attribute; EditorGUI.BeginChangeCheck(); float value = SirenixEditorFields.RangeFloatField(label, (float)entry.SmartValue, attribute.min, attribute.max); if (EditorGUI.EndChangeCheck()) { entry.SmartValue = (decimal)value; } }