예제 #1
0
 //why Unity does not store the links in package?
 void InitPrefabLinks()
 {
     if (Browser2D == null)
     {
         Browser2D = gameObject.GetComponent <RawImage>();
     }
     if (mainUIPanel == null)
     {
         mainUIPanel = gameObject.transform.Find("MainUI").gameObject.GetComponent <BrowserUI>();
     }
     if (DialogPanel == null)
     {
         DialogPanel = gameObject.transform.Find("MessageBox").gameObject;
     }
     if (DialogText == null)
     {
         DialogText = DialogPanel.transform.Find("MessageText").gameObject.GetComponent <Text>();
     }
     if (OkButton == null)
     {
         OkButton = DialogPanel.transform.Find("OK").gameObject.GetComponent <Button>();
     }
     if (YesButton == null)
     {
         YesButton = DialogPanel.transform.Find("Yes").gameObject.GetComponent <Button>();
     }
     if (NoButton == null)
     {
         NoButton = DialogPanel.transform.Find("No").gameObject.GetComponent <Button>();
     }
     if (DialogPrompt == null)
     {
         DialogPrompt = DialogPanel.transform.Find("Prompt").gameObject.GetComponent <InputField>();
     }
 }
        //why Unity does not store the links in package?
        private void InitPrefabLinks()
        {
            if (mainUIPanel == null)
            {
                mainUIPanel = Search <BrowserUI>("MainUI");
            }

            if (DialogEnabled)
            {
                if (DialogCanvas == null)
                {
                    DialogCanvas = gameObject.transform.Find("MessageBox").gameObject.GetComponent <Canvas>();
                }
                if (DialogText == null)
                {
                    DialogText = DialogCanvas.transform.Find("MessageText").gameObject.GetComponent <Text>();
                }
                if (OkButton == null)
                {
                    OkButton = DialogCanvas.transform.Find("OK").gameObject.GetComponent <Button>();
                }
                if (YesButton == null)
                {
                    YesButton = DialogCanvas.transform.Find("Yes").gameObject.GetComponent <Button>();
                }
                if (NoButton == null)
                {
                    NoButton = DialogCanvas.transform.Find("No").gameObject.GetComponent <Button>();
                }
                if (DialogPrompt == null)
                {
                    DialogPrompt = DialogCanvas.transform.Find("Prompt").gameObject.GetComponent <InputField>();
                }
            }
        }
        void InitPrefabLinks()
        {
            if (mainUIPanel == null)
            {
                mainUIPanel = Search <BrowserUI>("MainUI");
            }
            if (Browser2D == null)
            {
                Browser2D = gameObject.GetComponent <RawImage>();
            }


            if (DialogPanel == null)
            {
                var messagebox = transform.Find("MessageBox");
                if (messagebox)
                {
                    DialogPanel = messagebox.gameObject;
                }
            }

            if (DialogText == null)
            {
                DialogText = Search <Text>("MessageText");
            }
            if (OkButton == null)
            {
                OkButton = Search <Button>("OK");
            }
            if (YesButton == null)
            {
                YesButton = Search <Button>("Yes");
            }
            if (NoButton == null)
            {
                NoButton = Search <Button>("No");
            }
            if (DialogPrompt == null)
            {
                DialogPrompt = Search <InputField>("Prompt");
            }
            Debug.Log("Init prefab completed");
        }