public static void AddNotTransformBeforeHavingParent() { var rect = new Mux.Markup.RectTransform { BindingContext = 0 }; var beforeHavingParent = new NotTransform(); var afterHavingParent = new NotTransform(); SynchronizationContextWaiter.Execute(() => rect.Add(beforeHavingParent)); Assert.AreEqual(0, beforeHavingParent.BindingContext); Assert.Null(beforeHavingParent.gameObject); Assert.AreEqual(0, beforeHavingParent.awakeCount); var gameObject = new UnityEngine.GameObject(); try { rect.AddToInMainThread(gameObject); Assert.AreEqual(rect.Body.gameObject, beforeHavingParent.gameObject); Assert.AreEqual(0, beforeHavingParent.awakeCount); rect.Add(afterHavingParent); Assert.AreEqual(rect.Body.gameObject, afterHavingParent.gameObject); Assert.AreEqual(0, afterHavingParent.awakeCount); rect.AwakeInMainThread(); Assert.AreEqual(1, beforeHavingParent.awakeCount); Assert.AreEqual(1, afterHavingParent.awakeCount); } finally { UnityEngine.Object.Destroy(gameObject); } }
public static void AddTransform() { var rect = new Mux.Markup.RectTransform { BindingContext = 0 }; var afterHavingParent = new Mux.Markup.RectTransform(); var beforeHavingParent = new Mux.Markup.RectTransform(); rect.Add(beforeHavingParent); Assert.AreEqual(rect, ((IInternalTransform)beforeHavingParent).Parent); CollectionAssert.Contains(rect, beforeHavingParent); var gameObject = new UnityEngine.GameObject(); try { rect.AddToInMainThread(gameObject); Assert.AreEqual(gameObject.transform, rect.Body.parent); Assert.AreEqual(rect.Body, beforeHavingParent.Body.parent); Assert.False(beforeHavingParent.Body.gameObject.activeSelf); rect.Add(afterHavingParent); Assert.AreEqual(rect, ((IInternalTransform)afterHavingParent).Parent); Assert.AreEqual(rect.Body, afterHavingParent.Body.parent); Assert.False(afterHavingParent.Body.gameObject.activeSelf); rect.AwakeInMainThread(); Assert.True(beforeHavingParent.Body.gameObject.activeSelf); Assert.True(afterHavingParent.Body.gameObject.activeSelf); } finally { UnityEngine.Object.Destroy(gameObject); } }
public static void AddTransformToGameObject() { var gameObject = new UnityEngine.GameObject(); try { var child = new Mux.Markup.RectTransform(); child.PropertyChanged += (sender, args) => { Assert.AreEqual("Body", args.PropertyName); Assert.AreEqual(gameObject.transform, child.Body.parent); }; child.AddToInMainThread(gameObject); } finally { UnityEngine.Object.Destroy(gameObject); } }
public static void SetXAfterAddBeforeAwake() { var localPosition = new UnityEngine.Vector3(6, 0, 0); var rect = new Mux.Markup.RectTransform(); var gameObject = new UnityEngine.GameObject(); try { rect.AddToInMainThread(gameObject); rect.X = new Mux.Markup.Sized { AnchoredPosition = 6 }; Assert.AreEqual(localPosition, rect.Body.localPosition); rect.AwakeInMainThread(); Assert.AreEqual(localPosition, rect.Body.localPosition); } finally { UnityEngine.Object.Destroy(gameObject); } }