private void SafeCheck(GameObject layout)
 {
     if (!layout.transform.GetComponent <CanvasGroup>())
     {
         throw new Exception("Invalid Tooltip Layout! Prefab needs to have CanvasGroup component");
     }
     else if (!LayoutTransform.GetComponent <Image>())
     {
         throw new Exception("Invalid Tooltip Layout! LayoutTransform(child of canvas) needs to have Image component");
     }
 }
Example #2
0
        private void InitializeLayout()
        {
            try
            {
                LayoutTransform = UIWindow.transform.GetChild(0);
            }
            catch (Exception)
            {
                Debug.LogError("You should have child transform on your prefab!");
            }
            SafeCheck(LayoutTransform);

            LayoutRectTransform   = LayoutTransform.GetComponent <RectTransform>();
            UIWindowRectTransform = UIWindow.GetComponent <RectTransform>();
            CanvasGroup           = UIWindow.GetComponent <CanvasGroup>();
            Images  = Initialize(LayoutTransform.GetChild(0), Images);
            Buttons = Initialize(LayoutTransform.GetChild(1), Buttons);
            Texts   = Initialize(LayoutTransform.GetChild(2), Texts);
        }