//Must seal this method to keep sub-class share same code because we can never know which attribute drawer will be created
        //if many different type of attributes are assigned
        public sealed override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            drawOptionThisFrame = SwitchContext(property);

            //Keep draw option of last frame to draw background before reset option
            DrawBackground(position, drawOptionThisFrame, 1f);
            drawOptionThisFrame.ResetOption();

            //Modify power editing option by reading all power property attributes
            ModifyOption(property);

            //Special process of 'PowerWidget' field.
            if (fieldInfo.FieldType.IsSubclassOf(typeof(PowerWidget)))
            {
                PowerWidgetDrawingTool tool = PowerWidgetDrawingToolFactory.GetWidgetDrawingTool(property);
                if (tool != null)//Display widget when target widget drawing tool class has been found in Assembly
                {
                    drawOptionThisFrame.overrideDrawer = (r, p, l) => { tool.WidgetDrawer(r, p, fieldInfo, l); return(tool.GetWidgetHeight(p, fieldInfo)); };
                }
                else
                {
                    drawOptionThisFrame.overrideDrawer = (r, p, l) =>
                    {
                        return(PowerInspectorUtility.DrawErrorMessage(position, fieldInfo.FieldType.Name + "' has no drawing tool!", (float)(1.5 * EditorGUIUtility.singleLineHeight)));
                    };
                }
            }

            drawOptionThisFrame.heightAfterDraw = DrawPowerProperty(position, property, label, drawOptionThisFrame);
            drawOptionThisFrame.firstFrameDrawn = true;
        }
Beispiel #2
0
        public sealed override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            if (tool == null)
            {
                tool = PowerWidgetDrawingToolFactory.GetWidgetDrawingTool(property) as T;
            }

            if (tool != null)
            {
                tool.WidgetDrawer(position, property, fieldInfo, label);
            }
        }
Beispiel #3
0
        public sealed override float GetPropertyHeight(SerializedProperty property, GUIContent label)
        {
            if (tool == null)
            {
                tool = PowerWidgetDrawingToolFactory.GetWidgetDrawingTool(property) as T;
            }

            if (tool == null)
            {
                return(EditorGUIUtility.singleLineHeight);
            }

            return(tool.GetWidgetHeight(property, fieldInfo));
        }