コード例 #1
0
        protected Rect makeNodeRect(MoronIONode node)
        {
            IEnumerable <FieldInfo> attributes;
            float width, height;

            width  = 180;
            height = 25;

            attributes = node.getFieldsWithAttribute <MoronManualWriteAttribute>();
            if (attributes.Count() > 0)
            {
                height += attributes.Count() * 20f;
            }

            attributes = node.getFieldsWithAttribute <MoronStateWriteAttribute>();
            if (attributes.Count() > 0)
            {
                height += (attributes.Count() + 1) * 20f;
            }

            attributes = node.getFieldsWithAttribute <MoronStateReadAttribute>();
            if (attributes.Count() > 0)
            {
                height += (attributes.Count() + 1) * 20f;
            }

            return(new Rect(node.position.x - width / 2, node.position.y - height / 2, width, height));
        }
コード例 #2
0
        protected void drawJoistList <T>(MoronIONode node, Rect nodeRect, ref Rect current, ref Rect label, Func <String, String> getCall, Action <String, String> setCall, String labelText) where T : Attribute
        {
            IEnumerable <FieldInfo> fields;

            String[] matchingArray;
            float    labelWidth;
            int      index, original, adj;

            fields = node.getFieldsWithAttribute <T>();
            if (fields.Count() <= 0)
            {
                return;
            }

            label.y     = current.y;
            label.width = GUI.skin.label.CalcSize(new GUIContent(labelText)).x;
            current.y  += 20;

            EditorGUI.LabelField(label, labelText);

            // reads
            foreach (FieldInfo field in fields)
            {
                label.y     = current.y;
                label.width = GUI.skin.label.CalcSize(new GUIContent(field.Name)).x;

                labelWidth    = label.width + 5;
                current.x     = nodeRect.x + labelWidth;
                current.width = nodeRect.width - labelWidth - 2;

                EditorGUI.LabelField(label, field.Name);

                matchingArray = graph.statemapDefinition.getFieldsForType(field.FieldType).Select(k => k.name).ToArray();
                original      = Array.IndexOf(matchingArray, getCall(field.Name));

                adj = original;
                if (original < 0)
                {
                    adj = 0;
                }

                index = EditorGUI.Popup(current, adj, matchingArray);

                if (index >= 0 && index < matchingArray.Length && index != original)
                {
                    setCall(field.Name, matchingArray[index]);
                    EditorUtility.SetDirty(graph);
                }

                current.y += 20;
            }
        }
コード例 #3
0
        protected void drawFields(MoronIONode node, Rect nodeRect)
        {
            System.Object value, original;
            Rect          current, label;
            float         labelWidth;

            current = new Rect(nodeRect.x, nodeRect.y + 20, nodeRect.width, 20);
            label   = current;

            GUI.color           = NODE_BACKGROUND_COLOR;
            GUI.contentColor    = NODE_BACKGROUND_COLOR;
            GUI.backgroundColor = NODE_BACKGROUND_COLOR;

            // manual
            foreach (FieldInfo field in node.getFieldsWithAttribute <MoronManualWriteAttribute>())
            {
                label.y     = current.y;
                label.width = GUI.skin.label.CalcSize(new GUIContent(field.Name)).x;

                labelWidth    = label.width + 5;
                current.x     = nodeRect.x + labelWidth;
                current.width = nodeRect.width - labelWidth - 2;

                original = node.getManualJoist(field.Name);
                value    = EditorPropertyHelper.propertyField(current, label, field.Name, field.FieldType, original);
                node.setManualJoist(field.Name, value);

                if (value != original)
                {
                    EditorUtility.SetDirty(graph);
                }

                current.y += 20;
            }

            drawJoistList <MoronStateReadAttribute>(node, nodeRect, ref current, ref label, node.getReadJoist, node.setReadJoist, "    Reads:");
            drawJoistList <MoronStateWriteAttribute>(node, nodeRect, ref current, ref label, node.getWriteJoist, node.setWriteJoist, "    Writes:");
        }