예제 #1
0
        //Element
        public void Element(string textureName, ICComRect position, RectOffset borders, RectOffset offset)
        {
            if (Event.current.type != EventType.Repaint)
            {
                return;
            }

            position.Init(this);
            Rect rect = position.GetRect();

            GUIStyle elementStyle = new GUIStyle();

            elementStyle.normal.background = ICEditorFunc.GetIcon(textureName);
            elementStyle.hover.background  = ICEditorFunc.GetIcon(textureName);

            if (borders != null)
            {
                elementStyle.border = borders;
            }
            Rect paddedRect = ToDisplay(rect);

            if (offset != null)
            {
                paddedRect = new Rect(paddedRect.x - offset.left, paddedRect.y - offset.top, paddedRect.width + offset.left + offset.right, paddedRect.height + offset.top + offset.bottom);
            }

#if UNITY_EDITOR
            elementStyle.Draw(paddedRect, UnityEditor.EditorGUIUtility.isProSkin, false, false, false);
#endif
        }
예제 #2
0
        public void InitInspector(int margin = 1)
        {
            cursor      = new Rect();
            this.margin = margin;
            field       = ICEditorFunc.GetInspectorRect();

            ICEditorFunc.CheckStyles();
        }
예제 #3
0
        public void Icon(ICComRect position, string texture,
                         IconAligment horizontalAlign = IconAligment.resize,
                         IconAligment verticalAlign   = IconAligment.resize,
                         bool tile = false)
        {
            var text = ICEditorFunc.GetIcon(texture);

            Icon(position, text, horizontalAlign, verticalAlign, tile);
        }
예제 #4
0
        //Int Input
        public void IntField(ref int value, ICComRect position,
                             string label = "", string tooltip = "Float Value", GUIStyle style = null)
        {
            Com_Init(position, label, tooltip, style, ICEditorFunc.InputTextStyle);
#if UNITY_EDITOR
            var texture  = ICEditorFunc.GetIcon("ICMagic_Slider");
            var iconRect = com_rect.SplitRectHorizontal(1, 2).Move(-texture.width, 2);
            iconRect.height = texture.height; iconRect.width = texture.width;
            GUI.DrawTexture(ToDisplay(iconRect), texture, ScaleMode.ScaleAndCrop);


            UnityEditor.EditorGUIUtility.labelWidth = com_rect.width / 2;
            value = UnityEditor.EditorGUI.IntField(com_rect, " ", value, com_style);
            UnityEditor.EditorGUIUtility.labelWidth = 0;


            Style_Init(ICEditorFunc.labelStyle);
            com_style.alignment = TextAnchor.UpperLeft;
            GUI.Label(com_rect, com_content, com_style);
#endif
        }
예제 #5
0
        //Float Input
        public void FloatField(ref float value, ICComRect position,
                               string label = "", string tooltip = "Float Value", GUIStyle style = null)
        {
            //Icon(new zSpeOneline(1, 4, false, position.height) { offset = new Rect(2,1,0,0)}
            //, "ICMagic_Slider",IconAligment.max,IconAligment.center);
            Com_Init(position, label, tooltip, style, ICEditorFunc.InputTextStyle);
#if UNITY_EDITOR
            var texture  = ICEditorFunc.GetIcon("ICMagic_Slider");
            var iconRect = com_rect.SplitRectHorizontal(1, 2).Move(-texture.width, 2);
            iconRect.height = texture.height; iconRect.width = texture.width;
            GUI.DrawTexture(ToDisplay(iconRect), texture, ScaleMode.ScaleAndCrop);


            UnityEditor.EditorGUIUtility.labelWidth = com_rect.width / 2;
            value = UnityEditor.EditorGUI.FloatField(com_rect, " ", value, com_style);
            UnityEditor.EditorGUIUtility.labelWidth = 0;


            Style_Init(ICEditorFunc.labelStyle);
            com_style.alignment = TextAnchor.UpperLeft;
            GUI.Label(com_rect, com_content, com_style);
#endif
        }
예제 #6
0
 //结束绘制,把区域反应到inpector上
 public void FinishInspector()
 {
     ICEditorFunc.SetInspectorRect(this.field);
 }