- Home /
small example sendmessage from javascript to C# wrong???
I tried to search and read many ways to access variable from javascript to C# I tried this compile
However I get no result. Here is my process:
First, I create new Project
Second, I create folder Plugins
Third, I create 1 C# script called "Cshape"
using UnityEngine; using System.Collections;
public class Cshape : MonoBehaviour {
void ApplyDamage(float damage) {
print ("a"); } }
and 1 Java script called "Java"
function Update(){ GameObject.SendMessage ("ApplyDamage", 5.0); }
How can I call the function ApplyDamage from Cshape script? Thanks for any help Regards.
Yes, of course, and I put 2 scripts into the folder "Plugins" but it not work :( Can someone help me?
Answer by superstar123 · Jul 15, 2011 at 01:02 PM
OK I find the solution here, the JavaScript "Java" should be like this :
function Update() { gameObject.Find("NameOfObjectAttatchThisScript ").GetComponent("Cshape").SendMessage ("ApplyDamage", 5.0);
}
yup, this should work, just create the object with name "NameOfObjectAttatchThisScript" :p
Your answer
Follow this Question
Related Questions
Problem - Access several Javascripts in C# 0 Answers
Help converting this to C# - a few issues 3 Answers
java to C# conversion 1 Answer
Converting a javascript to C# 2 Answers
converting javascript to c# 1 Answer