コード例 #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);
 }