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 #2
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});");
            }
        }
    }