/// <summary> /// 提交状态 /// </summary> protected void SetProps() { if (this.Props.IsChanged()) { UFlux.SetComponentValue(this.Transform, this.Props); } }
/// <summary> /// 设置数据,全局只能通过这个接口设置数据 /// </summary> /// <param name="props"></param> public void SetProps(T props) { if (props.IsChanged()) { this.Props = props; UFlux.SetComponentValue(this.Transform, props); } }
/// <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); }
/// <summary> /// 提交状态 /// </summary> protected void CommitProps(bool isAllPrpertyChanged = false) { if (isAllPrpertyChanged) { this.Props.SetAllPropertyChanged(); } if (this.Props.IsChanged()) { UFlux.SetComponentValue(this.Transform, this.Props); } }
/// <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); } } }