Esempio n. 1
0
        public static bool CanCreateGraphData(ScriptableObject parentObject, FieldInfo fieldInfo, out GraphData graphData)
        {
            graphData = null;
            Type fieldValueType = fieldInfo.FieldType;

            if (fieldValueType.IsGenericType && (fieldValueType.GetGenericTypeDefinition() == typeof(List <>)) &&
                typeof(ScriptableObject).IsAssignableFrom(fieldValueType.GetGenericArguments()[0]))
            {
                object[] attributes = fieldInfo.GetCustomAttributes(false);
                if (attributes == null || attributes.Length == 0)
                {
                    return(false);
                }
                GraphAttribute attribute = attributes
                                           .ToList().First((arg) => arg.GetType() == typeof(GraphAttribute)) as GraphAttribute;
                if (attribute != null)
                {
                    object fieldValue = fieldInfo.GetValue(parentObject);
                    if (fieldValue == null)
                    {
                        var newList = Activator.CreateInstance(fieldValueType);
                        fieldInfo.SetValue(parentObject, newList);
                        fieldValue = newList;
                    }
                    SerializedObject serializedObject = new SerializedObject(parentObject);
                    graphData = new GraphData();
                    graphData.ItemBaseType       = fieldValueType.GetGenericArguments()[0];
                    graphData.ItemList           = fieldValue as IList;
                    graphData.PropertyName       = fieldInfo.Name;
                    graphData.ParentObject       = parentObject;
                    graphData.SerializedItemList = serializedObject.FindProperty(fieldInfo.Name);
                    if (string.IsNullOrEmpty(graphData.PropertyName))
                    {
                        graphData.PropertyName = fieldInfo.Name;
                    }
                    graphData.StartNode = null;
                    if (!string.IsNullOrEmpty(attribute.StartNode))
                    {
                        graphData.StartNode = serializedObject.FindProperty(attribute.StartNode);
                        if (graphData.StartNode == null)
                        {
                            Debug.LogError("Cant find property with name " + attribute.StartNode + " for this graph");
                        }
                        else if (false)    //fixme through reflexion get field type
                        {
                            graphData.StartNode = null;
                            Debug.LogError("Start node type is not assignable from graph node type");
                        }
                    }
                    graphData.SetDefaultStartNodeIfNothingSelected();
                    return(true);
                }
            }


            return(false);
        }
Esempio n. 2
0
 public static Status Query(Graph graph, GraphAttribute attribute, out Perf obj)
 {
     unsafe
     {
         fixed(Perf *p_obj = &obj)
         {
             return(Query(graph, attribute, new IntPtr(p_obj), (UIntPtr)64));
         }
     }
 }
Esempio n. 3
0
 public static Status Query(Graph graph, GraphAttribute attribute, out UIntPtr obj)
 {
     unsafe
     {
         fixed(UIntPtr *p_obj = &obj)
         {
             return(Query(graph, attribute, new IntPtr(p_obj), (UIntPtr)UIntPtr.Size));
         }
     }
 }
Esempio n. 4
0
 protected void Setup(GraphAttribute attr)
 {
     data     = new List <float[]>();
     maxCount = attr.count;
 }