コード例 #1
0
ファイル: RectTransformNode.cs プロジェクト: yakumo-proj/Mux
        public static void DestroyImmediate()
        {
            var source = new Source {
                Property = 0
            };
            var binding    = new Binding("Property", BindingMode.OneWay, null, null, null, source);
            var gameObject = new UnityEngine.GameObject();

            try
            {
                var parent = new Mux.Markup.RectTransform();
                parent.AddTo(gameObject);
                var rect = new Mux.Markup.RectTransform();
                parent.Add(rect);

                SynchronizationContextWaiter.Execute(() =>
                {
                    rect.SetBinding(Mux.Markup.RectTransform.BindingContextProperty, binding);
                    rect.DestroyImmediate();
                    source.Property = 1;
                    Assert.AreEqual(0, rect.BindingContext);
                });

                Assert.AreEqual(0, parent.Body.childCount);
                CollectionAssert.DoesNotContain(parent, rect);
            }
            finally
            {
                UnityEngine.Object.Destroy(gameObject);
            }
        }
コード例 #2
0
ファイル: RectTransformNode.cs プロジェクト: yakumo-proj/Mux
        public static void DestroyMuxInMainThreadUnappliesBindings()
        {
            var rect   = new Mux.Markup.RectTransform();
            var source = new Source {
                Property = 0
            };
            var binding = new Binding("Property", BindingMode.OneWay, null, null, null, source);

            rect.SetBinding(Mux.Markup.RectTransform.BindingContextProperty, binding);
            rect.DestroyMuxInMainThread();
            source.Property = 1;
            Assert.AreEqual(0, rect.BindingContext);
        }