gtag('config', 'UA-180278623-1'); Unity 3D C# Temelleri (PUBLİC AND PRİVATE) - Bilginiz Dahilinde

Ads Top

Unity 3D C# Temelleri (PUBLİC AND PRİVATE)

PUBLİC AND PRİVATE:

PUBLİC AND PRİVATE:


1)public

public class HelloWorld : MonoBehaviour

{

    public int sayi = 18;

    public int sayi2 = 20;

    int sonuc;

// Start is called before the first frame update

  

 void Start()

    {

        sonuc = sayi + sayi2;

        print(sonuc);

    }

 

    // Update is called once per frame

    void Update()

    {

       

    }

}

 

2)private

public class HelloWorld : MonoBehaviour

{

    private int sayi = 18;

    private int sayi2 = 20;

    private int sonuc;

 

 // Start is called before the first frame update

    void Start()

    {

        sonuc = sayi + sayi2;

        print(sonuc);

    }

 

    // Update is called once per frame

    void Update()

    {

    }

}

                         Private ve Public Arasındaki Fark :

     UNİTY EDİTOR KISMINDAN DEĞİŞKENİN DEĞERLERİNİ DEĞİŞTİRMEK İSTİYORSAK PUBLİC KULLANMALIYIZ.
     UNİTY EDİTOR KISMINDAN DEĞİŞKENİN DEĞERLERİNİ DEĞİŞTİRMEK İSTEMİYORSAK PRİVATE
KULLANMALIYIZ.  

Hiç yorum yok:

Blogger tarafından desteklenmektedir.