public void Init() { if (bHaveInit) { return; } bHaveInit = true; //获取项目中所有继承了初始化接口的类型 foreach (var typeInitializer in CSharpTools.GetType(typeof(IAudioMgrInitializer))) { try { IAudioMgrInitializer initializer = Activator.CreateInstance(typeInitializer) as IAudioMgrInitializer; initializer?.InitAudioMgr(this); } #if !UNITY_EDITOR catch (System.Exception) { } #else catch (System.Exception e) { Debug.Log("AudioMgr Init Error : " + e); } #endif } }
public void LocalDownLoadImage(string url, LuaFunction callback, bool isCache) { using (WWW www = new WWW(url)) { while (!www.isDone) { } if (www.error != null) { callback.Call(false, url); } else { Texture2D texture = www.texture; Sprite sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f)); callback.Call(true, sprite); if (isCache) { string hash = CSharpTools.md5(url); string path = Application.persistentDataPath + "/" + hash + ".png"; byte[] bytes = texture.EncodeToPNG(); File.WriteAllBytes(path, bytes); } } } }
static int cleanCache(IntPtr L) { try { ToLua.CheckArgsCount(L, 0); CSharpTools.cleanCache(); return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int GetOSTime(IntPtr L) { try { ToLua.CheckArgsCount(L, 0); long o = CSharpTools.GetOSTime(); LuaDLL.tolua_pushint64(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int getFileHash(IntPtr L) { try { ToLua.CheckArgsCount(L, 1); string arg0 = ToLua.CheckString(L, 1); string o = CSharpTools.getFileHash(arg0); LuaDLL.lua_pushstring(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int StandardY(IntPtr L) { try { ToLua.CheckArgsCount(L, 1); float arg0 = (float)LuaDLL.luaL_checknumber(L, 1); float o = CSharpTools.StandardY(arg0); LuaDLL.lua_pushnumber(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int IsPointerOverUIObject(IntPtr L) { try { ToLua.CheckArgsCount(L, 1); UnityEngine.Vector2 arg0 = ToLua.ToVector2(L, 1); bool o = CSharpTools.IsPointerOverUIObject(arg0); LuaDLL.lua_pushboolean(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int ToBezierLinePoints(IntPtr L) { try { ToLua.CheckArgsCount(L, 2); System.Collections.Generic.List <UnityEngine.Vector3> arg0 = (System.Collections.Generic.List <UnityEngine.Vector3>)ToLua.CheckObject(L, 1, typeof(System.Collections.Generic.List <UnityEngine.Vector3>)); int arg1 = (int)LuaDLL.luaL_checknumber(L, 2); System.Collections.Generic.List <UnityEngine.Vector3> o = CSharpTools.ToBezierLinePoints(arg0, arg1); ToLua.PushSealed(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int GetTowPointAngle(IntPtr L) { try { ToLua.CheckArgsCount(L, 2); UnityEngine.Vector3 arg0 = ToLua.ToVector3(L, 1); UnityEngine.Vector3 arg1 = ToLua.ToVector3(L, 2); float o = CSharpTools.GetTowPointAngle(arg0, arg1); LuaDLL.lua_pushnumber(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
public void LoadAndCacheImage(string url, LuaFunction callback, bool isCache = true) { string hash = CSharpTools.md5(url); string path = Application.persistentDataPath + "/" + hash + ".png"; if (File.Exists(path)) { string wwwPath = "file://" + path; StartCoroutine(LoadImageFromPath(url, callback)); } else { StartCoroutine(DownLoadImage(url, callback, isCache)); // LocalDownLoadImage(url, callback, false); } }
static int _CreateCSharpTools(IntPtr L) { try { int count = LuaDLL.lua_gettop(L); if (count == 0) { CSharpTools obj = new CSharpTools(); ToLua.PushObject(L, obj); return(1); } else { return(LuaDLL.luaL_throw(L, "invalid arguments to ctor method: CSharpTools.New")); } } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
public void DownloadAPK(string url, string md5) { string hash = CSharpTools.md5(url); string path = Application.persistentDataPath + "/" + hash + ".apk"; APKPath = path; // 如果已经下载完了就安装,没有就重新下载 if (File.Exists(APKPath)) { if (CSharpTools.getFileHash(APKPath) == md5) { InstallAPK(APKPath); } else { StartCoroutine(StatrtDownloadAPK(url, md5)); } } else { StartCoroutine(StatrtDownloadAPK(url, md5)); } }
public unsafe static void Test() { DataPacket dataPacket = new DataPacket(); Console.WriteLine(CSharpTools.GetObjectSize(dataPacket)); }
public static async Task SendNewVerifyMailAsync() { VerifyeMail verifyeMail = new VerifyeMail("验证码", CSharpTools.CreateUUID().ToString(), "", null, "*****@*****.**"); await TaskCore.Run(verifyeMail); }