Beispiel #1
0
        public override void DrawView(Rect editorRect, Rect PercentRect, Event e, NodeGraph graph)
        {
            base.DrawView(editorRect, PercentRect, e, graph);

            // reposition to fit on screen
            float dy = window.position.height - (body.height + body.y);

            if (dy < 0)
            {
                body.y += dy;
            }
            float dx = window.position.width - (body.width + body.x);

            if (dx < 0)
            {
                body.x += dx;
            }

            ProcessEvents(e);

            // check validity of input name
            // else case should look into the "Global" list of variables
            bool     isValid = scope == Variable.VarScope.Local ? !graph.ContainsVariable(varName) : true;
            GUIStyle style   = new GUIStyle();

            style.font.material.color = isValid ? defColor : Color.red;

            varName = EditorGUILayout.TextField(varName);
            scope   = (Variable.VarScope)EditorGUILayout.EnumPopup("Scope:", scope);
            if (GUILayout.Button("Create Variable") && isValid && scope == Variable.VarScope.Local)
            {
                Promote();
            }
        }