public void Copy(Transform t) { this.Name = t.name; this._Position.Import(t.position); this._LocalPosition.Import(t.localPosition); this._LocalScale.Import(t.localScale); this._Rotation.Import(t.rotation); this._LocalRotation.Import(t.localRotation); RectTransform rt = t.GetComponent <RectTransform>(); if (rt != null) { if (_RectTransform == null) { _RectTransform = new RectTransformData(this); } _RectTransform.Copy(rt); } _Children.Clear(); for (int i = 0; i < t.childCount; i++) { TransformData tdc = new TransformData(); tdc.Copy(t.GetChild(i)); Add(tdc); } }
public void Load(XmlElement e) { this.Name = e.GetAttributeValueAsString("TName", "Transform"); XmlElement p = e["Position"]; XmlElement lp = e["LocalPosition"]; XmlElement ls = e["LocalScale"]; XmlElement r = e["Rotation"]; XmlElement lr = e["LocalRotation"]; if (p != null) { _Position.Load(p); } if (lp != null) { _LocalPosition.Load(lp); } if (ls != null) { _LocalScale.Load(ls); } if (r != null) { _Rotation.Load(r); } if (lr != null) { _LocalRotation.Load(lr); } XmlElement rt = e["RectTransform"]; if (rt != null) { if (_RectTransform == null) { _RectTransform = new RectTransformData(this); } _RectTransform.Load(rt); } _Children.Clear(); XmlElement children = e["Children"]; if (children != null) { int count = children.GetAttributeValueAsInt("Count", 0); if (count > 0) { this._Children.Capacity = count; foreach (var element in children) { TransformData t = new TransformData(); t.Load(element); _Children.Add(t); } } } }