I’m trying to make an independence that would let me affect with other game object (and whatever component in that)
As i know the UI component Button have a very neat Onclick that let you affect with other game object (and whatever component in that) ,so i wonder whether i can make use of that.,whether it is inherit,interface or just simply plain script text that would do the same
Yeah,i would love to have that red part in my independence script,thank in advance
I think this answers your question.
Attach to your UI object this line:
if (Input.OnMouseDown())
//Do stuff
Or you could add in the click event itself
gameObject.AddListener(OnMouseClick());
void OnMouseClick(){
//do stuff
}
If you add a public UnityEvent member to your monobehavior script, you will see, in the editor, a UI for the variable, that is very similar to OnClick.
e.g.
public UnityEvent customCallback;
To call the function(s) specified in this control, use “Invoke”
customCallback.Invoke();
If this is what your looking for, more details can be found in this forum thread: https://forum.unity3d.com/threads/how-to-select-a-callback-function-for-your-script-from-the-editor.295550/#post-2227483