public void DrawBefore(CyberAttrribute atr)
        {
            TheEditor.PrepareToRefuseGui(this.GetType());
            Color color = ((BackgroundAttribute)atr).CurColor;

            GUI.backgroundColor = (Color)color;
        }
Example #2
0
        public void DrawBefore(CyberAttrribute cyberAttribute)
        {
            SeparatorAttribute attribute = cyberAttribute as SeparatorAttribute;

            EditorGUILayout.BeginHorizontal();

            var   content = new GUIContent(attribute.Label);
            float width   = EditorStyles.label.CalcSize(content).x;

            if (string.IsNullOrEmpty(attribute.Label) == false)
            {
                DrawMinBox();
                EditorGUILayout.LabelField(attribute.Label, attribute.GUIStyle, GUILayout.Width(width));
                DrawMinBox();
            }
            else
            {
                DrawMinBox();
            }
            EditorGUILayout.EndHorizontal();

            void DrawMinBox()
            {
                EditorGUILayout.BeginVertical();
                GUILayout.Box(GUIContent.none, "GroupBox", GUILayout.Height(1), GUILayout.MaxWidth(int.MaxValue));
                EditorGUILayout.EndVertical();
            }
        }
        public void ChangeGuiStyle(CyberAttrribute attrribute, ref GUIStyle style, ref string customName)
        {
            var fatr = (attrribute as CustomGuiAttribute);

            style      = fatr.GUIStyle;
            customName = fatr.Label ?? customName;
        }
        public void DrawEnd(CyberAttrribute atr)
        {
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.EndHorizontal();

            CyberEdit.Current.PopHorizontalStack();
        }
        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;
        }
Example #6
0
        public void DrawAfter(CyberAttrribute 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);
            }
        }
Example #7
0
 public void DrawDirectly(SerializedProperty property, CyberAttrribute 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();
 }
Example #8
0
 public void DrawAfter(CyberAttrribute atr)
 {
     if ((atr as IndentLvAttribute).OneShoot)
     {
         EditorGUI.indentLevel -= (atr as IndentLvAttribute).Quantity;
     }
 }
Example #9
0
        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_" });
        }
Example #10
0
 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 DrawAfter(CyberAttrribute cyberAttribute)
 {
     if (GUILayout.Button("↺", GUILayout.Width(20)))
     {
         Restore(CyberEdit.Current.CurrentProp, CyberEdit.Current.CurrentField, cyberAttribute);
     }
     EditorGUILayout.EndHorizontal();
 }
Example #12
0
        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 DrawBefore(CyberAttrribute cyberAttrribute)
        {
            OnlyRuntimeAttribute atr = cyberAttrribute as OnlyRuntimeAttribute;

            if (Application.isPlaying == false)
            {
                GUI.enabled = false;
            }
        }
 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);
 }
Example #15
0
        public void DrawDirectly(SerializedProperty property, CyberAttrribute 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 DrawBefore(CyberAttrribute 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 DrawAfterSize(SerializedProperty prop, CyberAttrribute cyberAttrribute)
        {
            var attribute = cyberAttrribute as ConstSizeAttribute;

            if (prop.arraySize != attribute.Size)
            {
                prop.arraySize = attribute.Size;
            }
            GUI.enabled = befor;
        }
        public void DrawDirectly(SerializedProperty property, CyberAttrribute 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 DrawBefore(CyberAttrribute atr)
        {
            var attribute = atr as HelpBoxAttribute;

            TheEditor.HelpBox(attribute.Text, attribute.MessageType,
                              new GUIStyle()
            {
                fixedHeight = attribute.Height, fixedWidth = attribute.Width
            });
        }
 public void DrawAfter(CyberAttrribute cyberAttributer)
 {
     if (CyberEdit.Current.CurrentInspectedMember != null)
     {
         ButtonAttribute attribute = cyberAttributer as ButtonAttribute;
         var             type      = CyberEdit.Current.GetFinalTargetType();
         DrawMethod(type.GetMethod(attribute.Method, BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Static), attribute);
     }
     EditorGUILayout.EndHorizontal();
 }
Example #21
0
        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 DrawDirectly(SerializedProperty property, CyberAttrribute 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();
 }
Example #23
0
        public void DrawAfter(CyberAttrribute cyberAttribute)
        {
            ResetButtonAttribute attribute = cyberAttribute as ResetButtonAttribute;

            if (GUILayout.Button("↺", GUILayout.Width(20)))
            {
                CyberEdit.Current.CurrentProp.SetValue(attribute.Value);
            }

            EditorGUILayout.EndHorizontal();
        }
        public void DrawAfter(CyberAttrribute cyberAttribute)
        {
            MaxSizeAttribute attribute = cyberAttribute as MaxSizeAttribute;

            if (CyberEdit.Current.CurrentProp == null)
            {
                return;
            }
            if (CyberEdit.Current.CurrentProp.arraySize > attribute.Max)
            {
                CyberEdit.Current.CurrentProp.arraySize = (int)attribute.Max;
            }
        }
        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);
        }
Example #26
0
        public bool IsGoodValue(CyberAttrribute attrribute, object val)
        {
            IllegalValuesAttribute illegalValueAttribute = attrribute as IllegalValuesAttribute;

            foreach (var item in illegalValueAttribute.Values)
            {
                if (item.Equals(val))
                {
                    Debug.LogWarning($"Illegal Value {{{item}}}");
                    return(false);
                }
            }
            return(true);
        }
        public bool CanDraw(CyberAttrribute cyberAttrribute)
        {
            RequireToolbarAttribute attribute = cyberAttrribute as RequireToolbarAttribute;
            int select = CyberEdit.Current.GetToolbarSelect(attribute.ToolbarId);

            if (attribute.HasOnlyStringValue == false)
            {
                return(select == attribute.Index);
            }
            else
            {
                return(select == CyberEdit.Current.ToolbarElements[attribute.ToolbarId].GetIndex(attribute.IndexAsName));
            }
        }
 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();
 }
        private void Restore(SerializedProperty property, FieldInfo field, CyberAttrribute cyberAttribute)
        {
            AutoLoadAttribute attribute = cyberAttribute as AutoLoadAttribute;
            var component = (CyberEdit.Current.Target as Component);

            if (attribute.WithChildren == false)
            {
                property.objectReferenceValue = component.gameObject.GetComponent(field.FieldType);
            }
            else
            {
                property.objectReferenceValue = component.gameObject.GetComponentInChildren(field.FieldType);
            }
        }
Example #30
0
        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;
        }