maxhacker11

Function Call In Another Script

Sep 10th, 2023
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.48 KB | Source Code | 0 0
  1. //This is not the actual script used in the video, it's just a few lines that I extracted so you can copy/paste them if needed.
  2.  
  3. //Finding the game object by name, then accessing the component:
  4. GameObject.Find("ObjectB").GetComponent<ScriptB>();
  5.  
  6. //Finding the game object by tag, then accessing the component:
  7. GameObject.FindWithTag("ObjectBTag").GetComponent<ScriptB>();
  8.  
  9. //Finding the first game object that has this script attached to it:
  10. GameObject.FindObjectOfType<ScriptB>();
Advertisement
Add Comment
Please, Sign In to add comment