- Home /
Question by
Daniel_Rod · Apr 06, 2020 at 02:10 AM ·
sendmessage
I am trying to send a int in between gameobjects
My code is:
using UnityEngine;
public class PianoKey1 : MonoBehaviour { void Start() { gameObject.SendMessage("KeyPressed", 1); } }
using UnityEngine;
public class WaveBar1 : MonoBehaviour { public void KeyPressed(int keyID) { print(keyID); } }
Comment
Answer by BBIT-SOLUTIONS · Apr 06, 2020 at 02:24 AM
In Unity you usually do something like that by either using public variables or public functions.
I guess the first answer in this thread could help you.
Your answer
Follow this Question
Related Questions
Help With Homing Missiles - Annoying! 3 Answers
The function SendMessage in js can not return values? 0 Answers
SendMessage with multiple parameters 3 Answers
SendMessage() to inactive object? 3 Answers