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 /
  • Help Room /
avatar image
0
Question by leralonde · Dec 12, 2016 at 11:45 PM · c#booleancallfunction call

I cant call function another script !

Hi guys , i have bool (isFire,isWater...) and i cannot call the inside the ConfirmButton function boolean variables in the ArenaBackground class. Boolean variables seems false all the time.

Could you help me ?

using UnityEngine; using System.Collections; using UnityEngine.SceneManagement;

 namespace S3{
 public class CharacterSelection : MonoBehaviour {
 
     private GameObject[] characterList;
     private int index;
         //Character 
     public bool isFire;
     public bool isWater;
     public bool isEarth;
     public bool isWood;
 
 
     private void Start(){
 
 
             index = PlayerPrefs.GetInt ("CharacterSelected");
 
             characterList = new GameObject[transform.childCount];
 
 
             foreach (Transform t in transform) {
                 
                 //fill the array our models
                 for (int i = 0; i < transform.childCount; i++) {
 
                     characterList [i] = transform.GetChild (i).gameObject;
                 }
 
                 //we toggle of their renderer
             
                 foreach (GameObject go in characterList) {
                 
                     go.SetActive (false);
                 }
 
                 //toggle on the selected character
                 if (characterList [index])
                     characterList [index].SetActive (true);
             
 
 
 
             }
 
     } //Start function end
 
     
         public void ToggleBack(){
 
             SceneManager.LoadScene ("GTGD S3");
 
         }
     
 
         public void ToggleLeft(){
 
             characterList [index].SetActive (false);
             index--;
 
             if (index < 0) {
 
                 index = characterList.Length - 1;
             }
             characterList [index].SetActive (true);
         } // Toggle Left End
 
         public void ToggleRight(){
 
             characterList [index].SetActive (false);
             index++;
 
             if (index == characterList.Length) {
 
                 index =0;
             }
             characterList [index].SetActive (true);
         }
 
 
         public  void  ConfirmButton(){
 
             PlayerPrefs.SetInt ("CharacterSelected", index);
             SceneManager.LoadScene ("LevelTry");
                 if (index == 0) {
                 
                   isFire = true;
                 Debug.LogFormat ("Fire");
 
             } else if (index == 1) {
                 
 
                     isWater = true;
                     Debug.LogFormat ("Water");
 
                 } else if (index == 2) {
                 
 
                 isEarth = true;
                     Debug.LogFormat ("Earth");
 
                 } else if (index == 3) {
 
                 isWood = true;
                 Debug.LogFormat ("Wood");
 
 
             }
         }
 }
 }

And , my secondary script

 using UnityEngine;
 using System.Collections;
 using UnityEngine.EventSystems;
 
 namespace S3{
 
     public class ArenaBackground : MonoBehaviour {
         
         public  CharacterSelection arenaBG;
 
     
 
     // Use this for initialization
     void Start () {
 
         arenaBG = gameObject.AddComponent<CharacterSelection>();
 
 
             if (arenaBG.isFire) {
             
                 Debug.LogFormat ("Yes !");
             }
             else{
                     Debug.LogFormat("No !");
             }
 
         } 
 }
 }

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Pengocat · Dec 13, 2016 at 01:41 AM

If you call ConfirmButton() isFire would be set to true by default and the rest to false. Since it is a public method and you add CharacterSelection while storing a reference in ArenaBackground you should be able to call the method.

Comment
Add comment · Show 1 · Share
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
avatar image leralonde · Dec 14, 2016 at 02:43 AM 0
Share

hi , firstly thank you for answer.

I called ConfirmButton() in ArenaBackground ( in void Start() )

but all time (true or false) run " Debug.LogFormat ("Yes !"); "

i make a big mistake but i don't see this.

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

275 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Why does my Gem counter not work? (screenshot included for explanation / easy code) 1 Answer

I'm trying to make the collision work. But... 2 Answers

Automatic Switching of two or more booleans in Inspector 1 Answer

Is there a way to "Dubug.Log" which gameobject called a certain function? 3 Answers

Reading a var from variable parents 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