Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

SOLVED Thanks...

Discussion in 'Scripting' started by latasever8, Apr 28, 2020.

  1. latasever8

    latasever8

    Joined:
    Jun 22, 2019
    Posts:
    16
    I have a code of growing score and it is standing in Canvas.
    I want to make a button in Canvas and when I click this button, integer must be decreasing.

    Here is a code for creasing score

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class sayıart : MonoBehaviour {
    6.     public int sayi = 0;
    7.     // Use this for initialization
    8.     void Start () {
    9.        
    10.     }
    11.    
    12.     void OnGUI()
    13.     {
    14.         GUI.Label (new Rect (90, 306, 100, 20), "Tahta:" + sayi);
    15.     }
    16. }
    17.  
    18.  
    please help, thank you
     
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    You're using the old UI in this code. You should start by following a tutorial for the current UI.
     
  3. latasever8

    latasever8

    Joined:
    Jun 22, 2019
    Posts:
    16
    actually I dont know which is new which is old....
     
  4. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    If you see OnGUI, you're looking at the ancient UI from before Unity 4.6. Any 3rd party UI tutorials created after November 2014 should be using the current system, as well as any tutorial from Unity itself.
     
    Kurt-Dekker likes this.
  5. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,970
    And adding to Uncle Joe above, code that accesses the Unity UI usually must have a
    using UnityEngine.UI;
    line at the top. That namespace is all the modern UI.