Beispiel #1
0
 public void SetValue(object value)
 {
     this.value = FlowNode.ChangeType(value, valueType);
 }
Beispiel #2
0
 public ValuePort(FlowNode node, string name, Type type)
     : this(node, name, type, null)
 {
 }
 public void ChangeActive(FlowNode oldNode, FlowNode newNode)
 {
 }
 public void AddActive(FlowNode node)
 {
 }
 public FlowNodeData AddNode(FlowNode node)
 {
     return(AddNode(node, Vector2.zero));
 }
Beispiel #6
0
        public FlowNode CreateFlowNode()
        {
            FlowNode node = null;

            if (isNodeAsset)
            {
                if (nodeAsset)
                {
                    node = nodeAsset.CreateFlowNode();
                }
            }
            else
            {
                Type type = null;

                if (string.IsNullOrEmpty(typeName))
                {
                    Debug.LogError("type name null");
                    return(null);
                }

                type = FindType(typeName);
                if (type == null)
                {
                    HasDeserializeError = true;
                    Debug.LogError("Not Found Type:" + typeName);
                    return(null);
                }

                try
                {
                    node = Activator.CreateInstance(type) as FlowNode;

                    var props = this.properties;
                    //node.ID = id;
                    if (props != null)
                    {
                        var fields = GetSerializeFields(type);

                        if (fields != null)
                        {
                            object value;
                            foreach (var propData in props)
                            {
                                var field = fields.Where(o => o.Name == propData.field).FirstOrDefault();

                                if (field == null)
                                {
                                    continue;
                                }
                                value = propData.value.Value;
                                if (propData.value.Value == null)
                                {
                                    value = null;
                                }
                                field.SetValue(node, value);
                            }
                        }
                    }

                    node.OnAfterDeserialize();

                    if (node.HasDeserializeError)
                    {
                        HasDeserializeError = true;
                    }
                }
                catch (Exception ex)
                {
                    HasDeserializeError = true;
                    Debug.LogException(ex);
                }
            }

            return(node);
        }