Example #1
0
    public virtual void Empty()
    {
        List <FieldInfo> fields = GetType().GetFields().ToList().FindAll(t => t.FieldType.InheritsFrom(typeof(Component_)));

        foreach (FieldInfo field in fields)
        {
            Component_ component = (Component_)GetComponentInChildren(field.FieldType);
            component.Empty();
            field.SetValue(this, null);
        }
    }
        public static Component[] FromTSObject(dynamic[] tsArray)
        {
            if (tsArray is null)
            {
                return(null);
            }
            var list = new System.Collections.Generic.List <Component>();

            foreach (var tsItem in tsArray)
            {
                list.Add(Component_.FromTSObject(tsItem));
            }
            return(list.ToArray());
        }
        public static dynamic GetTSObject(Component[] dynArray)
        {
            if (dynArray is null)
            {
                return(null);
            }
            var list = new System.Collections.Generic.List <dynamic>();

            foreach (var dynItem in dynArray)
            {
                list.Add(Component_.GetTSObject(dynItem));
            }
            return(list.ToArray());
        }
    public virtual void Build(Owner_ owner)
    {
        this.owner = owner;
        List <FieldInfo> fields = GetType().GetFields().ToList().FindAll(t => t.FieldType.InheritsFrom(typeof(Component_)));

        foreach (FieldInfo field in fields)
        {
            Component_ component = (Component_)GetComponentInChildren(field.FieldType);
            if (component != null)
            {
                component.Build(owner);
                field.SetValue(this, component);
            }
        }
    }
Example #5
0
    public virtual void Build()
    {
        List <FieldInfo> fields = GetType().GetFields().ToList().FindAll(t => t.FieldType.InheritsFrom(typeof(Component_)));

        foreach (FieldInfo field in fields)
        {
            Component_ component = (Component_)GetComponentInChildren(field.FieldType);
            if (component != null)
            {
                component.Build(this);
                field.SetValue(this, GetComponentInChildren(field.FieldType));
            }
            else
            {
                Debug.Log($"It doesn't exist a component for field {field.Name} ({field.FieldType.Name});");
            }
        }
    }