- Home /
Call C# function from within as3?
Hi! I have as3 class. I want to call C# function. Doing something like:
import global.MyClass
... _myClass.MoveMouse()
produced errors.
I have example on how to sent whole Object from as3 to Unity, but I don't need that. I just want to sent mouse position from as3 to my Unity function like MouseMove(2,2)
Thanks!
Answer by catburton · Aug 14, 2012 at 10:31 AM
It's hard to see what your exact issue is without a copy of the source or your errors.
Without seeing your project, the first thing I'd say to check is that your C# class uses the [NotRenamed] attribute for the class/functions. This will ensure they have the same names when converted to AS3 at build time.
What is the reason for getting the mouse position in AS3 and returning that to C#? Can you not just make use of the Input.mousePosition value directly in your C# class?
http://docs.unity3d.com/Documentation/ScriptReference/Input-mousePosition.html
I've attached a demo project which shows the Input.mousePosition value working for Flash export. If you build this project for Flash, you should see a texture following the mouse cursor.
Your answer
Follow this Question
Related Questions
C# Script interaction between separate locations 1 Answer
A node in a childnode? 1 Answer
Distribute terrain in zones 3 Answers
Multiple Cars not working 1 Answer