public static ObjectProperties_Struct Create(GameObject GO, Vector3 Position, Quaternion Rotation, Vector3 Scale) { ObjectProperties_Struct OPS = new ObjectProperties_Struct(); OPS.GO = GO; OPS.Position = Position; OPS.Rotation = Rotation; OPS.Scale = Scale; return(OPS); }
public bool SetProperties(GameObject GO) { if (GO == null) { CustomMessage = "You've To Select Object"; return(false); } CustomMessage = ""; Transform MyTransform = GO.transform; if (MyTransform == null) { CustomMessage = "Selected Object Does Not Contain Transform"; return(false); } List <GameObject> Children = FindChildrenObjects(GO); if (Children.Count > 0) { foreach (GameObject GO2 in Children) { Transform T = GO2.transform; if (T == null) { continue; } ObjectProperties.Add(ObjectProperties_Struct.Create(GO2, T.position, T.rotation, T.lossyScale)); } if (bChangePosition) { MyTransform.localPosition = NewPosition; } if (bChangeRotation) { MyTransform.localRotation = NewRotation; } if (bChangeScale) { MyTransform.localScale = NewScale; } foreach (ObjectProperties_Struct OPS in ObjectProperties) { if (OPS.GO == null) { continue; } Transform T = OPS.GO.transform; if (T == null) { continue; } if (bKeepChildrenPosition) { T.position = OPS.Position; } if (bKeepChildrenRotation) { T.rotation = OPS.Rotation; } if (bKeepChildrenScale) { Vector3 V = new Vector3(0, 0, 0); V.x = T.localScale.x * (OPS.Scale.x / T.lossyScale.x); V.y = T.localScale.y * (OPS.Scale.y / T.lossyScale.y); V.z = T.localScale.z * (OPS.Scale.z / T.lossyScale.z); T.localScale = V; } } if (ObjectProperties != null) { ObjectProperties.Clear(); } } else { if (bChangePosition) { MyTransform.localPosition = NewPosition; } if (bChangeRotation) { MyTransform.localRotation = NewRotation; } if (bChangeScale) { MyTransform.localScale = NewScale; } } if (Children != null) { Children.Clear(); } return(true); }