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 GoooS · Aug 30, 2016 at 02:59 PM · 2dgui2d gameupdate problemstrings

Problem with Strings updatings on Gui

Hi i have problem with Strings In my "Game" they aren update correctly. Here is code and some snaps , And also the You Lost/You Lose text arent switching their's visibility to active from the sript... Debugs are working fine for me. Im a noobbut rly tried everyting to make it act like it should. funny Staff is whe i was using the same script ina 3d game it worked perfectly :S. Waiting for your's Respond.

using UnityEngine; using System.Collections; using UnityEngine.UI; using System.Collections.Generic;

public class Gamemenager : MonoBehaviour { public int lifes = 3; public int bricks = 0; public int points = 0; public float resetDelay =1f ; public Text BallsCount; public Text Points; public GameObject Ball; public GameObject Roof; public GameObject Bonus; public GameObject YouWon; public GameObject YouLost; public List bricksPrefabs; public GameObject Paddle; public GameObject deathParticles; private Ball ball; public static Gamemenager instance = null; private GameObject clonePaddle; private GameObject cloneBall; public GameObject DamangedBrickRed;

 // chceks is there allready eny instance startet if so it will destroy coppies
 void Start()
 {
     if (instance == null)
         instance = this;
     else if (instance != null)
         Destroy(gameObject); 

     Setup();
 }
 // Spawn map objects
 public void Setup()
 {

     clonePaddle = Instantiate(Paddle, transform.position, Quaternion.identity) as GameObject;
     clonePaddle.transform.SetParent(Roof.transform);
     cloneBall = Instantiate(Ball, transform.position, Quaternion.identity) as GameObject;
     cloneBall.transform.SetParent(Roof.transform);
     RandomBlocks();
     BallsCount.text = "Balls: " + lifes.ToString();
     Points.text = "Points: " + points.ToString();
     //ball = GameObject.Find("Ball").gameObject.GetComponent<Ball>();


 }
 // Chceks game over
 public void ChceckGameOver()
 {
     if (bricks == 0)
     {
         YouWon.SetActive(true);
         Time.timeScale = .20f;
         Invoke("Reset", resetDelay);
     }

     if (lifes == 0)
     {
         Debug.Log("Koniec!");
         YouLost.SetActive(true);
         Time.timeScale = .20f;
         Invoke("Reset", resetDelay);
     }
 }

 private List<Vector2> vectors = new List<Vector2>();
 // Random Bricks generator
 private void RandomBlocks()
 {
     int n = 40;
     bricks = n;
     while (n > 0)
     {
         bool allow = true;
         Vector2 vec = new Vector2(Random.Range(-400, 250) *1.6f, Random.Range(-100, 207) *1.6f);
         foreach (Vector2 v in vectors)
         {
             if (v == vec)
             {
                 allow = false;
             }
         }

         if (allow == true)
         {
             vectors.Add(vec);
             GameObject Go = Instantiate(bricksPrefabs[Random.Range(0, bricksPrefabs.Count)], vec, Quaternion.identity) as GameObject;
             Go.transform.SetParent(Roof.transform);
             n--;
         }
     }

     foreach (Vector2 v in vectors)
         Debug.Log(v);
     

     Debug.Log("#############");
 }

 // Resets Level
 void Reset()
 {
     Time.timeScale = 1f;
     Application.LoadLevel(Application.loadedLevel);
 }

 //loose life

 public void LoseLife()
 {
     lifes--;
     BallsCount.text = "Balls: "+lifes.ToString();
     Instantiate(deathParticles, clonePaddle.transform.position, Quaternion.identity);
     Destroy(clonePaddle);
     Invoke("SetupPaddle", resetDelay);
     ChceckGameOver();
 }
 void SetupPaddle()
 {
     clonePaddle = Instantiate(Paddle, transform.position, Quaternion.identity) as GameObject;
     clonePaddle.transform.SetParent(Roof.transform);
     cloneBall = Instantiate(Ball, transform.position, Quaternion.identity) as GameObject;
     cloneBall.transform.SetParent(Roof.transform);
 }
 public void DestroyBricksGreen()
 {
     Debug.Log("pkt");
     bricks--;
     points += 10; 
     Points.text = "Points: " + points.ToString();
     ChceckGameOver();
 }
 public void DestroyBricksRed()
 {
     bricks--;
     points += 20;
     Points.text = "Points: " + points.ToString();
     ChceckGameOver();
 }
 public void DestroyBricksBlue()
 {
     bricks--;
     points += 5;
     Points.text = "Points: " + points.ToString();
     ChceckGameOver();
 }
 public void DamangeBricksRed()
 {
     points += 5;
     Points.text = "Points: " + points.ToString();
 }

 public void BonusPoints()
 {
     points += 5;
     Points.text = "Points: " + points.ToString();
 }
 public void Update()
 {
     Points.text = "Points: " + points.ToString();
     BallsCount.text = "Balls: " + lifes.ToString();
 }

}

![alt text][1]

dont-update.png (303.0 kB)
dont-update.png (303.0 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

121 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

Related Questions

Music playing from 2 different scenes - how to fix? 1 Answer

Is there an order in the "Layers" tab? 0 Answers

Is it possible to get a number of pre-set hashtags per minute from twitter? 0 Answers

Game Object Drop 0 Answers

How to create 2D destructible terrain? 0 Answers


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