Targeting Unity3d Platform

Installation


haxelib install unity3d

Compile project example

haxe -main Main -cp src -cs bin -D no-compilation -lib unity3d {+required classes}

And then, use the .cs files in the unity3d editor

Tips and Tricks

You can use FlashDevelop-HaXe-Projects-Templates
https://github.com/AxGord/FlashDevelop-HaXe-Projects-Templates

You can use .NET Library for additional function
https://github.com/AxGord/hx-dotnet

Example

package ;
import unityEngine.MonoBehaviour;
import unityEngine.Time;
import unityEngine.Vector3;
import unityEngine.GameObject;
using UnityHelper;
class MyClass extends MonoBehaviour {
    private var target:GameObject;
    private var speed:Single;
    private function Start():Void {
        speed = 5;
        if (target == null) target = GameObject.Find('/Target');
    }
    private function Update():Void {
        if (speed == 0) return;
        getTransform().position = Vector3.MoveTowards(getTransform().position, target.transform.position, Time.deltaTime * speed);
    }
}

Manual

http://docs.unity3d.com/Documentation/ScriptReference/20_class_hierarchy.html

version #15847, modified 2013-01-10 12:48:25 by axg