public void DrawAfter(CyberAttribute cyberAttributer) { OnValueChangedAttribute atr = cyberAttributer as OnValueChangedAttribute; if (EditorGUI.EndChangeCheck()) { CyberEdit.Current.SerializedObject.ApplyModifiedProperties(); var method = CyberEdit.Current.Target.GetType().GetMethod(atr.Call, BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Static); object[] parameters; object caller; if (method.GetParameters().Length > 0) { parameters = new object[] { CyberEdit.Current.CurrentField.GetValue(CyberEdit.Current.Target) } } ; else { parameters = new object[0]; } if (method.IsStatic) { caller = null; } else { caller = CyberEdit.Current.Target; } method.Invoke(caller, parameters); } }
public void ChangeGuiStyle(CyberAttribute attrribute, ref GUIStyle style, ref string customName) { var fatr = (attrribute as CustomGuiAttribute); style = fatr.ApplyStyle(style); customName = fatr.Label ?? customName; }
public void DrawBefore(CyberAttribute cyberAttribute) { bool before; before = GUI.enabled; GUI.enabled = true; var attribute = cyberAttribute as StartHorizontalAttribute; EditorGUILayout.BeginHorizontal(); if (attribute.Name != null) { EditorGUILayout.PrefixLabel(new GUIContent((attribute.Name)), new GUIStyle(), new GUIStyle() { fixedWidth = 20 }); } if (attribute.RightPush != 0) { GUILayout.Label("", GUILayout.Width(attribute.RightPush)); } TheEditor.BeginHorizontal(attribute.BackgroundMode); CyberEdit.Current.PushHorizontalStack(); GUI.enabled = before; }
private void DrawAdditional(CyberAttribute cyberAttribute) { ButtonAttribute attribute = cyberAttribute as ButtonAttribute; var type = CyberEdit.Current.GetFinalTargetType(); DrawMethod(type.GetMethod(attribute.Method, BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Static), attribute); }
public void DrawBefore(CyberAttribute cyberAttribute) { SeparatorAttribute attribute = cyberAttribute as SeparatorAttribute; EditorGUILayout.BeginHorizontal(); var content = new GUIContent(attribute.Label); float width = EditorStyles.label.CalcSize(content).x + 2; if (string.IsNullOrEmpty(attribute.Label) == false) { DrawMinBox(); EditorGUILayout.LabelField(attribute.Label, attribute.ApplyStyle(new GUIStyle("label")), GUILayout.Width(width)); DrawMinBox(); } else { DrawMinBox(); } EditorGUILayout.EndHorizontal(); void DrawMinBox() { var style = new GUIStyle("groupBox"); EditorGUILayout.BeginVertical(); GUILayout.Box(GUIContent.none, style, GUILayout.Height(attribute.Height / (float)UISize.Default), GUILayout.MaxWidth(int.MaxValue)); EditorGUILayout.EndVertical(); } }
public void DrawBefore(CyberAttribute cyberAttribute) { ColorSeparatorAttribute colorSeparatorAttribute = cyberAttribute as ColorSeparatorAttribute; EditorGUI.DrawRect(EditorGUI.IndentedRect(EditorGUILayout.GetControlRect(true, colorSeparatorAttribute.Height)), colorSeparatorAttribute.CurColor); }
public void DrawBefore(CyberAttribute atr) { TheEditor.PrepareToRefuseGui(this.GetType()); Color color = ((BackgroundAttribute)atr).CurColor; GUI.backgroundColor = (Color)color; }
public void DrawDirectly(SerializedProperty property, CyberAttribute attribute, GUIContent content, GUIStyle style, FieldInfo field) { ArrayAsFieldsAttribute atr = attribute as ArrayAsFieldsAttribute; property.arraySize = atr.Names?.Length ?? 1; TheEditor.DrawArray(field, GUIContent.none, property, false, false, false, atr.Names ?? new string[] { "_NoName_" }); }
public void DrawDirectly(SerializedProperty property, CyberAttribute atribute, GUIContent content, GUIStyle style, FieldInfo field) { EditorGUILayout.BeginHorizontal(); TheEditor.DrawPrefix(content, field, style); property.stringValue = EditorGUILayout.TagField(property.stringValue); EditorGUILayout.EndHorizontal(); }
public bool DrawPrefix(GUIContent content, GUIStyle style, CyberAttribute cyberAttrribute) { var attribute = cyberAttrribute as ShortPrefixAttribute; EditorGUILayout.LabelField(content, GUILayout.Width(attribute.Width)); return(true); }
public void DrawDirectly(SerializedProperty property, CyberAttribute atrribute, GUIContent content, GUIStyle style, FieldInfo field) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel(content); string[] all = GetAllSortingLayers(); string val = property.stringValue; if (all.Any(item => item != property.stringValue) == false) { val = all[0]; } if (EditorGUILayout.DropdownButton(new GUIContent(val), FocusType.Passive)) { GenericMenu generic = new GenericMenu(); foreach (string item in all) { generic.AddItem(new GUIContent(item), false, (data) => { property.stringValue = data.ToString(); property.serializedObject.ApplyModifiedProperties(); }, item); } generic.ShowAsContext(); } property.stringValue = val; EditorGUILayout.EndHorizontal(); }
public void DrawDirectly(SerializedProperty property, CyberAttribute atribute, GUIContent content, GUIStyle style, FieldInfo field) { EditorGUILayout.BeginHorizontal(); TheEditor.DrawPrefix(content, field, style); property.objectReferenceValue = EditorGUILayout.ObjectField(GUIContent.none, property.objectReferenceValue, CyberEdit.Current.GetFieldByName(property.name).FieldType, false); EditorGUILayout.EndHorizontal(); }
public void DrawAfter(CyberAttribute cyberAttribute) { if (GUILayout.Button("↺", GUILayout.Width(20))) { Restore(CyberEdit.Current.CurrentProp, CyberEdit.Current.CurrentField, cyberAttribute); } EditorGUILayout.EndHorizontal(); }
public void DrawBefore(CyberAttribute atr) { IndentLvAttribute indentLvAttribute = atr as IndentLvAttribute; if (indentLvAttribute.Mode != IndentMode.After) { Draw(indentLvAttribute); } }
public void DrawBefore(CyberAttribute cyberAttrribute) { OnlyRuntimeAttribute atr = cyberAttrribute as OnlyRuntimeAttribute; if (Application.isPlaying == false) { GUI.enabled = false; } }
public void DrawEnd(CyberAttribute cyberAttribute) { var attribute = cyberAttribute as StartHorizontalAttribute; TheEditor.EndHorizontal(attribute.BackgroundMode); EditorGUILayout.EndHorizontal(); CyberEdit.Current.PopHorizontalStack(); }
public void DrawDirectly(SerializedProperty property, CyberAttribute atribute, GUIContent content, GUIStyle style, FieldInfo field) { if (UnityEditorInternal.InternalEditorUtility.layers.Contains(property.stringValue) == false) { property.stringValue = UnityEditorInternal.InternalEditorUtility.layers[0]; } TheEditor.DrawPropertyAsDropdown(property, field, content, style, UnityEditorInternal.InternalEditorUtility.layers, (item) => property.stringValue = item?.ToString() ?? "null", null, true); }
public void DrawDirectly(SerializedProperty property, CyberAttribute atribute, GUIContent content, GUIStyle style, FieldInfo field) { DropdownAttribute atr = atribute as DropdownAttribute; TheEditor.DrawPropertyAsDropdownWithFixValue(property, field, content, style, atr.Values, (i) => property.SetValue(i), property.GetJustValue(), (item, index) => atr.Names[index], true, atr.ShowAsName); }
public void DrawAfter(CyberAttribute cyberAttribute) { OptionalDropdownAttribute atr = cyberAttribute as OptionalDropdownAttribute; var prop = CyberEdit.Current.CurrentProp; TheEditor.DrawPropertyAsDropdown(CyberEdit.Current.CurrentProp, CyberEdit.Current.CurrentField, null, null, atr.Values, (i) => prop.SetValue(i), (item, index) => atr.Names[index], drawPrefix: false); EditorGUILayout.EndHorizontal(); }
public void DrawDirectly(SerializedProperty property, CyberAttribute atribute, GUIContent content, GUIStyle style, FieldInfo field) { MinMaxRangeAttribute atr = atribute as MinMaxRangeAttribute; EditorGUILayout.BeginHorizontal(); TheEditor.DrawPrefix(content, field, style); property.SetValue(EditorGUILayout.Slider((float)Convert.ChangeType(property.GetJustValue(), typeof(float)), atr.Min, atr.Max)); EditorGUILayout.EndHorizontal(); }
public void DrawMethod(MethodInfo method, CyberAttribute cyberAttrribute) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel(method.Name); TheEditor.PrepareToRefuseGui(this); GUI.enabled = false; EditorGUILayout.TextField(method.Invoke(CyberEdit.Current.Target, null)?.ToString() ?? "null"); TheEditor.RefuseGui(this); EditorGUILayout.EndHorizontal(); }
public void DrawAfterSize(SerializedProperty prop, CyberAttribute cyberAttrribute) { var attribute = cyberAttrribute as ConstSizeAttribute; if (prop.arraySize != attribute.Size) { prop.arraySize = attribute.Size; } GUI.enabled = befor; }
public void DrawBefore(CyberAttribute atr) { var attribute = atr as HelpBoxAttribute; TheEditor.HelpBox(attribute.Text, attribute.MessageType, new GUIStyle() { fixedHeight = attribute.Height, fixedWidth = attribute.Width }); }
public void DrawBefore(CyberAttribute atr) { ToolbarAttribute attribute = atr as ToolbarAttribute; CyberEdit.Current.SetToolbarSelect (attribute.ToolbarId, GUILayout.Toolbar(CyberEdit.Current.GetToolbarSelect(attribute.ToolbarId), attribute.Names)); CyberEdit.Current.SetToolbarElementCollection(attribute.ToolbarId, attribute.Names); }
public void DrawDirectly(SerializedProperty property, CyberAttribute atribute, GUIContent content, GUIStyle style, FieldInfo field) { HorizontalArrayAttribute atr = atribute as HorizontalArrayAttribute; if (property.isExpanded = EditorGUILayout.Foldout(property.isExpanded, content, true)) { EditorGUI.indentLevel++; TheEditor.DrawSize(field, CyberEdit.Current.CurrentProp); EditorGUILayout.BeginVertical("GroupBox"); EditorGUILayout.BeginHorizontal(); EditorGUILayout.BeginVertical(); EditorGUILayout.BeginHorizontal(); int before = EditorGUI.indentLevel; EditorGUI.indentLevel = 0; int index = 0; foreach (SerializedProperty pr in property.ToEnumerable()) { bool next = index != 0 && index % atr.ElementAtOneWide == 0; if (next) { EditorGUILayout.EndHorizontal(); } if (next) { EditorGUILayout.BeginHorizontal(); } EditorGUILayout.PropertyField(pr, GUIContent.none, GUILayout.MinWidth(atr.MinWith)); index++; } if (index % atr.ElementAtOneWide != 0) { for (int x = 0; x < atr.ElementAtOneWide - index % atr.ElementAtOneWide; x++) { EditorGUILayout.LabelField("", GUILayout.MinWidth(atr.MinWith)); } } EditorGUI.indentLevel = before; EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); EditorGUI.indentLevel--; } }
public void DrawDirectly(SerializedProperty property, CyberAttribute atribute, GUIContent content, GUIStyle style, FieldInfo field) { content.text += $" {{size:{property.arraySize}}}"; EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel(content, new GUIStyle(), style); if (GUILayout.Button("Open")) { ArrayWindow.Open(CyberEdit.Current.Target, field, content); } EditorGUILayout.EndHorizontal(); }
public void DrawAfter(CyberAttribute cyberAttribute) { ResetButtonAttribute attribute = cyberAttribute as ResetButtonAttribute; if (GUILayout.Button("↺", GUILayout.Width(20))) { CyberEdit.Current.CurrentProp.SetValue(attribute.Value); } EditorGUILayout.EndHorizontal(); }
public void DrawBefore(CyberAttribute cyberAttributer) { EditorGUILayout.BeginHorizontal(); ButtonAttribute attribute = cyberAttributer as ButtonAttribute; if (attribute.After == false) { DrawAdditional(cyberAttributer); EditorGUILayout.EndHorizontal(); } }
public void DrawDirectly(SerializedProperty property, CyberAttribute atribute, GUIContent content, GUIStyle style, FieldInfo field) { bool drawExpand = true; bool isExpand = false; if (CyberEdit.Current.CurrentProp == null) { return; } if (CyberEdit.Current.CurrentProp.propertyType != SerializedPropertyType.ObjectReference) { Debug.LogError($"{nameof(AssetVievDrawer)} should be use only with objectReference type"); } if (CyberEdit.Current.CurrentProp.objectReferenceValue == null) { drawExpand = true; } EditorGUILayout.BeginHorizontal(); if (drawExpand && property.objectReferenceValue != null) { isExpand = CyberEdit.Current.CurrentProp.isExpanded = EditorGUILayout.Foldout(CyberEdit.Current.CurrentProp.isExpanded, content, true); EditorGUI.indentLevel++; } else { EditorGUILayout.PrefixLabel(content); } TheEditor.DrawProperty(field, property, true, true); EditorGUILayout.EndHorizontal(); bool drawInside = drawExpand && property.objectReferenceValue != null; if (isExpand && drawInside) { EditorGUILayout.BeginVertical("helpBox"); EditorGUI.indentLevel++; var editor = Editor.CreateEditor(CyberEdit.Current.CurrentProp.objectReferenceValue); editor.OnInspectorGUI(); EditorGUILayout.EndHorizontal(); EditorGUI.indentLevel--; } if (drawInside) { EditorGUI.indentLevel--; } }
public void DrawDirectly(SerializedProperty property, CyberAttribute atribute, GUIContent content, GUIStyle style, FieldInfo field) { EditorGUILayout.BeginHorizontal(); TheEditor.DrawPrefix(content, field, style); EditorGUILayout.ObjectField(property, GUIContent.none); if (property.objectReferenceValue != null && PrefabUtility.GetPrefabAssetType(property.objectReferenceValue) != PrefabAssetType.NotAPrefab) { Debug.LogWarning("Scene refence only"); property.objectReferenceValue = null; } EditorGUILayout.EndHorizontal(); }