public IEnumerator FindAllOfType() { yield return(new WaitForSecondsRealtime(2)); // - REcanvas 1 // - REtext 4 // - REimage 4 // - REbutton 2 // - REpanel 1 // Select All REcanvas.Selector[] finded = REcanvas.Find(); Debug.Log(finded.Length); Assert.IsTrue(finded.Length == 1); REtext.Selector[] finded2 = REtext.Find(); Debug.Log(finded2.Length); Assert.IsTrue(finded2.Length == 4); REimage.Selector[] finded3 = REimage.Find(); Debug.Log(finded3.Length); Assert.IsTrue(finded3.Length == 4); REbutton.Selector[] finded4 = REbutton.Find(); Debug.Log(finded4.Length); Assert.IsTrue(finded4.Length == 2); REpanel.Selector[] finded5 = REpanel.Find(); Debug.Log(finded5.Length); Assert.IsTrue(finded5.Length == 1); // Select All finded = REcanvas.Find(""); Debug.Log(finded.Length); Assert.IsTrue(finded.Length == 1); finded2 = REtext.Find(""); Debug.Log(finded2.Length); Assert.IsTrue(finded2.Length == 4); finded3 = REimage.Find(""); Debug.Log(finded3.Length); Assert.IsTrue(finded3.Length == 4); finded4 = REbutton.Find(""); Debug.Log(finded4.Length); Assert.IsTrue(finded4.Length == 2); finded5 = REpanel.Find(""); Debug.Log(finded5.Length); Assert.IsTrue(finded5.Length == 1); yield return(new WaitForSecondsRealtime(2)); }
void Start() { // Multiple components reactorList1 = ListREcomponent().Draw(); var find = REtext.Find("#Title-One"); Debug.Log("Elements Finded: " + find.Length); foreach (var element in find) { Debug.Log("Type: " + element.textCmp.text); } }
public IEnumerator FindByIdOfType() { yield return(new WaitForSecondsRealtime(2)); // By id REcanvas.Selector[] finded = REcanvas.Find("#CanvasSuperior"); Assert.IsTrue(finded.Length == 1); // By id REtext.Selector[] finded2 = REtext.Find("#Title-One"); Assert.IsTrue(finded2.Length == 2); // By id REcanvas.Selector[] finded3 = REcanvas.Find("#ImagenSuperior"); Assert.IsTrue(finded3.Length == 0); // By id REpanel.Selector[] finded4 = REpanel.Find("#PanelBack"); Assert.IsTrue(finded4.Length == 1); // By id REbutton.Selector[] finded5 = REbutton.Find("#MainButton"); Assert.IsTrue(finded5.Length == 0); yield return(new WaitForSecondsRealtime(2)); }
public IEnumerator DrawInOtherObject() { // Create a reactor component REcanvas MainReactorComponent() { return(new REcanvas { childs = () => new REbase[] { new REtext { propsId = () => new REtext.IdSetter { id = "ProveText" }, propsText = () => new REtext.TextSetter { text = "Hello world", }, childs = () => new REbase[] { new REimage(), new REimage(), } }, new REtext(), new REtext(), new REtext(), }, }); } var reactorComponent = MainReactorComponent(); yield return(new WaitForSecondsRealtime(1)); // Draw the component for the first time but in other object Debug.Log("Drawing"); reactorComponent.Draw(new GameObject("AnyObject")); yield return(new WaitForSecondsRealtime(1)); // Look fr the component var textSelector = REtext.Find("#ProveText")[0]; // The transform root must be the other object Assert.IsTrue(REtext.Find("#ProveText").Length == 1); Assert.IsTrue(textSelector.rectTransform.root.gameObject.name == "AnyObject"); // If component is redrawed the same parent must be in same object, but must be finded again reactorComponent.Draw(new GameObject("OtherObject")); textSelector = REtext.Find("#ProveText")[0]; // The transform root must be the other object Assert.IsTrue(REtext.Find("#ProveText").Length == 1); Assert.IsTrue(textSelector.rectTransform.root.gameObject.name == "OtherObject"); // If component is redrawed in null reactorComponent.Draw(); textSelector = REtext.Find("#ProveText")[0]; // The transform root must be the canvas Assert.IsTrue(REtext.Find("#ProveText").Length == 1); Assert.IsTrue(textSelector.rectTransform.root.gameObject.name == "Canvas-Unamed"); reactorComponent.Erase(); }
public IEnumerator DrawInOtherObjectNestedCanvas_Selector_ParentCanvas() { // Create a reactor component REcanvas MainReactorComponent() { return(new REcanvas { propsGameObject = () => new REcanvas.GameObjectSetter { name = "RootCanvas", }, childs = () => new REbase[] { new REcanvas { childs = () => new REbase[] { new REpanel { childs = () => new REbase[] { new REtext { propsId = () => new REtext.IdSetter { id = "ProveText" }, propsText = () => new REtext.TextSetter { text = "Hello world", }, childs = () => new REbase[] { new REimage(), new REimage(), } }, new REtext(), new REtext(), new REtext(), }, } }, } }, }); } var reactorComponent = MainReactorComponent(); yield return(new WaitForSecondsRealtime(1)); // Draw the component for the first time but in other object Debug.Log("Drawing"); reactorComponent.Draw(new GameObject("AnyObject")); yield return(new WaitForSecondsRealtime(1)); // Look fr the component Debug.Log("Finding"); var textSelector = REtext.Find("#ProveText")[0]; // The transform root must be the other object Assert.IsTrue(REtext.Find("#ProveText").Length == 1); Assert.IsTrue(textSelector.rectTransform.root.gameObject.name == "AnyObject"); // But the selector parentcanvas must be the first canvas Debug.Log("Check parentCanvas"); Assert.IsTrue(textSelector.parentCanvasSelector.gameObject.name == "Canvas-Unamed"); Assert.IsTrue(textSelector.parentCanvasSelector.parentCanvasSelector.gameObject.name == "RootCanvas"); Assert.IsTrue(textSelector.parentCanvasSelector.parentCanvasSelector.parentCanvasSelector.gameObject.name == "RootCanvas"); var canvasSelector = (REcanvas.Selector)textSelector.parentCanvasSelector; canvasSelector = (REcanvas.Selector)textSelector.parentCanvasSelector.parentCanvasSelector; canvasSelector = (REcanvas.Selector)textSelector.parentCanvasSelector.parentCanvasSelector.parentCanvasSelector; // If component is redrawed in null Debug.Log("Drawing in null"); reactorComponent.Draw(); textSelector = REtext.Find("#ProveText")[0]; // But the selector parentcanvas must be the first canvas Debug.Log("Check parentCanvas"); Assert.IsTrue(textSelector.parentCanvasSelector.gameObject.name == "Canvas-Unamed"); Assert.IsTrue(textSelector.parentCanvasSelector.parentCanvasSelector.gameObject.name == "RootCanvas"); Assert.IsTrue(textSelector.parentCanvasSelector.parentCanvasSelector.parentCanvasSelector.gameObject.name == "RootCanvas"); canvasSelector = (REcanvas.Selector)textSelector.parentCanvasSelector; canvasSelector = (REcanvas.Selector)textSelector.parentCanvasSelector.parentCanvasSelector; canvasSelector = (REcanvas.Selector)textSelector.parentCanvasSelector.parentCanvasSelector.parentCanvasSelector; reactorComponent.Erase(); }
public IEnumerator DrawInOtherObject_ButObjectDestroyed() { // Create a reactor component REcanvas MainReactorComponent() { return(new REcanvas { childs = () => new REbase[] { new REtext { propsId = () => new REtext.IdSetter { id = "ProveText" }, propsText = () => new REtext.TextSetter { text = "Hello world", }, childs = () => new REbase[] { new REimage(), new REimage(), } }, new REtext(), new REtext(), new REtext(), }, }); } var reactorComponent = MainReactorComponent(); yield return(new WaitForSecondsRealtime(1)); // Draw the component for the first time but in other object Debug.Log("Drawing"); reactorComponent.Draw(new GameObject("AnyObject")); yield return(new WaitForSecondsRealtime(1)); // Look fr the component Debug.Log("Finding"); var textSelector = REtext.Find("#ProveText")[0]; // The transform root must be the other object Assert.IsTrue(REtext.Find("#ProveText").Length == 1); Assert.IsTrue(textSelector.rectTransform.root.gameObject.name == "AnyObject"); // If component is redrawed the same parent must be in same object, but must be finded again Debug.Log("Drawing in other object"); var go = new GameObject("OtherObject"); reactorComponent.Draw(go); textSelector = REtext.Find("#ProveText")[0]; // The transform root must be the other object Debug.Log("Finding again"); Assert.IsTrue(REtext.Find("#ProveText").Length == 1); Assert.IsTrue(textSelector.rectTransform.root.gameObject.name == "OtherObject"); // If object destroyed Debug.Log("Destroying object"); UnityEngine.Object.DestroyImmediate(go); // Reactor component will be destroyed too Assert.IsTrue(REtext.Find("#ProveText").Length == 0); // Check that the selector references are now null Debug.Log("Checking selectoris destroyed"); Assert.IsTrue(textSelector.isDisposed); Assert.IsTrue(textSelector.rectTransform == null); Assert.IsTrue(textSelector.gameObject == null); Assert.IsTrue(textSelector.parent == null); Assert.IsTrue(textSelector.childs == null); Assert.IsTrue(textSelector.brothersSelector == null); Assert.IsTrue(textSelector.canvasRenderer == null); Assert.Throws <NullReferenceException>(() => Debug.Log("V: " + textSelector.rectTransform.rect)); reactorComponent.Erase(); }
public IEnumerator FindByClassNameOfType() { yield return(new WaitForSecondsRealtime(2)); // One classname var finded = REcanvas.Find(".Back"); Debug.Log(finded.Length); Assert.IsTrue(finded.Length == 1); var finded2 = REtext.Find(".H1"); Debug.Log(finded2.Length); Assert.IsTrue(finded2.Length == 2); var finded3 = REtext.Find(".Text"); Debug.Log(finded3.Length); Assert.IsTrue(finded3.Length == 4); var finded4 = REimage.Find(".Title"); Debug.Log(finded4.Length); Assert.IsTrue(finded4.Length == 0); var finded5 = REbutton.Find(".Button"); Debug.Log(finded5.Length); Assert.IsTrue(finded5.Length == 2); var finded6 = REcanvas.Find(".White"); Debug.Log(finded6.Length); Assert.IsTrue(finded6.Length == 0); // With AND var finded7 = REtext.Find(".H1&&.Text&&.Title"); Debug.Log(finded7.Length); Assert.IsTrue(finded7.Length == 1); var finded8 = REbutton.Find(".Button&&Title"); Debug.Log(finded8.Length); Assert.IsTrue(finded8.Length == 1); var finded9 = REimage.Find(".H1&&.Text"); Debug.Log(finded9.Length); Assert.IsTrue(finded9.Length == 0); var finded10 = REcanvas.Find(".H1&&Pink"); Debug.Log(finded10.Length); Assert.IsTrue(finded10.Length == 0); // With or var finded11 = REtext.Find(".Button||Text"); Debug.Log(finded11.Length); Assert.IsTrue(finded11.Length == 4); var finded12 = REpanel.Find(".Back||H1||Text"); Debug.Log(finded12.Length); Assert.IsTrue(finded12.Length == 1); var finded13 = REtext.Find(".Back||H1||Grey"); Debug.Log(finded13.Length); Assert.IsTrue(finded13.Length == 2); yield return(new WaitForSecondsRealtime(2)); }
public IEnumerator Find_ThenErase() { // Create a reactor component REcanvas MainReactorComponent() { return(new REcanvas { childs = () => new REbase[] { new REtext { propsId = () => new REtext.IdSetter { id = "ProveText" }, propsText = () => new REtext.TextSetter { text = "Hello world", }, childs = () => new REbase[] { new REimage(), new REimage(), } }, new REtext(), new REtext(), new REtext(), }, }); } var reactorComponent = MainReactorComponent(); yield return(new WaitForSecondsRealtime(1)); // Draw the component for the first time Debug.Log("Drawing"); reactorComponent.Draw(); yield return(new WaitForSecondsRealtime(1)); // Look fr the component Debug.Log("Finding"); var textSelector = REtext.FindOne("#ProveText"); // Check that the compoennt exist Assert.IsFalse(textSelector.isDisposed); Assert.IsFalse(textSelector.rectTransform == null); Assert.IsFalse(textSelector.gameObject == null); Assert.IsFalse(textSelector.parent == null); Assert.IsFalse(textSelector.childs == null); Assert.IsFalse(textSelector.brothersSelector == null); Assert.IsFalse(textSelector.canvasRenderer == null); Assert.IsTrue(textSelector.textCmp.text == "Hello world"); // Erase the component Debug.Log("Erasing"); reactorComponent.Erase(); // Check that the selector references are now null Assert.IsTrue(textSelector.isDisposed); Assert.IsTrue(textSelector.rectTransform == null); Assert.IsTrue(textSelector.gameObject == null); Assert.IsTrue(textSelector.parent == null); Assert.IsTrue(textSelector.childs == null); Assert.IsTrue(textSelector.brothersSelector == null); Assert.IsTrue(textSelector.canvasRenderer == null); Assert.Throws <NullReferenceException>(() => Debug.Log("V: " + textSelector.rectTransform.rect)); // Try to find again the component that it must not exist Debug.Log("Finding again"); Assert.IsTrue(REtext.Find("#ProveText").Length == 0); yield return(new WaitForSecondsRealtime(2)); reactorComponent.Erase(); }