//Use this for initialization.
 void Start()
 {
     /*
      * These code below mostly to get reference to this game object component or
      *      this game object's child component.
      * Get this game object Image and RectTransform component.
      */
     image         = gameObject.GetComponent <Image>();
     rectTransform = gameObject.GetComponent <RectTransform>();
     //Fill in childPanelScrollTextLog and take its Image component.
     childPanelScrollTextLog      = gameObject.transform.Find("PanelScrollTextLog");
     childPanelScrollTextLogImage = childPanelScrollTextLog.gameObject.GetComponent <Image>();
     //Get the childTextClickToDismiss game object.
     childTextClickToDismiss = gameObject.transform.Find("TextClickToDismiss");
     //Get childTextClickToDismiss's text component.
     childTextClickToDismissText = childTextClickToDismiss.gameObject.GetComponent <Text>();
     //Get the childTextLog game object and its text component.
     childTextLog     = gameObject.transform.Find("PanelScrollTextLog").Find("TextLog");
     childTextLogText = childTextLog.gameObject.GetComponent <Text>();
     //Put reference to exhibitionDatabase.
     exhibitionDatabase       = GameObject.Find("ExhibitionDatabase");
     scriptExhibitionDatabase = exhibitionDatabase.GetComponent <ScriptExhibitionDatabase>();
     //Panel content show cards.
     panelContentShowCards       = GameObject.Find("PanelContentShowCards");
     scriptPanelContentShowCards = panelContentShowCards.GetComponent <ScriptPanelContentShowCards>();
     //Assign value to panelNotification.
     panelNotification       = GameObject.Find("PanelNotification");
     scriptPanelNotification = panelNotification.GetComponent <ScriptPanelNotification>();
 }
    private void SetExhibition()
    {
        //Get reference to ExhibitionDatabase game object.
        exhibitionDatabase = GameObject.Find("ExhibitionDatabase");

        //Null reference checking.
        if(exhibitionDatabase != null){

            //Get reference to ScriptExhibitionDatabase inside ExhibitionDatabase game object.
            scriptExhibitionDatabase =
                exhibitionDatabase.GetComponent<ScriptExhibitionDatabase>();

            exhibitionArrayLength =
                scriptExhibitionDatabase.exhibitionArray.Length;

            /*
            Get this game object exhibition string.
            What I meant by exhibition string is a string that has substracted from
                this game object name so that it only take the number of this ButtonExhibition
                game object.
            In my case, in this program only buttons those are not ButtonExhibitionPrime has
                exhibition index because, ButtonExhibitionPrime is always visited no matter what.
            */
            if(gameObject.name != "ButtonExhibitionPrime"){
                exhibitionIndexString = gameObject.name.Replace("ButtonExhibition", "");
                exhibitionIndexInt = int.Parse(exhibitionIndexString);

                //If there is explanation given for this button exhibition.
                if(exhibitionIndexInt <= exhibitionArrayLength - 1){
                    exhibitionExplanationAmount =
                        scriptExhibitionDatabase.exhibitionArray[exhibitionIndexInt].explanationArray.Length;
                }
                //If there is no explanation given for this button exhibition in particular.
                else if(exhibitionIndexInt > exhibitionArrayLength - 1){

                    /*
                    Just give the value to -1, I think I can also make the value
                        as null.
                    But whatever~.
                    */
                    exhibitionExplanationAmount = -1;

                }

            }

            //Specifically for ButtonExhibitionPrime I set the index to 0.
            else if(gameObject.name == "ButtonExhibitionPrime"){

                exhibitionIndexInt = 0;
                //If there is explanation given for this button exhibition.
                if(exhibitionIndexInt <= exhibitionArrayLength - 1){
                    exhibitionExplanationAmount =
                        scriptExhibitionDatabase.exhibitionArray[exhibitionIndexInt].explanationArray.Length;
                }
                //If there is no explanation given for this button exhibition in particular.
                else if(exhibitionIndexInt > exhibitionArrayLength - 1){

                    /*
                    Just give the value to -1, I think I can also make the value
                        as null.
                    But whatever~.
                    */
                    exhibitionExplanationAmount = -1;

                }

            }

        }
        else{

            exhibitionExplanationAmount = -1;

            //Print debug error message.
            Debug.Log("ERROR: GameObject ExhibitionDatabase could not be found!");

        }
    }
