Esempio n. 1
0
        private void HookUpInput(GraphInput graphInput)
        {
            LogicNode node    = _inputNodes.Find(n => n.NodeGuid == graphInput.NodeGuid);
            var       methods = node.GetType().GetMethods(BindingFlags.Public |
                                                          BindingFlags.NonPublic |
                                                          BindingFlags.Instance);

            foreach (MethodInfo method in methods)
            {
                var attrs = method.GetCustomAttributes(typeof(InputAttribute), false) as InputAttribute[];
                if (attrs.Length > 0)
                {
                    if (method.Name == graphInput.MemberName)
                    {
                        graphInput.InputType = attrs[0].InputType();
                        attrs[0].HookUpMethodInvoke(node, method, graphInput);
                    }

                    if (attrs.Length > 1)
                    {
                        Debug.LogWarning(method.Name + " on  " + node + "has multiple input attributes.");
                    }
                }
            }
        }
Esempio n. 2
0
 private void LoadInputs(List <GraphInput> inputs)
 {
     foreach (var node in _inputNodes)
     {
         var methods = node.GetType().GetMethods(BindingFlags.Public |
                                                 BindingFlags.NonPublic |
                                                 BindingFlags.Instance);
         foreach (MethodInfo method in methods)
         {
             var attrs = method.GetCustomAttributes(typeof(InputAttribute), false) as InputAttribute[];
             if (attrs.Length > 0)
             {
                 GraphInput input = new GraphInput
                 {
                     MemberName  = method.Name,
                     NodeGuid    = node.NodeGuid,
                     DisplayName = node.DisplayName + " " + method.Name,
                     InputType   = attrs[0].InputType()
                 };
                 inputs.Add(input);
                 if (attrs.Length > 1)
                 {
                     Debug.LogWarning(method.Name + " on  " + node + "has multiple input attributes.");
                 }
             }
         }
     }
 }
Esempio n. 3
0
 private void OnValidate(LogicNode node, MethodInfo method, GraphInput graphInput)
 {
     if (!Mathf.Approximately(graphInput.FloatValueX, _priorFloatValueX))
     {
         method.Invoke(node, new object[] { graphInput.FloatValueX });
         _priorFloatValueX = graphInput.FloatValueX;
     }
 }
Esempio n. 4
0
 private void OnValidate(LogicNode node, MethodInfo method, GraphInput graphInput)
 {
     if (!Mathf.Approximately(graphInput.FloatValueX, _priorFloatValueX) ||
         !Mathf.Approximately(graphInput.FloatValueY, _priorFloatValueY) ||
         !Mathf.Approximately(graphInput.FloatValueZ, _priorFloatValueZ))
     {
         method.Invoke(node, new object[] { new Vector3(graphInput.FloatValueX, graphInput.FloatValueY, graphInput.FloatValueZ) });
         _priorFloatValueX = graphInput.FloatValueX;
         _priorFloatValueY = graphInput.FloatValueY;
         _priorFloatValueZ = graphInput.FloatValueZ;
     }
 }
Esempio n. 5
0
 public override void HookUpMethodInvoke(LogicNode node, MethodInfo method, GraphInput graphInput)
 {
     graphInput.Validate = () => OnValidate(node, method, graphInput);
 }
Esempio n. 6
0
 /// <summary>
 /// Gets called from OnEnable or OnValidate of LogicGraphInstance, needs to hook up the InputAttribute
 /// so that it pipes the data from the serialized GraphInput object through the nodechain.
 /// </summary>
 /// <param name="node">The node to hooke up.</param>
 /// <param name="method">The method which the InputAttribute is.</param>
 /// <param name="graphInput">The GraphiInput holding the serialized data.</param>
 public abstract void HookUpMethodInvoke(LogicNode node, MethodInfo method, GraphInput graphInput);