/// <summary>
        /// Constructor.
        /// <param name="serializedNode">The target serialized node.</param>
        /// <param name="path">The property path.</param>
        /// <param name="propertyType">The serialize property type.</param>
        /// <param name="target">The object that owns the serialized field.</param>
        /// <param name="fieldInfo">The field info of the property.</param>
        /// </summary>
        public SerializedNodeField(SerializedNode serializedNode, string path, NodePropertyType propertyType, object target, FieldInfo fieldInfo) : base(target, serializedNode, path, fieldInfo.FieldType, propertyType)
        {
            m_FieldInfo          = fieldInfo;
            this.hideInInspector = AttributeUtility.GetAttribute <HideInInspector>(fieldInfo, true) != null;

            // Variable?
            if (propertyType == NodePropertyType.Variable)
            {
                this.label     = StringHelper.SplitCamelCase(fieldInfo.Name);
                m_VariableInfo = AttributeUtility.GetAttribute <VariableInfoAttribute>(fieldInfo, true) ?? new VariableInfoAttribute();

                var         variable     = m_FieldInfo.GetValue(m_Target) as BehaviourMachine.Variable;
                System.Type variableType = variable != null?variable.GetType() : null;

                m_IsConcreteVariable = variableType != null && TypeUtility.GetConcreteType(variableType) == variableType;
                this.tooltip         = (fieldInfo.FieldType.Name + ": " + m_VariableInfo.tooltip).Replace("Var", string.Empty);
            }
            else
            {
                this.label = StringHelper.SplitCamelCase(fieldInfo.Name);
                var tooltip = AttributeUtility.GetAttribute <BehaviourMachine.TooltipAttribute>(fieldInfo, true);
                if (tooltip != null)
                {
                    m_Tooltip = tooltip.tooltip;
                }
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Class constructor.
 /// <param name="target">The target object (node, variable or a generic object).</param>
 /// <param name="serializedNode">The target serialized node.</param>
 /// <param name="path">The property path.</param>
 /// <param name="type">The type of the property.</param>
 /// <param name="propertyType">The property type.</param>
 /// </summary>
 public SerializedNodeProperty(object target, SerializedNode serializedNode, string path, Type type, NodePropertyType propertyType)
 {
     m_Target         = target;
     m_SerializedNode = serializedNode;
     m_Path           = path;
     m_PropertyType   = propertyType;
     m_Type           = type;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Class constructor.
        /// <param name="target">The target object (node, variable or generic object).</param>
        /// <param name="serializedNode">The target serialized node.</param>
        /// <param name="path">The property path.</param>
        /// <param name="type">The type of the property.</param>
        /// <param name="propertyType">The property type.</param>
        /// <param name="array">The array that the element belongs to.</param>
        /// <param name="index">The element index.</param>
        /// <param name="variableInfo">A variable info if the serialized property is a variable; null otherwise.</param>
        /// </summary>
        public SerializedArrayElement (object target, SerializedNode serializedNode, string path, System.Type type, NodePropertyType propertyType, Array array, int index, VariableInfoAttribute variableInfo) : base (target, serializedNode, path, type, propertyType) {
            m_Array = array;
            m_Index = index;
            m_VariableInfo = variableInfo;
            this.label = "Element " + index.ToString();

            // Its a variable type?
            if (propertyType == NodePropertyType.Variable) {
                // Update label
                this.tooltip = (type.Name + ": " + this.tooltip).Replace("Var", string.Empty);

                // Set concreteVariable
                var variable = m_Array.GetValue(m_Index) as BehaviourMachine.Variable;
                System.Type variableType = variable != null ? variable.GetType() : null;
                m_IsConcreteVariable = variableType != null && TypeUtility.GetConcreteType(variableType) == variableType;
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Constructor.
        /// <param name="serializedNode">The target serialized node.</param>
        /// <param name="path">The property path.</param>
        /// <param name="propertyType">The serialize property type.</param>
        /// <param name="target">The object that owns the serialized field.</param>
        /// <param name="fieldInfo">The field info of the property.</param>
        /// </summary>
        public SerializedNodeField (SerializedNode serializedNode, string path, NodePropertyType propertyType, object target, FieldInfo fieldInfo) : base (target, serializedNode, path, fieldInfo.FieldType, propertyType) {
            m_FieldInfo = fieldInfo;
            this.hideInInspector = AttributeUtility.GetAttribute<HideInInspector>(fieldInfo, true) != null;

            // Variable?
            if (propertyType == NodePropertyType.Variable) {
                this.label = StringHelper.SplitCamelCase(fieldInfo.Name);
                m_VariableInfo = AttributeUtility.GetAttribute<VariableInfoAttribute>(fieldInfo, true) ?? new VariableInfoAttribute();

                var variable = m_FieldInfo.GetValue(m_Target) as BehaviourMachine.Variable;
                System.Type variableType = variable != null ? variable.GetType() : null; 

                m_IsConcreteVariable = variableType != null && TypeUtility.GetConcreteType(variableType) == variableType;
                this.tooltip = (fieldInfo.FieldType.Name + ": " + m_VariableInfo.tooltip).Replace("Var", string.Empty);
            }
            else {
                this.label = StringHelper.SplitCamelCase(fieldInfo.Name);
                var tooltip = AttributeUtility.GetAttribute<BehaviourMachine.TooltipAttribute>(fieldInfo, true);
                if (tooltip != null)
                    m_Tooltip = tooltip.tooltip;
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Class constructor.
 /// <param name="target">The target object (node, variable or a generic object).</param>
 /// <param name="serializedNode">The target serialized node.</param>
 /// <param name="path">The property path.</param>
 /// <param name="type">The type of the property.</param>
 /// <param name="propertyType">The property type.</param>
 /// </summary>
 public SerializedNodeProperty (object target, SerializedNode serializedNode, string path, Type type, NodePropertyType propertyType) {
     m_Target = target;
     m_SerializedNode = serializedNode;
     m_Path = path;
     m_PropertyType = propertyType;
     m_Type = type;
 }
        /// <summary>
        /// Class constructor.
        /// <param name="target">The target object (node, variable or generic object).</param>
        /// <param name="serializedNode">The target serialized node.</param>
        /// <param name="path">The property path.</param>
        /// <param name="type">The type of the property.</param>
        /// <param name="propertyType">The property type.</param>
        /// <param name="array">The array that the element belongs to.</param>
        /// <param name="index">The element index.</param>
        /// <param name="variableInfo">A variable info if the serialized property is a variable; null otherwise.</param>
        /// </summary>
        public SerializedArrayElement(object target, SerializedNode serializedNode, string path, System.Type type, NodePropertyType propertyType, Array array, int index, VariableInfoAttribute variableInfo) : base(target, serializedNode, path, type, propertyType)
        {
            m_Array        = array;
            m_Index        = index;
            m_VariableInfo = variableInfo;
            this.label     = "Element " + index.ToString();

            // Its a variable type?
            if (propertyType == NodePropertyType.Variable)
            {
                // Update label
                this.tooltip = (type.Name + ": " + this.tooltip).Replace("Var", string.Empty);

                // Set concreteVariable
                var         variable     = m_Array.GetValue(m_Index) as BehaviourMachine.Variable;
                System.Type variableType = variable != null?variable.GetType() : null;

                m_IsConcreteVariable = variableType != null && TypeUtility.GetConcreteType(variableType) == variableType;
            }
        }