- Home /
Question by
dansav · Aug 16, 2012 at 04:53 PM ·
javascriptfunction
anonymous function in unityscript?
I'm translating some code from csharp to unityscript and I've run into this. Is there any way to do an anonymous function in unityscript?
// add some event handlers
_videoTexture.videoDidStartEvent = () =>
{
Debug.Log( "Video one started" );
};
_videoTexture.videoDidFinishEvent = () =>
{
// when the video finishes if we are not set to loop this instance is no longer valid
Debug.Log( "Video one finished" );
};
Comment
Wiki
Answer by lpye · Aug 16, 2012 at 07:47 PM
IIRC, you can do:
_videoTexture.videoDidStartEvent = function()
{
Debug.Log("Video one started");
};
_videoTexture.videoDidFinishEvent = function()
{
// when the video finishes if we are not set to loop this instance is no longer valid
Debug.Log("Video one finished");
};
Your answer
Follow this Question
Related Questions
anonymous functions with JavaScript? 2 Answers
Performance Optimization ~Function Update: Loop or Once ? 5 Answers
Can eval() declare functions (such as Update()) 0 Answers
Nested Functions 1 Answer
adding multiple values to single function/variable. 0 Answers