Example #3
0
    private void SetExhibition()
    {
        //Get reference to ExhibitionDatabase game object.
        exhibitionDatabase = GameObject.Find("ExhibitionDatabase");

        //Null reference checking.
        if (exhibitionDatabase != null)
        {
            //Get reference to ScriptExhibitionDatabase inside ExhibitionDatabase game object.
            scriptExhibitionDatabase =
                exhibitionDatabase.GetComponent <ScriptExhibitionDatabase>();

            exhibitionArrayLength =
                scriptExhibitionDatabase.exhibitionArray.Length;

            /*
             * Get this game object exhibition string.
             * What I meant by exhibition string is a string that has substracted from
             *      this game object name so that it only take the number of this ButtonExhibition
             *      game object.
             * In my case, in this program only buttons those are not ButtonExhibitionPrime has
             *      exhibition index because, ButtonExhibitionPrime is always visited no matter what.
             */
            if (gameObject.name != "ButtonExhibitionPrime")
            {
                exhibitionIndexString = gameObject.name.Replace("ButtonExhibition", "");
                exhibitionIndexInt    = int.Parse(exhibitionIndexString);

                //If there is explanation given for this button exhibition.
                if (exhibitionIndexInt <= exhibitionArrayLength - 1)
                {
                    exhibitionExplanationAmount =
                        scriptExhibitionDatabase.exhibitionArray[exhibitionIndexInt].explanationArray.Length;
                }
                //If there is no explanation given for this button exhibition in particular.
                else if (exhibitionIndexInt > exhibitionArrayLength - 1)
                {
                    /*
                     * Just give the value to -1, I think I can also make the value
                     *      as null.
                     * But whatever~.
                     */
                    exhibitionExplanationAmount = -1;
                }
            }

            //Specifically for ButtonExhibitionPrime I set the index to 0.
            else if (gameObject.name == "ButtonExhibitionPrime")
            {
                exhibitionIndexInt = 0;
                //If there is explanation given for this button exhibition.
                if (exhibitionIndexInt <= exhibitionArrayLength - 1)
                {
                    exhibitionExplanationAmount =
                        scriptExhibitionDatabase.exhibitionArray[exhibitionIndexInt].explanationArray.Length;
                }
                //If there is no explanation given for this button exhibition in particular.
                else if (exhibitionIndexInt > exhibitionArrayLength - 1)
                {
                    /*
                     * Just give the value to -1, I think I can also make the value
                     *      as null.
                     * But whatever~.
                     */
                    exhibitionExplanationAmount = -1;
                }
            }
        }
        else
        {
            exhibitionExplanationAmount = -1;

            //Print debug error message.
            Debug.Log("ERROR: GameObject ExhibitionDatabase could not be found!");
        }
    }
 //Use this for initialization.
 void Start()
 {
     /*
     These code below mostly to get reference to this game object component or
         this game object's child component.
     Get this game object Image and RectTransform component.
     */
     image = gameObject.GetComponent<Image>();
     rectTransform = gameObject.GetComponent<RectTransform>();
     //Fill in childPanelScrollTextLog and take its Image component.
     childPanelScrollTextLog = gameObject.transform.Find("PanelScrollTextLog");
     childPanelScrollTextLogImage = childPanelScrollTextLog.gameObject.GetComponent<Image>();
     //Get the childTextClickToDismiss game object.
     childTextClickToDismiss = gameObject.transform.Find("TextClickToDismiss");
     //Get childTextClickToDismiss's text component.
     childTextClickToDismissText = childTextClickToDismiss.gameObject.GetComponent<Text>();
     //Get the childTextLog game object and its text component.
     childTextLog = gameObject.transform.Find("PanelScrollTextLog").Find("TextLog");
     childTextLogText = childTextLog.gameObject.GetComponent<Text>();
     //Put reference to exhibitionDatabase.
     exhibitionDatabase = GameObject.Find("ExhibitionDatabase");
     scriptExhibitionDatabase = exhibitionDatabase.GetComponent<ScriptExhibitionDatabase>();
     //Panel content show cards.
     panelContentShowCards = GameObject.Find("PanelContentShowCards");
     scriptPanelContentShowCards = panelContentShowCards.GetComponent<ScriptPanelContentShowCards>();
     //Assign value to panelNotification.
     panelNotification = GameObject.Find("PanelNotification");
     scriptPanelNotification = panelNotification.GetComponent<ScriptPanelNotification>();
 }