protected virtual void RegisterClasses(Puerts.JsEnv env) { env.UsingAction <int>(); env.UsingAction <float>(); env.UsingAction <string>(); env.UsingAction <string, string>(); }
public static void Register(Puerts.JsEnv jsEnv) { jsEnv.AddLazyStaticWrapLoader(typeof(UnityEngine.Debug), UnityEngine_Debug_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(UnityEngine.Vector3), UnityEngine_Vector3_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(UnityEngine.Time), UnityEngine_Time_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(UnityEngine.Transform), UnityEngine_Transform_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(UnityEngine.Component), UnityEngine_Component_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(UnityEngine.GameObject), UnityEngine_GameObject_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(System.Delegate), System_Delegate_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(System.Object), System_Object_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(System.Type), System_Type_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(UnityEngine.ParticleSystem), UnityEngine_ParticleSystem_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(UnityEngine.Canvas), UnityEngine_Canvas_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(UnityEngine.Behaviour), UnityEngine_Behaviour_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(UnityEngine.Object), UnityEngine_Object_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(UnityEngine.Resources), UnityEngine_Resources_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(UnityEngine.UI.Button), UnityEngine_UI_Button_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(UnityEngine.UI.Button.ButtonClickedEvent), UnityEngine_UI_Button_ButtonClickedEvent_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(UnityEngine.Events.UnityEvent), UnityEngine_Events_UnityEvent_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(UnityEngine.Renderer), UnityEngine_Renderer_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(UnityEngine.MeshRenderer), UnityEngine_MeshRenderer_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(UnityEngine.Material), UnityEngine_Material_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(UnityEngine.Color), UnityEngine_Color_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(UnityEngine.Color32), UnityEngine_Color32_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(UnityEngine.AudioSource), UnityEngine_AudioSource_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(UnityEngine.AudioClip), UnityEngine_AudioClip_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(MonoSingleton <JsManager>), MonoSingleton_1_JsManager__Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(JsManager), JsManager_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(JsBehaviour), JsBehaviour_Wrap.GetRegisterInfo); }
public static void AutoUsing(this JsEnv jsEnv) { jsEnv.UsingAction <System.Boolean>(); jsEnv.UsingAction <System.Boolean, System.Boolean, System.Int32>(); jsEnv.UsingAction <System.Int32>(); jsEnv.UsingAction <System.Int32, System.Int32>(); jsEnv.UsingAction <System.Int32, System.Int32, System.Int32>(); jsEnv.UsingAction <System.Int32, System.Net.WebHeaderCollection>(); jsEnv.UsingAction <System.IntPtr, Puerts.ISetValueToJs, System.IntPtr, System.Object>(); jsEnv.UsingAction <System.String, System.Boolean, System.String>(); jsEnv.UsingAction <System.String, System.String, UnityEngine.LogType>(); jsEnv.UsingAction <UnityEngine.CullingGroupEvent>(); jsEnv.UsingAction <UnityEngine.ReflectionProbe, UnityEngine.ReflectionProbe.ReflectionProbeEvent>(); jsEnv.UsingAction <UnityEngine.SceneManagement.Scene>(); jsEnv.UsingAction <UnityEngine.SceneManagement.Scene, UnityEngine.SceneManagement.LoadSceneMode>(); jsEnv.UsingAction <UnityEngine.SceneManagement.Scene, UnityEngine.SceneManagement.Scene>(); jsEnv.UsingFunc <IEnumeratorUtil.Tick>(); jsEnv.UsingFunc <System.Boolean>(); jsEnv.UsingFunc <System.Exception, System.Boolean>(); jsEnv.UsingFunc <System.Int32, System.Boolean>(); jsEnv.UsingFunc <System.Int32, System.Int32, System.Int32>(); jsEnv.UsingFunc <System.IntPtr, Puerts.IGetValueFromJs, System.IntPtr, System.Boolean, System.Object>(); jsEnv.UsingFunc <System.Net.HttpListenerRequest, System.Net.AuthenticationSchemes>(); jsEnv.UsingFunc <System.Net.ServicePoint, System.Net.IPEndPoint, System.Int32, System.Net.IPEndPoint>(); jsEnv.UsingFunc <System.Object, System.Security.Cryptography.X509Certificates.X509Certificate, System.Security.Cryptography.X509Certificates.X509Chain, System.Net.Security.SslPolicyErrors, System.Boolean>(); jsEnv.UsingFunc <System.Reflection.Assembly, System.String, System.Boolean, System.Type>(); jsEnv.UsingFunc <System.Reflection.MemberInfo, System.Object, System.Boolean>(); jsEnv.UsingFunc <System.String, System.Int32, System.Char, System.Char>(); jsEnv.UsingFunc <System.Type, System.Object, System.Boolean>(); jsEnv.UsingFunc <UnityEngine.UI.ILayoutElement, System.Single>(); }
public static void Register(Puerts.JsEnv jsEnv) { jsEnv.AddLazyStaticWrapLoader(typeof(UnityEngine.Debug), UnityEngine_Debug_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(UnityEngine.Vector3), UnityEngine_Vector3_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(System.Collections.Generic.List <int>), System_Collections_Generic_List_1_System_Int32__Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(UnityEngine.Time), UnityEngine_Time_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(UnityEngine.Transform), UnityEngine_Transform_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(UnityEngine.Component), UnityEngine_Component_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(UnityEngine.GameObject), UnityEngine_GameObject_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(UnityEngine.Object), UnityEngine_Object_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(System.Delegate), System_Delegate_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(System.Object), System_Object_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(System.Type), System_Type_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(UnityEngine.ParticleSystem), UnityEngine_ParticleSystem_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(UnityEngine.Canvas), UnityEngine_Canvas_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(UnityEngine.Behaviour), UnityEngine_Behaviour_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(UnityEngine.MonoBehaviour), UnityEngine_MonoBehaviour_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(UnityEngine.EventSystems.UIBehaviour), UnityEngine_EventSystems_UIBehaviour_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(UnityEngine.UI.Selectable), UnityEngine_UI_Selectable_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(UnityEngine.UI.Button), UnityEngine_UI_Button_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(UnityEngine.UI.Button.ButtonClickedEvent), UnityEngine_UI_Button_ButtonClickedEvent_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(UnityEngine.Events.UnityEvent), UnityEngine_Events_UnityEvent_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(UnityEngine.UI.InputField), UnityEngine_UI_InputField_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(UnityEngine.UI.Toggle), UnityEngine_UI_Toggle_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(UnityEngine.UI.Toggle.ToggleEvent), UnityEngine_UI_Toggle_ToggleEvent_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(UnityEngine.Events.UnityEvent <bool>), UnityEngine_Events_UnityEvent_1_System_Boolean__Wrap.GetRegisterInfo); }
public static void Register(Puerts.JsEnv jsEnv) { jsEnv.AddLazyStaticWrapLoader(typeof(PuertsTest.PhyWorld), PuertsTest_PhyWorld_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(PuertsTest.CameraControl), PuertsTest_CameraControl_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(PuertsTest.GameManager), PuertsTest_GameManager_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(PuertsTest.ShellExplosion), PuertsTest_ShellExplosion_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(PuertsTest.TankHealth), PuertsTest_TankHealth_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(PuertsTest.TankManager), PuertsTest_TankManager_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(PuertsTest.TankMovement), PuertsTest_TankMovement_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(PuertsTest.TankShooting), PuertsTest_TankShooting_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(PuertsTest.UIDirectionControl), PuertsTest_UIDirectionControl_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(UnityEngine.Mathf), UnityEngine_Mathf_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(UnityEngine.Debug), UnityEngine_Debug_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(UnityEngine.Vector3), UnityEngine_Vector3_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(System.Collections.Generic.List <int>), System_Collections_Generic_List_1_System_Int32__Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(System.Array), System_Array_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(System.Collections.Generic.Dictionary <string, System.Collections.Generic.List <int> >), System_Collections_Generic_Dictionary_2_System_String_System_Collections_Generic_List_1_System_Int32___Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(UnityEngine.Time), UnityEngine_Time_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(UnityEngine.Transform), UnityEngine_Transform_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(UnityEngine.Component), UnityEngine_Component_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(UnityEngine.GameObject), UnityEngine_GameObject_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(UnityEngine.Object), UnityEngine_Object_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(System.Delegate), System_Delegate_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(System.Object), System_Object_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(System.Type), System_Type_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(UnityEngine.ParticleSystem), UnityEngine_ParticleSystem_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(UnityEngine.ParticleSystem.MainModule), UnityEngine_ParticleSystem_MainModule_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(UnityEngine.Canvas), UnityEngine_Canvas_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(UnityEngine.Behaviour), UnityEngine_Behaviour_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(UnityEngine.MonoBehaviour), UnityEngine_MonoBehaviour_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(UnityEngine.Camera), UnityEngine_Camera_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(System.DateTime), System_DateTime_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(System.TimeSpan), System_TimeSpan_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(UnityEngine.BoxCollider), UnityEngine_BoxCollider_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(UnityEngine.Physics), UnityEngine_Physics_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(UnityEngine.Rigidbody), UnityEngine_Rigidbody_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(UnityEngine.AudioSource), UnityEngine_AudioSource_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(UnityEngine.Input), UnityEngine_Input_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(UnityEngine.ColorUtility), UnityEngine_ColorUtility_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(UnityEngine.MeshRenderer), UnityEngine_MeshRenderer_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(UnityEngine.Resources), UnityEngine_Resources_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(UnityEngine.Application), UnityEngine_Application_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(WeChat.PuertsBeefBallBehaviour), WeChat_PuertsBeefBallBehaviour_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(PuertsBeefBallSDK.Prefab), PuertsBeefBallSDK_Prefab_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(PuertsBeefBallSDK.RemoteResource), PuertsBeefBallSDK_RemoteResource_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(UnityEngine.EventSystems.UIBehaviour), UnityEngine_EventSystems_UIBehaviour_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(UnityEngine.UI.Selectable), UnityEngine_UI_Selectable_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(UnityEngine.UI.Button), UnityEngine_UI_Button_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(UnityEngine.UI.Button.ButtonClickedEvent), UnityEngine_UI_Button_ButtonClickedEvent_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(UnityEngine.Events.UnityEvent), UnityEngine_Events_UnityEvent_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(UnityEngine.UI.InputField), UnityEngine_UI_InputField_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(UnityEngine.UI.Toggle), UnityEngine_UI_Toggle_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(UnityEngine.UI.Toggle.ToggleEvent), UnityEngine_UI_Toggle_ToggleEvent_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(UnityEngine.Events.UnityEvent <bool>), UnityEngine_Events_UnityEvent_1_System_Boolean__Wrap.GetRegisterInfo); }
public static void UsingGeneric(this JsEnv jsEnv, bool usingAction, params Type[] types) { var name = usingAction ? "UsingAction" : "UsingFunc"; var count = types.Length; var method = (from m in typeof(JsEnv).GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) where m.Name.Equals(name) && m.IsGenericMethod && m.GetGenericArguments().Length == count select m).FirstOrDefault(); if (method == null) { throw new Exception("Not found method: '" + name + "', ArgsLength=" + count); } method.MakeGenericMethod(types).Invoke(jsEnv, null); }
protected virtual void RegisterClasses(Puerts.JsEnv vm) { vm.UsingAction <int>(); vm.UsingAction <float>(); vm.UsingAction <string>(); vm.UsingAction <bool>(); vm.UsingFunc <int>(); vm.UsingFunc <float>(); vm.UsingFunc <string>(); vm.UsingFunc <bool>(); vm.UsingAction <string, string>(); vm.UsingAction <Vector3>(); vm.UsingFunc <Vector3>(); vm.UsingAction <UnityEngine.SceneManagement.Scene, UnityEngine.SceneManagement.LoadSceneMode>(); vm.UsingAction <UnityEngine.SceneManagement.Scene, UnityEngine.SceneManagement.Scene>(); vm.UsingAction <UnityEngine.AsyncOperation>(); }
protected virtual async System.Threading.Tasks.Task StartJavaScript() { DontDestroyOnLoad(gameObject); inst = this; // 创建JS虚拟机 loader = new JavaScriptLoader(DebuggerRoot); vm = new Puerts.JsEnv(loader, DebuggerPort); this.RegisterClasses(vm); if (WaitForDebugger) { await vm.WaitDebuggerAsync(); } // 加载启动JS脚本, 执行脚本 main 函数 var javascript_main = vm.Eval <JavaScriptMain>("require('bootstrap.js');", loader.GetScriptDebugPath("bootstrap.js")); javascript_main(this); }
protected virtual void StartJavaScript() { DontDestroyOnLoad(gameObject); if (inst) { throw new Exception("无法启动 JavaScript 虚拟机"); } inst = this; // 创建JS虚拟机 loader = new JavaScriptLoader(DebuggerRoot); env = new Puerts.JsEnv(loader, DebuggerPort); this.RegisterClasses(env); if (WaitForDebugger) { env.WaitDebugger(); } // 加载启动JS脚本, 执行脚本 main 函数 var javascript_main = env.Eval <JavaScriptMain>("require('bootstrap.js');", loader.GetScriptDebugPath("anonymous.js")); javascript_main(this); }
public static void Register(Puerts.JsEnv jsEnv) { jsEnv.AddLazyStaticWrapLoader(typeof(System.Type), System_Type_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(TestClass), TestClass_Wrap.GetRegisterInfo); jsEnv.AddLazyStaticWrapLoader(typeof(PuertsTest.JsBehaviour), PuertsTest_JsBehaviour_Wrap.GetRegisterInfo); }
public static void Register(Puerts.JsEnv jsEnv) { jsEnv.AddLazyStaticWrapLoader(typeof(Puerts.UnitTest.OptionalParametersClass), Puerts_UnitTest_OptionalParametersClass_Wrap.GetRegisterInfo); }
protected override void RegisterClasses(Puerts.JsEnv env) { base.RegisterClasses(env); // TODO: 在这里注册你需要的 }
public static void UsingFunc(this JsEnv jsEnv, params string[] args) { jsEnv.UsingGeneric(false, FindTypes(args)); }
public static void UsingAction(this JsEnv jsEnv, params string[] args) { jsEnv.UsingGeneric(true, FindTypes(args)); }
protected override void RegisterClasses(Puerts.JsEnv vm) { base.RegisterClasses(vm); // TODO: 在此注册C#回调函数 }