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?
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?