Quantcast
Channel: Unity Forum
Viewing all articles
Browse latest Browse all 1466670

Which is better practice? or what are their pros and cons?

$
0
0
Say I want to script a toggle UI to do something in another GameObject:

1: use the inspector of the toggle and drag myGameObject into the OnValueChanged window of the toggle's inspector to call a static method in myGameObject to change a private field or do some actions
2: create a public toggle "myToggle" in the script of myGameObject and then use drag'n drop in myGameObject's script inspector to reference it and use myToggle.OnValueChanged.AddListener and delegates to call a method to do...

Which is better practice? or what are their pros and cons?

Viewing all articles
Browse latest Browse all 1466670

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>