private void AddScreenElementData(global::UIModule.Scripts.UIElement uiElement) { ScreenElement screenElement = new ScreenElement(currentScreen); screenElement.TransformData = GetCurrentRectTransform(uiElement.GetComponent <RectTransform>()); uiElement.screenElements.Add(screenElement); }
private void SetUIElement() { if (Selection.gameObjects != null) { for (int j = 0; j < Selection.gameObjects.Length; j++) { if (Selection.gameObjects[j].GetComponent <RectTransform>() != null) { if (Selection.gameObjects[j].GetComponent <global::UIModule.Scripts.UIElement>() != null) { global::UIModule.Scripts.UIElement uiElement = Selection.gameObjects[j].GetComponent <global::UIModule.Scripts.UIElement>(); int index = -1; if (uiElement.screenElements != null) { for (int i = 0; i < uiElement.screenElements.Count; i++) { if (uiElement.screenElements[i].Screen.Equals(currentScreen)) { index = i; break; } } if (index != -1) { uiElement.screenElements[index].TransformData = GetCurrentRectTransform(uiElement.GetComponent <RectTransform>()); } else { AddScreenElementData(uiElement); } } else { uiElement.screenElements = new List <ScreenElement>(); AddScreenElementData(uiElement); } } else { EditorUtility.DisplayDialog("Missing component.", "Selected element does not have a UIElement component. Please select the correct element and try again.", "Ok"); } //Do the operations //EditorUtility.DisplayDialog("UI Object selected.", "The object you selected contains Rect Transform component.", "Ok"); } else { EditorUtility.DisplayDialog("No UI Object selected.", "The object you selected does not contain Rect Transform component. Please select again.", "Ok"); } } } else { EditorUtility.DisplayDialog("No object selected", "No UI object selected, please try again.", "Ok"); } }