public void Paste(Transform t) { t.localScale = _LocalScale.ToVector3(); if (t.parent == null) { t.position = _Position.ToVector3(); t.rotation = _Rotation.ToQuaternion(); } else { t.localPosition = _LocalPosition.ToVector3(); t.localRotation = _LocalRotation.ToQuaternion(); } RectTransform rt = t.GetComponent <RectTransform>(); if (rt != null && _RectTransform != null) { _RectTransform.Paste(rt); } for (int i = 0; i < Count; i++) { TransformData c = _Children[i]; Transform child = t.FindChild(c.Name); if (child != null) { c.Paste(child); } } }
/// <summary> /// Paste localPosition, localRotation and localScale from clipboard as formated string to selected objetc /// </summary> public static void PasteTransformHierarchy() { Transform[] ts = Selection.transforms; if (ts != null && ts.Length > 0) { string tData = EditorGUIUtility.systemCopyBuffer; if (!string.IsNullOrEmpty(tData)) { try { Skill.Framework.IO.XmlDocument document = new Framework.IO.XmlDocument(); document.LoadXml(tData); if (document.FirstChild != null) { TransformData td = new TransformData(); td.Load(document.FirstChild); foreach (var t in ts) { td.Paste(t); } Debug.Log("Hierarchy Transform pasted."); } else { Debug.Log("Invalid Hierarchy Transform data."); } } catch { Debug.Log("Invalid Hierarchy Transform data."); } } else { Debug.Log("Invalid Hierarchy Transform data."); } } }