public override Type Edit(Rect region, GUIContent label, Type element, fiGraphMetadata metadata)
        {
            Rect labelRect, buttonRect = region;

            if (string.IsNullOrEmpty(label.text) == false)
            {
                fiRectUtility.SplitHorizontalPercentage(region, .3f, 2, out labelRect, out buttonRect);
                GUI.Label(labelRect, label);
            }

            string displayed = "<no type>";

            if (element != null)
            {
                displayed = element.CSharpName();
            }

            StateObject stateObj = metadata.GetMetadata <StateObject>();

            if (GUI.Button(buttonRect, displayed))
            {
                TypeSelectionPopupWindow.CreateSelectionWindow(element, type => stateObj.Type = fiOption.Just(type));
            }

            if (stateObj.Type.HasValue)
            {
                GUI.changed = true;
                var type = stateObj.Type.Value;
                stateObj.Type = fiOption <Type> .Empty;
                return(type);
            }

            return(element);
        }
Example #2
0
        public override Type Edit(Rect region, GUIContent label, Type element, fiGraphMetadata metadata)
        {
            Rect labelRect, buttonRect = region;

            if (string.IsNullOrEmpty(label.text) == false)
            {
                fiRectUtility.SplitHorizontalPercentage(region, .3f, 2, out labelRect, out buttonRect);
                GUI.Label(labelRect, label);
            }

            string displayed = "<no type>";

            if (element != null)
            {
                displayed = element.CSharpName();
            }

            int         stateId  = EditorGUIUtility.GetControlID(FocusType.Passive);
            StateObject stateObj = (StateObject)GUIUtility.GetStateObject(typeof(StateObject), stateId);

            if (GUI.Button(buttonRect, displayed))
            {
                if (stateObj.Window == null)
                {
                    stateObj.Window = TypeSelectionPopupWindow.CreateSelectionWindow(element);
                }
            }

            if (stateObj.Window == null && ReferenceEquals(stateObj.Window, null) == false)
            {
                var window = stateObj.Window;
                stateObj.Window = null;

                if (window.SelectedType.HasValue)
                {
                    return(window.SelectedType.Value);
                }
            }

            return(element);
        }