Esempio n. 1
0
        protected override void OnExecute()
        {
            if (useAgent == null || nameClass == null)
            {
                EndAction();
            }


            GameObject obj = null;

            if (!useAgent.value && nameRoot != null)
            {
                string root = nameRoot.value;
                obj = GameObject.Find(root);
            }
            else
            {
                obj = agent.gameObject;
            }

            Type type = nameClass.value.GetTypeFromName();

            if (obj != null)
            {
                Component component = obj.GetChildInHierarchy(type);

                if (component != null)
                {
                    ReflectionExtend.SetField(component, nameField.value, GetValue(component));
                }
            }

            EndAction();
        }
        protected override void Awake()
        {
            base.Awake();

            if (useFiller && imageFillerType != null)
            {
                filler = ReflectionExtend.CreateInstance <Filler <ImageElementInfo> >(imageFillerType);
            }
        }
Esempio n. 3
0
        private object GetValue(Component component)
        {
            if (primitiveStruct != null)
            {
                switch (primitiveStruct.value)
                {
                case PrimitiveEnum.Bool:
                    return(boolValue != null ? boolValue.value : false);

                case PrimitiveEnum.Enum:
                    int index = 0;
                    if (nameField == null || enumValue == null)
                    {
                        LogManager.LogWarning("Enum problem");
                        return(index);
                    }

                    if (ReflectionExtend.GetField(component, nameField.value, out object result))
                    {
                        index = EnumExtend.ParseEnum(enumValue.value, result.GetType());
                    }
                    else
                    {
                        LogManager.LogWarning("Enum problem");
                    }
                    return(index);

                case PrimitiveEnum.Float:
                    return(floatValue != null ? floatValue.value : 0f);

                case PrimitiveEnum.Integer:
                    return(integerValue != null ? integerValue.value : 0);

                case PrimitiveEnum.String:
                    return(stringValue != null ? stringValue.value : "");
                }
            }
            return(null);
        }