Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by hmid_30 · Mar 26, 2017 at 05:15 PM · transformerror messageuser interface

Transform child out of bounds

Hello, i'm a beginner with Unity and i'm not very good in English then i apologize. I have a problem with a quizz game, i have an Exception :Transform child out of bounds and i don't know why, i think i have a child on the element... My 2 scripts:

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.UI; // permet de recuperer les elements de UI
 
 
 public class Reponses : MonoBehaviour {
 
     // Use this for initialization
     public void OnMouseDown () {  //quand je clique sur un objet
            if (Quizz.Reponse == transform.GetChild (0).GetComponent<Text> ().text) {
             Debug.Log ("Gagné");
             Quizz.Score += 1;
             //GameObject.Find ("Canvas").GetComponent<Quizz> ().Score += 1;
         } 
         else {
             Debug.Log ("perdu");
         }
 
         GameObject.Find ("Canvas").GetComponent<Quizz> ().PoseUneQuestion ();
     }
 
 }
 and my second script for the quizz :

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.UI; // permet de recuperer les elements de UI
 
 public class Quizz : MonoBehaviour {
 
     Text TxtQuestion;
      static Text TxtBtnG;
     static Text TxtBtnD;
     static Text TxtBtnBD;
     static Text TxtBtnBG;
     int Nr; // nombre aleatoire
     static Text TxtScore;
 
     // creation d'un tableau de chaines de caracteres
     string[] Quiz = new string[3];
     // variable publique reponse
     public static string Reponse;
     // variable publique score
     public static int Score = 0 ;
     public int TotalQuestions = 5;
     int NbQuestions = 0;
 
 
     // Use this for initialization
     void Start () {
 
         TxtQuestion = GameObject.Find("TxtQuestion").GetComponent<Text>();
         TxtScore = GameObject.Find ("TxtScore").GetComponent<Text> ();
         TxtBtnG = GameObject.Find ("TxtBtnG").GetComponent<Text> ();
         TxtBtnD = GameObject.Find ("TxtBtnD").GetComponent<Text> ();
         TxtBtnBD = GameObject.Find ("TxtBtnBD").GetComponent<Text> ();
         TxtBtnBG = GameObject.Find ("TxtBtnBG").GetComponent<Text> ();
 
         // declaration du contenu tableau 
         Quiz[0] = "Un client entre et ne vous dit pas bonjour.,Je l'ignore et je le laisse faire.,Je lui dis bonjour tout de suite sans le sourire.,Je lui dis bonjour tout de suite en souriant.,Je le laisse observer le magasin avant d'aller le saluer.,Je le laisse observer le magasin avant d'aller le saluer."; // separateur pour les collonnes : , 
         Quiz[1]= "Un de vos proches entre votre accueil est :,Hé salut comment ça va?,Ah ça fait plaisir de vous voir!,Bonjour (grand sourire),Je m'excuse auprès de mon client et je vais l'embrasser.,Bonjour (grand sourire)";
         Quiz[2] = "Personne dans le magasin et un client entre ,Vous finissez votre activité et vous allez ensuite le voir.,Vous allez sans tarder vers lui d'un pas décidé,Vous attendez qu'il vienne vers vous,Vous lui faîtes un signe de la tete,Vous finissez votre activité et vous allez ensuite le voir.";
         // decoupage du tableau avec la methode split
         //string[] Col = Quiz[0].split(",");
 
         PoseUneQuestion ();
         
     }
     
     // Update is called once per frame
     void Update () {
         TxtScore.text = "Score : " + Score;
     }
     public void PoseUneQuestion()
     {
         if (NbQuestions < TotalQuestions) {
             NbQuestions += 1;
             Nr = Random.Range (0, Quiz.Length);
             string[] Col = Quiz [Nr].Split (',');
             TxtQuestion.text = Col [0];
             TxtBtnG.text = Col [1];
             TxtBtnD.text = Col [2];
             TxtBtnBG.text = Col [3];
             TxtBtnBD.text = Col [4];
             Reponse = Col [5];
         } 
         else {
             Debug.Log("Partie Terminée. Score final : " + Score + " / " + TotalQuestions) ;
 
 
         }
 
     }
 }
 

I hope you could help me, i tryed, i looked forums, and i suppose it's just a little syntax eror... I need help, thanks. Here an image of my unity prject : alt text

sans-titre.jpg (276.3 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Rotation Issues error CS1612:,Can't edit rotation (error CS1612) 1 Answer

Warning: "Setting scale failed, ignoring request." ? 1 Answer

How to make a world-space UI panel that can find an open position in the world? 0 Answers

transform is destroyed (ERROR)... and I want the game to complete 1 Answer

Error says object reference not set when it really is? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges