예제 #1
0
 /// <summary>
 /// 删除
 /// </summary>
 virtual public void Destroy()
 {
     UFlux.Destroy(this.Transform.gameObject);
     this.Transform = null;
     UFlux.Unload(this.resPath);
     IsDestroy = true;
 }
예제 #2
0
 /// <summary>
 /// 构造
 /// </summary>
 /// <param name="trans"></param>
 public ATComponent(Transform trans)
 {
     this.Transform = trans;
     //创建State
     this.Props = new T();
     UFlux.InitComponent(this);
 }
예제 #3
0
 /// <summary>
 /// 构造
 /// </summary>
 /// <param name="trans"></param>
 public Component(Transform trans)
 {
     this.Transform = trans;
     //创建State
     this.Props = new T();
     UFlux.SetTransformPath(this);
 }
예제 #4
0
 /// <summary>
 /// 提交状态
 /// </summary>
 protected void SetProps()
 {
     if (this.Props.IsChanged())
     {
         UFlux.SetComponentValue(this.Transform, this.Props);
     }
 }
예제 #5
0
 /// <summary>
 /// 设置数据,全局只能通过这个接口设置数据
 /// </summary>
 /// <param name="props"></param>
 public void SetProps(T props)
 {
     if (props.IsChanged())
     {
         this.Props = props;
         UFlux.SetComponentValue(this.Transform, props);
     }
 }
예제 #6
0
        /// <summary>
        /// 设置属性
        /// </summary>
        /// <param name="transform"></param>
        /// <param name="value"></param>
        private void SetChildValue(Transform transform, object value)
        {
            var props = value as PropsBase;

            if (props == null)
            {
                Debug.LogError("类型不是props:" + value.GetType().Name);
                return;
            }

            UFlux.SetComponentValue(transform, props);
        }
예제 #7
0
        /// <summary>
        /// 提交状态
        /// </summary>
        protected void CommitProps(bool isAllPrpertyChanged = false)
        {
            if (isAllPrpertyChanged)
            {
                this.Props.SetAllPropertyChanged();
            }

            if (this.Props.IsChanged())
            {
                UFlux.SetComponentValue(this.Transform, this.Props);
            }
        }
예제 #8
0
        /// <summary>
        /// 设置图片
        /// </summary>
        /// <param name="value"></param>
        private void SetProp_Sprite(UIBehaviour uiBehaviour, object value)
        {
            var img = uiBehaviour as Image;

            if (value is string)
            {
                img.sprite = UFlux.Load <Sprite>((string)value);
            }
            else if (value is Sprite)
            {
                img.sprite = (Sprite)value;
            }
        }
예제 #9
0
        /// <summary>
        /// 加载接口
        /// </summary>
        public void Load()
        {
            if (resPath == null)
            {
                return;
            }

            var o = UFlux.Load <GameObject>(resPath);

            this.Transform = GameObject.Instantiate(o).transform;
            this.IsLoad    = true;
            UFlux.InitComponent(this);
            //初始化
            this.Init();
        }
예제 #10
0
        /// <summary>
        /// 绑定多个节点
        /// </summary>
        /// <param name="transform"></param>
        /// <param name="value">Value必须为集合类型</param>
        private void BindChildren(Transform transform, object value)
        {
            IPropsList propsList = value as IPropsList;

            if (!propsList.IsChanged)
            {
                return;
            }

            //绑定子节点
            propsList.Foreach((idx, props) =>
            {
                if (idx < transform.childCount)
                {
                    UFlux.SetComponentProps(transform.GetChild(idx), props);
                }
            });
        }
예제 #11
0
        /// <summary>
        /// 将List中的数据设置给子节点
        /// </summary>
        /// <param name="transform"></param>
        /// <param name="value">Value必须为集合类型</param>
        private void ForeahSetChildValueFormArray(Transform transform, object value)
        {
            ICollection Collection = value as ICollection;

            if (Collection == null)
            {
                return;
            }
            int count = 0;

            foreach (var item in Collection)
            {
                var props = item as PropsBase;
                if (props != null)
                {
                    transform.gameObject.SetActive(true);
                    var child = transform.GetChild(count);
                    if (child)
                    {
                        UFlux.SetComponentValue(child, props);
                    }
                }
                else
                {
                    BDebug.LogError("list数据错误:" + value.GetType());
                    return;
                }

                count++;
            }

            for (int i = 0; i < transform.childCount; i++)
            {
                if (i > count - 1)
                {
                    transform.GetChild(i).gameObject.SetActive(false);
                }
                else
                {
                    transform.GetChild(i).gameObject.SetActive(true);
                }
            }
        }
예제 #12
0
 /// <summary>
 /// 异步加载
 /// </summary>
 /// <param name="callback"></param>
 public void AsyncLoad(Action callback = null)
 {
     if (resPath == null)
     {
         return;
     }
     UFlux.AsyncLoad <GameObject>(resPath, obj =>
     {
         this.Transform = GameObject.Instantiate(obj).transform;
         this.IsLoad    = true;
         UFlux.InitComponent(this);
         //初始化
         Init();
         if (callback != null)
         {
             callback();
         }
     });
 }
예제 #13
0
 /// <summary>
 /// 提交状态
 /// </summary>
 protected void CommitProps()
 {
     UFlux.SetComponentProps(this.Transform, this.Props);
 }