public void DrawDirectly(SerializedProperty property, CyberAttrribute attribute, GUIContent content, GUIStyle style, FieldInfo field) { ArrayAsFieldAttribute atr = attribute as ArrayAsFieldAttribute; property.arraySize = atr?.Names.Length ?? 1; TheEditor.DrawArray(field, GUIContent.none, property, false, false, false, atr.Names ?? new string[] { "_NoName_" }); }
public void DrawBefore(CyberAttribute atr) { TheEditor.PrepareToRefuseGui(this.GetType()); Color color = ((BackgroundAttribute)atr).CurColor; GUI.backgroundColor = (Color)color; }
public void DrawBefore(CyberAttrribute 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; }
public override void OnInspectorGUI() { base.OnInspectorGUI(); Type type = StaticMethodDrawer.GetCanDrawTypes().FirstOrDefault(item => item.FullName == methodP.FindPropertyRelative("_TypeName").stringValue); if (type == null) { return; } MethodInfo methodInf = type.GetMethod(methodP.FindPropertyRelative("_MethodName").stringValue); if (methodInf == null || methodInf.GetParameters().Length == 0) { return; } else { ParameterInfo param = methodInf.GetParameters()[0]; Type paramType = param.ParameterType; EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel(new GUIContent(param.Name)); (argsP.stringValue, referenceP.objectReferenceValue) = TheEditor.GeneralField(argsP.stringValue, referenceP.objectReferenceValue, paramType); EditorGUILayout.EndHorizontal(); } serializedObject.ApplyModifiedProperties(); }
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 DrawDirectly(SerializedProperty property, CyberAttrribute atribute, GUIContent content, GUIStyle style, FieldInfo field) { EditorGUILayout.BeginHorizontal(); TheEditor.DrawPrefix(content, field, style); property.stringValue = EditorGUILayout.TagField(property.stringValue); EditorGUILayout.EndHorizontal(); }
public void DrawDirectly(SerializedProperty property, CyberAttrribute atrribute, GUIContent content, GUIStyle style, FieldInfo field) { EditorGUILayout.BeginHorizontal(); TheEditor.DrawPrefix(content, field, style); property.intValue = EditorGUILayout.MaskField(GUIContent.none, property.intValue, property.enumNames); EditorGUILayout.EndHorizontal(); }
public void DrawGroup(IGrouping <string, MemberInfo> groups, string[] usedGroup) { TheEditor.DrawBoxHeader(new GUIContent(groups.Key)); CyberEdit.Current.DrawBasicGroup(groups, BackgroundMode.HelpBox, usedGroup, drawPrefix: false); TheEditor.DrawAfteGroup <CustomBackgrounGroupDrawer>(groups.Key); }
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) { 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 DrawDirectly(SerializedProperty property, CyberAttrribute 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 DrawBefore(CyberAttribute atr) { var attribute = atr as HelpBoxAttribute; TheEditor.HelpBox(attribute.Text, attribute.MessageType, new GUIStyle() { fixedHeight = attribute.Height, fixedWidth = attribute.Width }); }
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(); }
private void Draw(GUIContent content, FieldInfo field) { TheEditor.PrepareToRefuseGui(this); GUI.enabled = false; EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel(content); EditorGUILayout.TextField(field.GetValue(CyberEdit.Current.Target).ToString()); EditorGUILayout.EndHorizontal(); TheEditor.RefuseGui(this); }
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 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, CyberAttrribute 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 DrawGroup(IGrouping <string, MemberInfo> groups) { BackgroundMode mode = BackgroundMode.Box; if (TheEditor.DrawBeforeGroup <CustomBackgrounGroupDrawer>(groups.Key) != null) { mode = BackgroundMode.None; } CyberEdit.Current.DrawBasicGroup(groups, mode); TheEditor.DrawAfteGroup <CustomBackgrounGroupDrawer>(groups.Key); }
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 DrawBefore(CyberAttribute atr) { HelpBoxWhenAttribute helpBoxWhen = atr as HelpBoxWhenAttribute; if (TheEditor.CheckEquals(CyberEdit.Current.GetPropByName(helpBoxWhen.SerializedProperty), helpBoxWhen.Value, helpBoxWhen.Equaler)) { TheEditor.HelpBox(helpBoxWhen.Text, helpBoxWhen.MessageType , new GUIStyle() { fixedHeight = helpBoxWhen.Height, fixedWidth = helpBoxWhen.Width }); } }
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(); }
public void DrawMethod(MethodInfo method, CyberAttrribute cyberAttrribute) { object locker = new object(); if (method == null) { throw new ArgumentNullException(nameof(method)); } if (cyberAttrribute == null) { throw new ArgumentNullException(nameof(method)); } ButtonAttribute button = cyberAttrribute as ButtonAttribute; TheEditor.PrepareToRefuseGui(locker); if (button.CustomColor) { GUI.color = button.CurColor; } if ((Application.isPlaying == false && button.WhenCanPress == UnityEventCallState.RuntimeOnly) || (button.WhenCanPress == UnityEventCallState.Off)) { GUI.enabled = false; } string text = button.Text; if (string.IsNullOrEmpty(text)) { text = method.Name; } if (GUILayout.Button(text, GUILayout.Height(button.Height))) { if (method.IsStatic == false) { method.Invoke(CyberEdit.Current.Target, null); } else { method.Invoke(null, null); } } TheEditor.RefuseGui(locker); }
public void DrawBefore(CyberAttrribute cyberAttribute) { bool before; before = GUI.enabled; GUI.enabled = true; StartVerticalAttribute attribute = cyberAttribute as StartVerticalAttribute; TheEditor.BeginVertical(attribute.BackgroundMode); GUI.enabled = before; }
public void DrawDirectly(SerializedProperty property, CyberAttrribute atrribute, GUIContent content, GUIStyle style, FieldInfo field) { EditorGUILayout.BeginHorizontal(); TheEditor.DrawPrefix(content, field, style); foreach (var item in Enum.GetValues(CyberEdit.Current.CurrentField.FieldType)) { int iVal = Convert.ToInt32(item); if (GUILayout.Toolbar(iVal == property.intValue ? 0 : 1, new GUIContent[] { new GUIContent(item.ToString()) }) == 0) { property.intValue = iVal; } } EditorGUILayout.EndHorizontal(); }
public void DrawDirectly(SerializedProperty property, CyberAttribute attribute, GUIContent content, GUIStyle style, FieldInfo field) { EditorGUILayout.BeginHorizontal(); TheEditor.DrawPrefix(content, field, style); EnumFlagsAttribute attr = attribute as EnumFlagsAttribute; if (property.intValue < 0) { property.intValue = 0; } void DrawCheckBox(GUIStyle checkStyle) { foreach (var item in Enum.GetValues(CyberEdit.Current.CurrentField.FieldType)) { int val = Convert.ToInt32(item); if (val == 0) { continue; } bool has = (property.intValue | val) == property.intValue; bool toogleRes = GUILayout.Toggle(has, new GUIContent(item.ToString()), checkStyle); if (toogleRes == false && has == true) { property.intValue ^= val; } else if (toogleRes == true && has == false) { property.intValue |= val; } } } switch (attr.EnumFlagOption) { case EnumMode.Classic: property.intValue = EditorGUILayout.MaskField(GUIContent.none, property.intValue, property.enumNames); break; default: DrawCheckBox(attr.EnumFlagOption.GetStyle()); break; } EditorGUILayout.EndHorizontal(); }
public void DrawDirectly(SerializedProperty property, CyberAttribute attribute, GUIContent content, GUIStyle style, FieldInfo field) { DropdownByAttribute attr = attribute as DropdownByAttribute; TheEditor.DrawPropertyAsDropdownWithFixValue( property, field, content, style, GetValue(attr.ValueGetter).OfType <object>().ToArray(), (i) => property.SetValue(i), property.GetJustValue(), (item, index) => item?.ToString() ?? "null", true, false); }
public void DrawDirectly(SerializedProperty property, CyberAttrribute cyberAttribute, GUIContent content, GUIStyle style, FieldInfo field) { MinMaxSliderAttribute atr = cyberAttribute as MinMaxSliderAttribute; EditorGUILayout.BeginHorizontal(); TheEditor.DrawPrefix(content, field, style); float min, max; SerializedProperty pVect = null; if (property.propertyType == SerializedPropertyType.Generic) { pVect = property.FindPropertyRelative("val"); min = pVect.vector2Value.x; max = pVect.vector2Value.y; } else if (property.propertyType == SerializedPropertyType.Vector2) { min = property.vector2Value.x; max = property.vector2Value.y; } else { min = property.vector2IntValue.x; max = property.vector2IntValue.y; } min = EditorGUILayout.FloatField(min, GUILayout.MinWidth(15), GUILayout.MaxWidth(70)); EditorGUILayout.MinMaxSlider(ref min, ref max, atr.Min, atr.Max); max = EditorGUILayout.FloatField(max, GUILayout.MinWidth(15), GUILayout.MaxWidth(70)); if (property.propertyType == SerializedPropertyType.Vector2) { property.vector2Value = new Vector2(min, max); } else if (property.propertyType == SerializedPropertyType.Vector2Int) { property.vector2IntValue = new Vector2Int((int)min, (int)max); } else if (property.propertyType == SerializedPropertyType.Generic) { pVect.vector2Value = new Vector2(min, max); } EditorGUILayout.EndHorizontal(); }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { var elements = property.FindPropertyRelative("elements"); TheEditor.DrawArray (property.serializedObject.targetObject.GetType().GetField(property.name, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance), label, elements); var asValue = elements.ToEnumerable().Select(item => item.GetJustValue()); if (asValue.Distinct().Count() != asValue.Count()) { TheEditor.HelpBox("Two identical key", MessageType.Warning, new GUIStyle() { fixedHeight = 30 }); } }
public void DrawBefore(CyberAttribute atr) { if (CyberEdit.Current.CurrentProp == null) { return; } if (CyberEdit.Current.CurrentProp.objectReferenceValue == null) { TheEditor.HelpBox("This value is requier", MessageType.Warning, new GUIStyle() { fixedHeight = 30 }); if (Application.isPlaying) { throw new CyberAttributeException(typeof(RequiresAnyAttribute), $"Assign {CyberEdit.Current.CurrentProp.name} before you will start play"); } } }
public void DrawDirectly(SerializedProperty property, CyberAttribute attribute, GUIContent content, GUIStyle style, FieldInfo field) { ResourcePrefabAttribute attr = attribute as ResourcePrefabAttribute; UnityEngine.Object[] elements; IEnumerable <UnityEngine.Object> collection = Resources.LoadAll($"{attr.Folder}"); if (field.FieldType.Is(typeof(Component))) { collection = from element in collection select(element as GameObject).GetComponent(field.FieldType); } elements = (from item in collection where item != null select item).ToArray(); TheEditor.DrawPropertyAsDropdownWithFixValue(property, CyberEdit.Current.CurrentField, content, style, elements, (i) => property.objectReferenceValue = i as UnityEngine.Object, property.GetJustValue(), (element, index) => ((UnityEngine.Object)element).name, true); }