setting a variable to refer to script or equivalent C#
Hello my friends, let's say i have a gameobject which gets utilised in multiple separate scenes. Each scene needs a different script on this gameobject but they're all basically variants of the same thing (all GUI stuff, etc.). I know i can check if a gameobject has a specific component (script) but am i able to detect that one of the scripts is utilised and then set a variable or something to refer to that script. For example: Component theScript; if (GetComponent<script1>() != null){ //thescript = script1 } else { //thescript = script2 } thescript.sendmessage ("heya");
all i need to do is send messages as well. can anyone help? thanks.
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612142740im_/https://answers.unity.com/themes/thub/images/avi.jpg)