/// <summary>
 /// Initializes gif draw function and tries
 /// to access the ChatbotCore.core.bot variable.
 /// </summary>
 void Start()
 {
     //Debug.Log ("Test: " + _Emoticons.Count);
     // Loop throug existing emoticons
     foreach (ChatbotEmoticons _entry in _Emoticons)
     {
         // If the gif file names match
         if (loadingGifPath == _entry._gifFile)
         {
             // Loop through frames
             foreach (Texture2D _frame in _entry._frames)
             {
                 // Add frame
                 gifFrames.Add(_frame);
             }
             // Copy the frame list
             gifFrames = _entry._frames;
             // If gif frames exist and frame count is bigger than zero
             if (gifFrames != null && gifFrames.Count > 0)
             {
                 // Store draw position
                 drawPosition = new Vector2(centerPosition.x - (gifFrames[0].width * _emoticonScale) / 2.0f, centerPosition.y - (gifFrames[0].height * _emoticonScale) / 2.0f);
             }
         }
     }
     // Try to access ChatbotCore component
     if (this.gameObject.GetComponent <ChatbotCore>())
     {
         // Try to access bot
         if (this.gameObject.GetComponent <ChatbotCore>().bot != null)
         {
             bot = this.gameObject.GetComponent <ChatbotCore>().bot;
         }
     }
 }
 /// <summary>
 /// Render the output of chatbot, like dialoges and more.
 /// </summary>
 void OnGUI()
 {
     // Draw Emoticon in front of other elements
     //GUI.depth = 0;
     // Render if reference to bot exists
     if (bot != null)
     {
         // Centered output style, color and wordwarp
         GUIStyle outputstyle = new GUIStyle();
         outputstyle.alignment        = TextAnchor.UpperCenter;
         outputstyle.normal.textColor = UnityEngine.Color.white;
         outputstyle.wordWrap         = true;
         // Enable Word warp
         GUI.skin.label.wordWrap = true;
         // Make a background box
         GUI.Box(new Rect(10, 10, 600, 400), "Chat with a Chatbot");
         // Make output label
         GUI.Label(new Rect(20, 300, 580, 40), Output_Text, outputstyle);
         // Make a text field that modifies Input_Text.
         Input_Text = GUI.TextField(new Rect(20, 350, 580, 20), Input_Text, 100);
         // If send button or enter pressed
         if (((Event.current.keyCode == KeyCode.Return) || GUI.Button(new Rect(550, 380, 50, 20), "Send")) && (Input_Text != ""))
         {
             // Simple perform chat and return output string
             Output_Text = bot.Chat(Input_Text);
             // Setting components in Scene are updated intern
             // Reset input text again
             Input_Text = "";
         }
         // When image changes, gui might be called.
         // So prevent error, if no frames loaded.
         if (gifFrames != null && gifFrames.Count != 0)
         {
             // Draw selected emoticon
             GUI.DrawTexture(new Rect(drawPosition.x, drawPosition.y, (gifFrames[0].width * _emoticonScale), (gifFrames[0].height * _emoticonScale)), gifFrames[(int)(Time.realtimeSinceStartup * speed) % gifFrames.Count]);
         }
     }
     else
     {
         // Try to access ChatbotCore component
         if (this.gameObject.GetComponent <ChatbotCore>())
         {
             // Try to access bot
             if (this.gameObject.GetComponent <ChatbotCore>().bot != null)
             {
                 bot = this.gameObject.GetComponent <ChatbotCore>().bot;
             }
         }
     }
 }
    /// <summary>
    /// Initialyse Trigger instance by retrieve
    /// Chatbot.Core instance
    /// </summary>
    void Start()
    {
        // Counter to avoid endless loop
        int counter = 0;
        // Count till this value
        int countmax = 10;
        // Current transform
        Transform tmpTrans = this.transform;
        // Gathered ChatbotCore component
        ChatbotCore tmpChatbotCore = null;

        // Loop through transforms till counter reached countmax
        while (counter < countmax)
        {
            // Is Transform available?
            if (tmpTrans == null)
            {
                // Abort global settings update
                counter = countmax;
            }
            else
            {
                // Try to grab ChatbotCore component
                tmpChatbotCore = tmpTrans.gameObject.GetComponent <ChatbotCore> ();
                // Test wether tmpChatbotCore exists
                if (tmpChatbotCore != null)
                {
                    // Set Triggers instance for later reference
                    bot = tmpChatbotCore.bot;
                    // Abort loop
                    counter = countmax;
                }
                // Get parent transform
                tmpTrans = tmpTrans.parent;
                // Increase counter
                counter++;
            }
        }
    }