活动介绍

using UnityEngine; using System; using System.Collections; //using System.Collections.Generic; using XLua; namespace LuaFramework { [LuaCallCSharp] public class ResourceManager : Manager { public static ResourceManager _instance; public LuaFunction onDestroy; private WWW _www; private LuaFunction onProgress; void Awake() { _instance = this; } public static ResourceManager Instance { get { return _instance; } } public void CreatUIObject(string UIPath, string objname, LuaFunction callBack = null) { #if UNITY_EDITOR if (!AppConst.UpdateMode) { string path = "datingui_" + AppConst.UIVersion.ToString() + "/" + UIPath + objname; UnityEngine.Object prefab = Resources.Load(path, typeof(GameObject)); if (prefab != null) { //GameObject obj = Instantiate(Resources.Load<GameObject>(path)); //if (obj != null) //{ GameObject obj = Instantiate(prefab) as GameObject; obj.transform.localScale = Vector3.one; obj.transform.localPosition = Vector3.zero; if (callBack != null) { callBack.Call(obj); } //} }else { if (callBack != null) { callBack.Call(null); } } }else { StartCoroutine(LoadObj(AppConst.FrameworkRoot + "/datingui_" + AppConst.UIVersion + "/" + UIPath + objname + ".u3d", objname, callBack)); } #else StartCoroutine(LoadObj(AppConst.FrameworkRoot + "/datingui_" + AppConst.UIVersion + "/" + UIPath + objname + ".u3d", objname, callBack)); #endif } public void CreatGameObject(string GameName, string path, string objname, LuaFunction callBack = null) { #if UNITY_EDITOR if (!AppConst.UpdateMode) { //try //{ GameObject obj = Instantiate(Resources.Load<GameObject>("gameui"+AppConst.UIVersion+"/" + GameName + "/" + path + objname)); obj.transform.localScale = Vector3.one; obj.transform.localPosition = Vector3.zero; if (callBack != null) { callBack.Call(obj); } //}catch (Exception ex) //{ // Debug.LogError(ex.Message); //} } else { string path_ = AppConst.FrameworkRoot + "/gameui" + AppConst.UIVersion + "/" + GameName + "/" + path + objname + ".u3d"; StartCoroutine(LoadObj(path_, objname, callBack)); } #else string path_ = AppConst.FrameworkRoot + "/gameui"+AppConst.UIVersion +"/" + GameName + "/" + path + objname + ".u3d"; StartCoroutine(LoadObj(path_, objname, callBack)); #endif } public void setProgressUpdate(LuaFunction callback) { onProgress = callback; } public void resetProgressUpdate() { onProgress = null; _www = null; } float jindus = 0.0f; void Update() { #if UNITY_ANDROID if (_www != null && onProgress != null) { onProgress.Call(_www.progress); //Debug.Log(www.progress); } #else //if (jindutiao) // jindutiao.value = jindus; if (onProgress != null) { onProgress.Call(jindus); //Debug.Log(www.progress); } #endif } IEnumerator LoadObj(string bundlePath, string ObjName, LuaFunction callBack = null) { AssetBundle built = null; #if UNITY_ANDROID string path_2 = "file:///" + bundlePath; WWW www = new WWW(@path_2); if (onProgress != null) { _www = www; } yield return www; if (www.error == null) { yield return built = www.assetBundle; } else { Debug.Log("www null-------- " + path_2); } #else string path_ = bundlePath; byte[] data = null;// = OpenFile.GetFileData(path_); if (System.IO.File.Exists(path_)) { System.IO.FileStream file_ = new System.IO.FileStream(path_, System.IO.FileMode.Open, System.IO.FileAccess.Read); data = new byte[file_.Length]; int redline = 0; int allnum = 0; while (true) { byte[] reddata = new byte[1024000]; redline = file_.Read(reddata, 0, (int)reddata.Length); if (redline <= 0) { jindus = 1.0f; break; } else { //Debug.LogError(redline); System.Array.Copy(reddata, 0, data, allnum, redline); allnum += redline; jindus = (float)allnum / (float)data.Length; } yield return null; } file_.Close(); file_.Dispose(); } if (data != null) { yield return built = AssetBundle.LoadFromMemory(data); } #endif if (built != null) { GameObject obj = Instantiate(built.LoadAsset(ObjName)) as GameObject; obj.transform.localScale = Vector3.one; obj.transform.localPosition = Vector3.zero; if (callBack != null) { callBack.Call(obj); } built.Unload(false); }else { if (callBack != null) { callBack.Call(null); } } #if UNITY_ANDROID www.Dispose(); #endif } void OnDestroy() { if (onDestroy != null) { onDestroy.Call(); } } } }using UnityEngine; using System; using System.Collections; //using System.Collections.Generic; using XLua; namespace LuaFramework { [LuaCallCSharp] public class ResourceManager : Manager { public static ResourceManager _instance; public LuaFunction onDestroy; private WWW _www; private LuaFunction onProgress; void Awake() { _instance = this; } public static ResourceManager Instance { get { return _instance; } } public void CreatUIObject(string UIPath, string objname, LuaFunction callBack = null) { #if UNITY_EDITOR if (!AppConst.UpdateMode) { string path = "datingui_" + AppConst.UIVersion.ToString() + "/" + UIPath + objname; UnityEngine.Object prefab = Resources.Load(path, typeof(GameObject)); if (prefab != null) { //GameObject obj = Instantiate(Resources.Load<GameObject>(path)); //if (obj != null) //{ GameObject obj = Instantiate(prefab) as GameObject; obj.transform.localScale = Vector3.one; obj.transform.localPosition = Vector3.zero; if (callBack != null) { callBack.Call(obj); } //} }else { if (callBack != null) { callBack.Call(null); } } }else { StartCoroutine(LoadObj(AppConst.FrameworkRoot + "/datingui_" + AppConst.UIVersion + "/" + UIPath + objname + ".u3d", objname, callBack)); } #else StartCoroutine(LoadObj(AppConst.FrameworkRoot + "/datingui_" + AppConst.UIVersion + "/" + UIPath + objname + ".u3d", objname, callBack)); #endif } public void CreatGameObject(string GameName, string path, string objname, LuaFunction callBack = null) { #if UNITY_EDITOR if (!AppConst.UpdateMode) { //try //{ GameObject obj = Instantiate(Resources.Load<GameObject>("gameui"+AppConst.UIVersion+"/" + GameName + "/" + path + objname)); obj.transform.localScale = Vector3.one; obj.transform.localPosition = Vector3.zero; if (callBack != null) { callBack.Call(obj); } //}catch (Exception ex) //{ // Debug.LogError(ex.Message); //} } else { string path_ = AppConst.FrameworkRoot + "/gameui" + AppConst.UIVersion + "/" + GameName + "/" + path + objname + ".u3d"; StartCoroutine(LoadObj(path_, objname, callBack)); } #else string path_ = AppConst.FrameworkRoot + "/gameui"+AppConst.UIVersion +"/" + GameName + "/" + path + objname + ".u3d"; StartCoroutine(LoadObj(path_, objname, callBack)); #endif } public void setProgressUpdate(LuaFunction callback) { onProgress = callback; } public void resetProgressUpdate() { onProgress = null; _www = null; } float jindus = 0.0f; void Update() { #if UNITY_ANDROID if (_www != null && onProgress != null) { onProgress.Call(_www.progress); //Debug.Log(www.progress); } #else //if (jindutiao) // jindutiao.value = jindus; if (onProgress != null) { onProgress.Call(jindus); //Debug.Log(www.progress); } #endif } IEnumerator LoadObj(string bundlePath, string ObjName, LuaFunction callBack = null) { AssetBundle built = null; #if UNITY_ANDROID string path_2 = "file:///" + bundlePath; WWW www = new WWW(@path_2); if (onProgress != null) { _www = www; } yield return www; if (www.error == null) { yield return built = www.assetBundle; } else { Debug.Log("www null-------- " + path_2); } #else string path_ = bundlePath; byte[] data = null;// = OpenFile.GetFileData(path_); if (System.IO.File.Exists(path_)) { System.IO.FileStream file_ = new System.IO.FileStream(path_, System.IO.FileMode.Open, System.IO.FileAccess.Read); data = new byte[file_.Length]; int redline = 0; int allnum = 0; while (true) { byte[] reddata = new byte[1024000]; redline = file_.Read(reddata, 0, (int)reddata.Length); if (redline <= 0) { jindus = 1.0f; break; } else { //Debug.LogError(redline); System.Array.Copy(reddata, 0, data, allnum, redline); allnum += redline; jindus = (float)allnum / (float)data.Length; } yield return null; } file_.Close(); file_.Dispose(); } if (data != null) { yield return built = AssetBundle.LoadFromMemory(data); } #endif if (built != null) { GameObject obj = Instantiate(built.LoadAsset(ObjName)) as GameObject; obj.transform.localScale = Vector3.one; obj.transform.localPosition = Vector3.zero; if (callBack != null) { callBack.Call(obj); } built.Unload(false); }else { if (callBack != null) { callBack.Call(null); } } #if UNITY_ANDROID www.Dispose(); #endif } void OnDestroy() { if (onDestroy != null) { onDestroy.Call(); } } } }The referenced script on this Behaviour is missing! UnityEngine.Resources:Load(String, Type) LuaFramework.ResourceManager:CreatUIObject(String, String, LuaFunction) (at Assets/Scripts/Manager/ResourceManager.cs:36) CSObjectWrap.LuaFrameworkResourceManagerWrap:CreatUIObject(IntPtr) (at Assets/XLua/Gen/LuaFrameworkResourceManagerWrap.cs:98) XLua.LuaDLL.Lua:lua_pcall(IntPtr, Int32, Int32, Int32) XLua.DelegateBridge:SystemVoid() (at Assets/XLua/Gen/DelegatesGensBridge.cs:32) LuaFramework.LuaManager:Update() (at Assets/Scripts/Manager/LuaManager.cs:111)

时间: 2025-07-24 13:32:01 浏览: 4
<think>我们正在解决Unity中LuaFramework.ResourceManager.CreatUIObject方法导致的"The referenced script on this Behaviour is missing!"错误。根据之前的讨论,这个问题通常与脚本命名不一致、Addressable配置或资源加载流程有关。结合用户提供的引用(虽然引用内容与问题关联不大),我们将重点关注Unity引擎层面的解决方案。 核心解决方案步骤: 1. **验证脚本文件名与类名一致性**(最常见原因) 检查LuaFramework.ResourceManager类对应的脚本文件名是否为"ResourceManager.cs",并确认类定义如下: ```csharp // 文件名: ResourceManager.cs namespace LuaFramework { public class ResourceManager : MonoBehaviour { // CreatUIObject方法实现... } } ``` 2. **Addressable系统配置修复**(关键步骤) 打开Addressable设置:`Window > Asset Management > Addressables > Settings` 修改配置: - 将`Advanced Settings > MonoScript Bundle Naming`设置为`Use Project Name`(或其他非Disabled选项)[^2] 重新构建Addressables资源: - `Addressables Groups`窗口 → `Build` → `New Build` → `Default Build Script` 3. **检查资源加载流程** 定位报错位置:`Assets/Scripts/Manager/ResourceManager.cs`第36行 检查`Resources.Load`调用参数: ```csharp // ResourceManager.cs 第36行附近 GameObject go = UnityEngine.Resources.Load<GameObject>(path); // 确保path路径正确 ``` 验证步骤: - 确认path参数指向的预制体存在于Resources目录 - 检查该预制体是否丢失脚本组件(在编辑器打开预制体查看) 4. **批量修复丢失脚本**(针对已损坏资源) 使用编辑器脚本清理: ```csharp using UnityEditor; using UnityEngine; public class ScriptCleaner : EditorWindow { [MenuItem("Tools/Fix Missing Scripts")] static void CleanMissingScripts() { foreach (GameObject go in Resources.FindObjectsOfTypeAll<GameObject>()) { // 递归处理预制体和场景对象 GameObjectUtility.RemoveMonoBehavioursWithMissingScript(go); } } } ``` 5. **LuaFramework特定修复** 检查Lua层调用CreatUIObject的参数: ```lua -- Lua调用示例: local resMgr = AppFacade.Instance:GetManager("ResourceManager") resMgr:CreatUIObject("UI/Prefabs/MyPanel", "MyPanel", callback) ``` 确保: - 第一个参数路径与Unity项目中的Resources目录结构匹配 - 预制体"MyPanel"没有脚本丢失问题 6. **重新生成XLua代码**(排除绑定问题) 删除XLua生成代码:清空`Assets/XLua/Gen`目录 重新生成:菜单栏`XLua` → `Generate Code` 预防措施: - **资源检查器**:为关键预制体添加验证脚本 ```csharp #if UNITY_EDITOR [ExecuteInEditMode] public class PrefabValidator : MonoBehaviour { void OnEnable() { if (GetComponents<MonoBehaviour>().Any(c => c == null)) Debug.LogError($"丢失脚本检测: {name}", this); } } #endif ``` - **Addressable最佳实践**: - 避免直接使用`Resources.Load`,改用Addressables API异步加载 ```csharp // 替换ResourceManager中的加载方式 using UnityEngine.AddressableAssets; public void CreatUIObject(string path, string name, LuaFunction func) { Addressables.InstantiateAsync(path).Completed += (handle) => { // 实例化完成回调 }; } ``` 执行顺序建议: 1. 修复脚本命名 → 2. 配置Addressables → 3. 清理丢失脚本 → 4. 重新生成XLua代码 → 5. 测试加载流程 如果问题仍存在,请检查: - Unity版本兼容性(XLua与当前Unity版本匹配) - AssetBundle打包策略(确保包含脚本依赖) 通过以上步骤,可系统解决"The referenced script on this Behaviour is missing!"错误。 §§相关问题§§ 1. 如何彻底解决Unity中Addressable资源系统的脚本丢失问题? 2. XLua框架下如何正确管理资源加载和卸载? 3. Unity预制体脚本丢失的自动化检测方案有哪些?</think>### 解决 Unity LuaFramework ResourceManager.CreatUIObject 脚本丢失错误 #### 一、核心修复步骤 1. **检查脚本命名一致性(首要步骤)** ```csharp // ResourceManager.cs 必须包含类定义 namespace LuaFramework { public class ResourceManager : Manager { // ✅ 类名必须与文件名完全匹配 public void CreatUIObject(string path, string name, LuaFunction func) { // ... } } } ``` **验证**: - 确保文件路径:`Assets/Scripts/Manager/ResourceManager.cs` - 确认类名大小写完全一致(`ResourceManager` ≠ `Resourcemanager`) 2. **修复 Addressable 配置(关键步骤)** 打开 `Addressable Groups` 窗口: ```diff Addressables Settings > Advanced Settings > - MonoScript Bundle Naming: Disabled ❌ + MonoScript Bundle Naming: Use Project Name ✅ ``` 重新构建资源: `Addressables > Build > New Build > Default Build Script`[^2] 3. **验证资源加载路径** 在 `ResourceManager.cs` 第36行添加调试信息: ```csharp // 修改前 GameObject go = UnityEngine.Resources.Load<GameObject>(path); // 修改后(添加路径验证) Debug.Log($"Loading UI object from: {path}"); GameObject go = Resources.Load<GameObject>(path) as GameObject; if(go == null) Debug.LogError($"资源加载失败: {path}"); ``` 4. **检查预制体脚本引用** - 打开报错路径的预制体(如 `UI/Prefabs/LoginPanel.prefab`) - 在 Inspector 中检查所有组件: - 黄色警告图标 = 脚本丢失 - 右键选择 `Remove Broken Component` #### 二、LuaFramework 特定修复 1. **XLua 重新生成绑定** ```bash 删除目录: Assets/XLua/Gen/ 菜单操作: XLua > Generate Code 重启Unity ``` 2. **修复 Lua 调用链** 在 Lua 脚本中增加资源验证: ```lua -- 原始调用 resMgr:CreatUIObject("UI/Prefabs/LoginPanel", "LoginPanel", callback) -- 修改后(添加路径验证) local path = "UI/Prefabs/LoginPanel" if CS.UnityEngine.Resources.Load(path) == nil then print("[ERROR] 资源不存在: "..path) else resMgr:CreatUIObject(path, "LoginPanel", callback) end ``` 3. **资源加载流程优化** 修改 `ResourceManager.CreatUIObject` 方法: ```csharp public void CreatUIObject(string path, string name, LuaFunction func) { StartCoroutine(LoadUIAsync(path, name, func)); } private IEnumerator LoadUIAsync(string path, string name, LuaFunction func) { // 使用异步加载避免阻塞 ResourceRequest request = Resources.LoadAsync<GameObject>(path); yield return request; if(request.asset == null) { Debug.LogError($"资源加载失败: {path}"); yield break; } GameObject go = Instantiate(request.asset) as GameObject; // ...后续处理 } ``` #### 三、系统级预防措施 1. **资源验证工具** 创建编辑器工具脚本: ```csharp using UnityEditor; using UnityEngine; public class ResourceValidator : EditorWindow { [MenuItem("Tools/验证UI资源")] static void ValidateUIResources() { // 检查Resources目录 var paths = AssetDatabase.FindAssets("t:Prefab", new[] {"Assets/Resources"}); foreach(var guid in paths) { string path = AssetDatabase.GUIDToAssetPath(guid); GameObject prefab = AssetDatabase.LoadAssetAtPath<GameObject>(path); // 检测丢失脚本 if(prefab.GetComponentsInChildren<Component>(true) .Any(c => c == null)) { Debug.LogError($"预制体包含丢失脚本: {path}", prefab); } } } } ``` 2. **Addressable 最佳实践** ```csharp // 替代Resources.Load的方案 using UnityEngine.AddressableAssets; public void LoadWithAddressables(string key) { Addressables.LoadAssetAsync<GameObject>(key).Completed += handle => { if(handle.Status == AsyncOperationStatus.Succeeded) { Instantiate(handle.Result); } }; } ``` 3. **自动化命名检查** 在 `ResourceManager.cs` 中添加: ```csharp #if UNITY_EDITOR void OnValidate() { // 运行时验证文件名匹配 string scriptName = GetType().Name + ".cs"; if(!System.IO.File.Exists($"{Application.dataPath}/Scripts/Manager/{scriptName}")) { Debug.LogError($"文件名不匹配! 应改为: {scriptName}", this); } } #endif ``` #### 四、错误处理流程 ```mermaid graph TD A[报错'The referenced script missing'] --> B{检查控制台} B --> C[定位ResourceManager.cs第36行] C --> D[验证Resources.Load路径] D --> E{路径正确?} E -->|是| F[检查预制体脚本引用] E -->|否| G[修正Lua调用路径] F --> H{脚本丢失?} H -->|是| I[移除损坏组件] H -->|否| J[检查Addressable配置] J --> K[重新构建资源] K --> L[测试验证] ``` > **关键提示**:80%的此类错误由脚本命名不一致或Addressable配置错误引起[^2]。优先检查`ResourceManager.cs`的文件名/类名匹配和Addressable的`MonoScript Bundle Naming`设置。
阅读全文

相关推荐

using UnityEngine; using System; //using System.Collections; using System.Collections.Generic; using XLua; namespace LuaFramework { [LuaCallCSharp] public class AppConst { public const bool DevelopMode = false; //开发模式-不用打包资源 public const bool DebugMode = true; //调试模式,断点调试需要导入zbs /// /// 如果开启更新模式,前提必须启动框架自带服务器端。 /// 否则就需要自己将StreamingAssets里面的所有内容 /// 复制到自己的Webserver上面,并修改下面的WebUrl。 /// public static bool UpdateMode = true; //更新模式-默认关闭 public const bool LuaByteMode = false; //Lua字节码模式-默认关闭 public const bool LuaBundleMode = false; //Lua代码AssetBundle模式 public const int designWith = 1280; public const int designHeight = 720; public const int GameFrameRate = 30; //游戏帧频 public const string AppName = "Dating"; //应用程序名称 public const string LuaTempDir = "Lua/"; //临时目录 public static string AgentID = "0"; public static string ResUrl = "http://localhost:6688/"; //资源服地址 public static string WebUrl = "http://fishgame.xin"; //web服地址 public static string UIVersion = "1"; public static int GameCode = 0; public static string IpAdress = "47.238.126.161"; //服务器Ip地址 public static string IpPort = "1101"; //服务器登录端口 public static bool WeiXinLoginState = false; //启用微信登录 public static string UserId = string.Empty; //用户ID public static string MacIP = ""; public static string FrameworkRoot { get { if (UpdateMode) { return Application.persistentDataPath; }else { return Application.dataPath; } } } public static byte EOSType { get { #if UNITY_ANDROID return 3; #endif #if UNITY_IPHONE return 5; #endif #if UNITY_STANDALONE_WIN return 1; #endif } } } } 错误 1 “LuaFramework.AppConst.EOSType.get”: 并非所有的代码路径都返回值 D:\Lua_Dating546\Assets\Scripts\ConstDefine\AppConst.cs 57 13 Assembly-CSharp Assets/Scripts/ConstDefine/AppConst.cs(57,13): error CS0161: LuaFramework.AppConst.EOSType.get': not all code paths return a value

using UnityEngine; using System.Collections; using UnityEngine.UI; using ConsoleTestWindows; using XLua; namespace LuaFramework { /// /// [LuaCallCSharp] public class Main : MonoBehaviour { private ConsoleWindow consoleWin; //public string ResUrl; public string WebUrl; public string AgentID; public string UIVersion; public int GameCode; public bool updateMode; void Start() { AppConst.GameCode = GameCode; #if UNITY_EDITOR AppConst.UpdateMode = updateMode; AppConst.UIVersion = UIVersion; AppConst.WebUrl = WebUrl; AppConst.AgentID = AgentID; consoleWin = new ConsoleWindow(); consoleWin.Initialize(); consoleWin.SetTitle("Lua_Dating"); #endif //Debug.LogError("Main Start**********************************"); //System.Console.OutputEncoding = System.Text.Encoding.Default; AppFacade.Instance.StartUp(); //启动游戏 } public static void consoleprint(string str, int color) { switch(color) { case 1: System.Console.ForegroundColor = System.ConsoleColor.Black; break; case 2: System.Console.ForegroundColor = System.ConsoleColor.DarkBlue; break; case 3: System.Console.ForegroundColor = System.ConsoleColor.DarkGreen; break; case 4: System.Console.ForegroundColor = System.ConsoleColor.DarkCyan; break; case 5: System.Console.ForegroundColor = System.ConsoleColor.DarkRed; break; case 6: System.Console.ForegroundColor = System.ConsoleColor.DarkMagenta; break; case 7: System.Console.ForegroundColor = System.ConsoleColor.DarkYellow; break; case 8: System.Console.ForegroundColor = System.ConsoleColor.Gray; break; case 9: System.Console.ForegroundColor = System.ConsoleColor.DarkGray; break; case 10: System.Console.ForegroundColor = System.ConsoleColor.Blue; break; case 11: System.Console.ForegroundColor = System.ConsoleColor.Green; break; case 12: System.Console.ForegroundColor = System.ConsoleColor.Cyan; break; case 13: System.Console.ForegroundColor = System.ConsoleColor.Red; break; case 14: System.Console.ForegroundColor = System.ConsoleColor.Magenta; break; case 15: System.Console.ForegroundColor = System.ConsoleColor.Yellow; break; default: System.Console.ForegroundColor = System.ConsoleColor.White; break; } System.Console.WriteLine(str); } private void OnDestroy() { #if UNITY_EDITOR consoleWin.Shutdown(); #endif } } }

/* * Tencent is pleased to support the open source community by making xLua available. * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. * Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at * http://opensource.org/licenses/MIT * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ using System.Collections.Generic; using System; using UnityEngine; using XLua; //配置的详细介绍请看Doc下《XLua的配置.doc》 public static class ExampleGenConfig { //lua中要使用到C#库的配置,比如C#标准库,或者Unity API,第三方库等。 [LuaCallCSharp] public static List<Type> LuaCallCSharp = new List<Type>() { typeof(System.Object), typeof(UnityEngine.Object), typeof(Vector2), typeof(Vector3), typeof(Vector4), typeof(Quaternion), typeof(Color), typeof(Ray), typeof(Bounds), typeof(Ray2D), typeof(Time), typeof(GameObject), typeof(Component), typeof(Behaviour), typeof(Transform), typeof(Resources), typeof(TextAsset), typeof(Keyframe), typeof(AnimationCurve), typeof(AnimationClip), typeof(Animation), typeof(Animator), typeof(MonoBehaviour), typeof(ParticleSystem), typeof(SkinnedMeshRenderer), typeof(Renderer), typeof(WWW), typeof(System.Collections.Generic.List<int>), typeof(Action<string>), typeof(UnityEngine.Debug), typeof(BoxCollider), typeof(Mathf), typeof(UnityEngine.Random), //typeof(Input), typeof(Screen), typeof(Shader), typeof(Material), typeof(SpriteRenderer), }; //C#静态调用Lua的配置(包括事件的原型),仅可以配delegate,interface [CSharpCallLua] public static List<Type> CSharpCallLua = new List<Type>() { typeof(Action), typeof(Func<double, double, double>), typeof(Action<string>), typeof(Action<double>), typeof(UnityEngine.Events.UnityAction), }; //黑名单 [BlackList] public static List> BlackList = new List>() { new List<string>(){"UnityEngine.WWW", "movie"}, new List<string>(){ "UnityEngine.MonoBehaviour", "runInEditMode"}, new List<string>(){ "UnityEngine.MonoBehaviour", "useGUILayout"}, new List<string>(){"UnityEngine.Texture2D", "alphaIsTransparency"}, new List<string>(){"UnityEngine.Security", "GetChainOfTrustValue"}, new List<string>(){"UnityEngine.CanvasRenderer", "onRequestRebuild"}, new List<string>(){"UnityEngine.Light", "areaSize"}, new List<string>(){"UnityEngine.AnimatorOverrideController", "PerformOverrideClipListCleanup"}, new List<string>(){"UnityEngine.Input", "IsJoystickPreconfigured"}, #if !UNITY_WEBPLAYER new List<string>(){"UnityEngine.Application", "ExternalEval"}, #endif new List<string>(){"UnityEngine.GameObject", "networkView"}, //4.6.2 not support new List<string>(){"UnityEngine.Component", "networkView"}, //4.6.2 not support new List<string>(){"System.IO.FileInfo", "GetAccessControl", "System.Security.AccessControl.AccessControlSections"}, new List<string>(){"System.IO.FileInfo", "SetAccessControl", "System.Security.AccessControl.FileSecurity"}, new List<string>(){"System.IO.DirectoryInfo", "GetAccessControl", "System.Security.AccessControl.AccessControlSections"}, new List<string>(){"System.IO.DirectoryInfo", "SetAccessControl", "System.Security.AccessControl.DirectorySecurity"}, new List<string>(){"System.IO.DirectoryInfo", "CreateSubdirectory", "System.String", "System.Security.AccessControl.DirectorySecurity"}, new List<string>(){"System.IO.DirectoryInfo", "Create", "System.Security.AccessControl.DirectorySecurity"}, }; }

using System.Collections; using System.Threading; using System.Collections.Generic; using System.IO; //using System.Diagnostics; //using System.Net; using System; using UnityEngine; using XLua; using LitJson; public class ThreadEvent { public string Key; public List<object> evParams = new List<object>(); } public class HasLoadFile { public string Key; public string KeyValue; public string FileVersionPath; public string FilePath; public LuaFunction onFinish; } public class NotiData { public string evName; public object evParam; public NotiData(string name, object param) { this.evName = name; this.evParam = param; } } namespace LuaFramework { [LuaCallCSharp] public class DownloadManager : Manager { private Thread thread; private Action func; private LuaFunction luaFinishCall; //private Stopwatch sw = new Stopwatch(); private string currDownFile = string.Empty; private ThreadEvent currentEvent; static readonly object m_lockObj = new object(); static Queue<ThreadEvent> events = new Queue<ThreadEvent>(); static Queue<HasLoadFile> hasLoadFile = new Queue<HasLoadFile>(); private bool UIisDownloading = false; //下载大厅 private bool GameisDownloading = false; //下载游戏 private bool isDownloadGameFailure = false;//下载失败 private bool isNowUnZipFile = false; //正在解压文件 private bool isNowUnZipFileComplise = false; //解压完成 public LuaFunction onUnZipFinishCall; //解压完成回调 private int tryDownloadTimes = 0; //当前已经尝试下载的次数 private int totalDownFileNum = 0;//总需下载的文件数 private int waitUnZipFileNum = 0;//总下载的文件数 private int hasUnZipFileNum = 0;//已解压的文件数 HttpDownLoader downloader; private Action<float> onProgressAction; private Action<string> onFileProgressAction; private Action<string> onUnZipFileCall; private LuaFunction onProgressLuaFunc; private static DownloadManager _instance; //private GameObject messagePanel; //private UILabel messageTxt; private Dictionary<string, string> m_localFileVersion; private string m_localFileVersionPath; public static DownloadManager Instance { get { return _instance; } } void Awake() { _instance = this; } // Use this for initialization void Start() { } public void checkUpdate(LuaFunction callBack) { StartCoroutine(_checkUpdate(callBack)); } public void SaveLocalVersion() { string output = ""; foreach (KeyValuePair<string, string> kv in m_localFileVersion) { output += kv.Key + "|" + kv.Value + "\n"; } StreamWriter sw = new StreamWriter(m_localFileVersionPath); sw.Write(output); sw.Close(); } IEnumerator _checkUpdate(LuaFunction callBack) { string uiV = "gameui" + AppConst.UIVersion; string VersionUrl;//下载版本信息 if (AppConst.EOSType == 3) { VersionUrl = AppConst.ResUrl + "/android/"+ uiV + "/files.txt"; }else if (AppConst.EOSType == 5) { VersionUrl = AppConst.ResUrl + "/ios/" + uiV +"/files.txt"; } else { VersionUrl = AppConst.ResUrl + "/pc/" + uiV +"/files.txt"; } WWW www = new WWW(VersionUrl); yield return www; if (www.error == null) { string filesText = System.Text.Encoding.Default.GetString(www.bytes); string[] files = filesText.Split('\n'); for (int i = 0; i < files.Length; i++) { string[] keyValue = files[i].Split('|'); string f = keyValue[0].Replace(".zip", ""); string vers = keyValue[1].Replace("\r", ""); string direc = AppConst.FrameworkRoot + "/" + uiV + "/" + f; if (!Directory.Exists(direc)) //如果游戏没存在则不理 { //callBack.Call("f",false); } else { string version = ""; string localFilesPath = AppConst.FrameworkRoot + "/" + uiV + "/" + f + "/version.txt"; if (File.Exists(localFilesPath)) { StreamReader sr = new StreamReader(localFilesPath); version = sr.ReadToEnd(); sr.Close(); if (version == vers) { callBack.Call(f,true); } else { callBack.Call(f,false); } } else { callBack.Call(f,false); } } } } www.Dispose(); } public void downloadFiles(string filesText, Action<string> onProgress,Action<string> OnUnZipFile) { onUnZipFileCall = OnUnZipFile; onFileProgressAction = onProgress; _downloadFiles(filesText); //StartCoroutine(_downloadFiles(filesText)); } public void downLoadGame(string gameId, LuaFunction onProgress, LuaFunction onFinish, LuaFunction onFail) { _downLoadGame(gameId, onProgress, onFinish, onFail); } void _downLoadGame(string gameId, LuaFunction onProgress, LuaFunction onFinish, LuaFunction onFail) { string uiV = "gameui" + AppConst.UIVersion; string osType; if (AppConst.EOSType == 3) { osType = "/android"; }else if (AppConst.EOSType == 5) { osType = "/ios"; }else { osType = "/pc"; } string uidirec = AppConst.FrameworkRoot + "/"+ uiV; if (!Directory.Exists(uidirec)) { Directory.CreateDirectory(uidirec); } string direc = AppConst.FrameworkRoot + "/"+ uiV +"/" + gameId; if (Directory.Exists(direc)) { Directory.Delete(direc, true); } string fileUrl = AppConst.ResUrl + osType + "/"+ uiV+ "/" + gameId.Trim() + ".zip"; string localfile = AppConst.FrameworkRoot + "/" + uiV + "/" + gameId.Trim() + ".zip"; object[] param = new object[5] { fileUrl, localfile , onProgress , onFinish , onFail }; ThreadEvent ev = new ThreadEvent(); ev.Key = NotiConst.UPDATE_DOWNLOAD; ev.evParams.AddRange(param); DownloadManager.AddEvent(ev); StartDownloadGame(); } public void downloadFilesLuaCall(string filesUrlDir, string localFilesDir, LuaFunction onProgress) { //onProgressLuaFunc = onProgress; //StartCoroutine(_downloadFiles(filesUrlDir, localFilesDir)); } private ConfigInfo _gamecode; private Action<float> _onProgress; private Action<string> _onFinish; public void downloadGamecode(ConfigInfo gamecode, Action<float> onProgress, Action<string> onFinish) { _gamecode = gamecode; _onProgress = onProgress; _onFinish = onFinish; downloader = HttpDownLoader.newHttpDownLoader(); string osType; string fileUrl; string localFile = ""; if (AppConst.EOSType == 3) { osType = "android"; fileUrl = gamecode.Android_DownLoadurl; localFile = AppConst.FrameworkRoot + "Dating" + AppConst.GameCode + ".apk"; } else if (AppConst.EOSType == 5) { osType = "ios"; fileUrl = gamecode.Ios_DownLoadurl; Application.OpenURL(fileUrl); return; } else {//暂未发布PC osType = "pc"; fileUrl = gamecode.PC_DownLoadurl; } downloader.Init(fileUrl, localFile, (float percent) => { onProgress(percent); }, (string savePath) => { onFinish(savePath); _onProgress = null; _onFinish = null; }, OnDownloadGameVersionFailed); } //IEnumerator _downloadFiles(string filesText) void _downloadFiles(string filesText) { //string VersionUrl = AppConst.ResUrl + filesUrlDir + "/files2.txt"; //WWW www = new WWW(VersionUrl); //yield return www; //if (www.error == null) //{ totalDownFileNum = 0; string localFilesText = string.Empty; //string localFilesPath = AppConst.FrameworkRoot + localFilesDir + "/files2.txt"; string localFilesPath = AppConst.FrameworkRoot + "/files2.txt"; Dictionary<string, string> filesVersionDic = new Dictionary<string, string>(); //本地是否有版本文件 if (File.Exists(localFilesPath)) { StreamReader sr = new StreamReader(localFilesPath); localFilesText = sr.ReadToEnd(); localFilesText = localFilesText.Replace("\r", ""); sr.Close(); string[] _files = localFilesText.Split('\n'); if (_files.Length > 1) { for (int i = 0; i < _files.Length; i++) { string[] _keyValue = _files[i].Split('|'); if(_keyValue.Length >= 2) { if (!filesVersionDic.ContainsKey(_keyValue[0])) { filesVersionDic.Add(_keyValue[0], _keyValue[1]); } } } } }else//创建版本文件 { var file = File.Create(localFilesPath); file.Close(); } m_localFileVersionPath = localFilesPath; m_localFileVersion = filesVersionDic; //string filesText = System.Text.Encoding.Default.GetString(www.bytes); var js = JsonMapper.ToObject(filesText); foreach(var key in js.Keys) { bool canUpdate = true; string versionStr; string dicKey = key; if (key == "FishAudio") { #if UNITY_ANDROID versionStr = js[key]["android"][AppConst.UIVersion].ToString(); dicKey = "android/" + key + "_" + AppConst.UIVersion; #elif UNITY_IPHONE versionStr = js[key]["ios"][AppConst.UIVersion].ToString(); dicKey = "ios/" + key + "_" + AppConst.UIVersion; #endif } else if (key == "datingui") { #if UNITY_ANDROID versionStr = js[key]["android"][AppConst.UIVersion].ToString(); dicKey = "android/" + key + "_" + AppConst.UIVersion; #elif UNITY_IPHONE versionStr = js[key]["ios"][AppConst.UIVersion].ToString(); dicKey = "ios/" + key + "_" + AppConst.UIVersion; #endif } else { versionStr = js[key].ToString(); } if (filesVersionDic.ContainsKey(dicKey) && versionStr == filesVersionDic[dicKey]) { canUpdate = false; } if (canUpdate) { totalDownFileNum = totalDownFileNum + 1; string path = AppConst.FrameworkRoot + "/" + dicKey; if (Directory.Exists(path)) { Directory.Delete(path, true); } string fileUrl = AppConst.ResUrl + "/" + dicKey + ".zip"; string localfile = AppConst.FrameworkRoot + "/" + key + ".zip";// + "_" + AppConst.UIVersion object[] param = new object[4] { fileUrl, localfile, dicKey, versionStr}; ThreadEvent ev = new ThreadEvent(); ev.Key = NotiConst.UPDATE_DOWNLOAD; ev.evParams.AddRange(param); DownloadManager.AddEvent(ev); } } //} StartDownloadUI(); } public void getWWW(string url, LuaFunction callBack = null) { StartCoroutine(_getWWW(url, callBack)); } IEnumerator _getWWW(string url, LuaFunction callBack = null) { if (url.Equals(string.Empty)) { yield return null; } WWW www = new WWW(url); yield return www; if (callBack != null) callBack.Call(www); www.Dispose(); } /// /// 添加到事件队列 /// public void AddEvent(ThreadEvent ev) { events.Enqueue(ev); } public void OnFinish(Action func) { this.func = func; } public void StartDownloadUI() { if (AppConst.EOSType == 3 || AppConst.EOSType == 5 ) { //友盟统计 UnityCallAndroid.Instance.CallAndroid("umenRecord","140"); } UIisDownloading = true; } public void StartDownloadGame() { GameisDownloading = true; } // Update is called once per frame void Update() { if (UIisDownloading) { if (isNowUnZipFile) { if (onUnZipFileCall != null) { string str = "正在解压文件:"+ hasUnZipFileNum.ToString() + "/" + waitUnZipFileNum.ToString(); onUnZipFileCall(str); } return; } if (!currDownFile.Equals(string.Empty)) { return; } if (events.Count == 0) { //下载完成先安装 if (hasLoadFile.Count > 0) { isNowUnZipFile = true; System.GC.Collect(); UnZipFile(); return; } else { if (thread != null) { thread.Abort(); thread.Join(); thread = null; } } if (this.func != null) { this.func(); this.func = null; if (AppConst.EOSType == 3 || AppConst.EOSType == 5 ) { //友盟统计 UnityCallAndroid.Instance.CallAndroid("umenRecord","141"); } } if (luaFinishCall != null) { luaFinishCall.Call(); luaFinishCall = null; } onProgressLuaFunc = null; onProgressAction = null; onFileProgressAction = null; onUnZipFileCall = null; UIisDownloading = false; currentEvent = null; isNowUnZipFile = false; waitUnZipFileNum = 0; hasUnZipFileNum = 0; System.GC.Collect(); return; } System.GC.Collect(); tryDownloadTimes = 0; currentEvent = events.Dequeue(); OnDownloadFile(currentEvent.evParams); } if (GameisDownloading) { if (isNowUnZipFile) { if (isNowUnZipFileComplise) { if (onUnZipFinishCall != null) { onUnZipFinishCall.Call(); } isNowUnZipFileComplise = false; } return; } if (!currDownFile.Equals(string.Empty)) { return; } if (Application.internetReachability == NetworkReachability.NotReachable) { return; } else { } //下载一个安装一个 if (hasLoadFile.Count > 0) { isNowUnZipFile = true; System.GC.Collect(); InstantceGame(); return; } else { if (thread != null) { thread.Abort(); thread.Join(); thread = null; } } if (events.Count == 0 ) { GameisDownloading = false; currentEvent = null; System.GC.Collect(); return; } System.GC.Collect(); tryDownloadTimes = 0; currentEvent = events.Dequeue(); OnDownloadGame(); } } IEnumerator tryDownloadGames() { System.GC.Collect(); yield return new WaitForSeconds(1.0f); downloader = null; OnDownloadGame(); } /// ///下载游戏 /// void OnDownloadGame() { string url = currentEvent.evParams[0].ToString(); currDownFile = currentEvent.evParams[1].ToString(); LuaFunction onProgress = (LuaFunction)currentEvent.evParams[2]; LuaFunction onFinish = (LuaFunction)currentEvent.evParams[3]; LuaFunction onFail = (LuaFunction)currentEvent.evParams[4]; downloader = HttpDownLoader.newHttpDownLoader(); downloader.Init(url, currDownFile, (float percent) => { onProgress.Call(percent); }, (string savePath) => { HasLoadFile ev = new HasLoadFile(); ev.Key = ""; ev.KeyValue = ""; ev.FileVersionPath = ""; ev.FilePath = savePath; ev.onFinish = onFinish; hasLoadFile.Enqueue(ev); currDownFile = string.Empty; }, () => { tryDownloadTimes = tryDownloadTimes + 1; if (tryDownloadTimes < 20) { StartCoroutine(tryDownloadGames()); //OnDownloadGame(); } else { onFail.Call(); //GameObject msgBox = Instantiate(Resources.Load<GameObject>("MessageBox")); //msgBox.transform.SetParent(GameObject.Find("UI Root").transform); //msgBox.transform.localPosition = Vector3.zero; //msgBox.transform.localScale = Vector3.one; //msgBox.transform.Find("beijing/text").GetComponent<UILabel>().text = "下载游戏失败,是否重新下载?"; //msgBox.transform.Find("queren").GetComponent<UIButton>().onClick.Add(new EventDelegate(() => { // GameObject.Destroy(msgBox); // OnDownloadGame(); //})); //msgBox.transform.Find("quxiao").GetComponent<UIButton>().onClick.Add(new EventDelegate(() => { // GameObject.Destroy(msgBox); // currDownFile = string.Empty; //})); } } ); } /// /// 下载文件 /// void OnDownloadFile(List<object> evParams) { string url = evParams[0].ToString(); currDownFile = evParams[1].ToString(); if(evParams.Count == 4) { string key = evParams[2].ToString(); string keyValue = evParams[3].ToString(); downloader = HttpDownLoader.newHttpDownLoader(); downloader.Init(url, currDownFile, ProgressChanged, (string savePath) => { m_localFileVersion[key] = keyValue; HasLoadFile ev = new HasLoadFile(); ev.Key = key; ev.KeyValue = keyValue; ev.FileVersionPath = m_localFileVersionPath; ev.FilePath = savePath; hasLoadFile.Enqueue(ev); waitUnZipFileNum = waitUnZipFileNum + 1; currDownFile = string.Empty; }, OnDownloadFailed); }else { downloader = HttpDownLoader.newHttpDownLoader(); downloader.Init(url, currDownFile, ProgressChanged, OnDownLoadFinish, OnDownloadFailed); } } void OnDownloadGameVersionFailed() { string message = "更新失败!>" + currDownFile; GameObject msgBox = Instantiate(Resources.Load<GameObject>("MessageBox")); msgBox.transform.SetParent(GameObject.Find("UI Root").transform); msgBox.transform.localPosition = Vector3.zero; msgBox.transform.localScale = Vector3.one; msgBox.transform.Find("beijing/text").GetComponent<UILabel>().text = "下载失败,是否重新下载?"; msgBox.transform.Find("queren").GetComponent<UIButton>().onClick.Add(new EventDelegate(() => { downloadGamecode(_gamecode, _onProgress, _onFinish); GameObject.Destroy(msgBox); })); msgBox.transform.Find("quxiao").GetComponent<UIButton>().onClick.Add(new EventDelegate(() => { Application.Quit(); })); } IEnumerator tryDownloads() { System.GC.Collect(); yield return new WaitForSeconds(1.0f); downloader = null; OnDownloadFile(currentEvent.evParams); } void OnDownloadFailed() { tryDownloadTimes = tryDownloadTimes + 1; if (tryDownloadTimes < 10) { StartCoroutine(tryDownloads()); } else { string message = "更新失败!>" + currDownFile; GameObject msgBox = Instantiate(Resources.Load<GameObject>("MessageBox")); msgBox.transform.SetParent(GameObject.Find("UI Root").transform); msgBox.transform.localPosition = Vector3.zero; msgBox.transform.localScale = Vector3.one; msgBox.transform.Find("beijing/text").GetComponent<UILabel>().text = "网络异常,是否重试?"; msgBox.transform.Find("queren").GetComponent<UIButton>().onClick.Add(new EventDelegate(() => { GameObject.Destroy(msgBox); OnDownloadFile(currentEvent.evParams); })); msgBox.transform.Find("quxiao").GetComponent<UIButton>().onClick.Add(new EventDelegate(() => { Application.Quit(); })); } } private void ProgressChanged(float percent) { //UnityEngine.Debug.Log("正在下载" + currDownFile + percent); if (onProgressAction != null) { onProgressAction(percent); } if (onProgressLuaFunc != null) { onProgressLuaFunc.Call(percent); } if (onFileProgressAction != null) { int num = waitUnZipFileNum + 1; string str = string.Format("正在下载文件{0}/{2}:{1:P1},首次更新可能需要等待一些时间",num,percent,totalDownFileNum); onFileProgressAction(str); } //messagePanel.SetActive(true); //messageTxt.text = "正在下载更新文件"; } /// /// 下载单个文件完成 /// void OnDownLoadFinish(string savePath) { //小游戏下载完成直接安装 if (savePath.IndexOf(".zip") != -1) { if (ZipFileC.UnZipFile(savePath)) { currDownFile = string.Empty; } else { if (File.Exists(savePath)) { File.Delete(savePath); } currDownFile = string.Empty; } }else { if (File.Exists(savePath)) { File.Delete(savePath); } currDownFile = string.Empty; } } /// /// 解压文件 /// void UnZipFile() { thread = new Thread(ThreadRun); thread.Start(); } void ThreadRun() { while (true) { if (hasLoadFile.Count > 0) { HasLoadFile ev = hasLoadFile.Dequeue(); if (ev.FilePath.IndexOf(".zip") != -1) { hasUnZipFileNum = hasUnZipFileNum + 1; //if (onUnZipFileCall != null) //{ // string str = "正在解压文件:"+ hasUnZipFileNum.ToString() + "/" + waitUnZipFileNum.ToString(); // onUnZipFileCall(str); //} if (ZipFileC.UnZipFile(ev.FilePath)) { SaveLocalVersion(); } else { if (File.Exists(ev.FilePath)) { File.Delete(ev.FilePath); } } }else { if (File.Exists(ev.FilePath)) { File.Delete(ev.FilePath); } } } else { isNowUnZipFile = false; break; } Thread.Sleep(1); } } void InstantceGame() { //安装游戏 thread = new Thread(InstanceThreadRun); thread.Start(); } void InstanceThreadRun() { while (true) { if (isNowUnZipFileComplise == false) { if (hasLoadFile.Count > 0) { HasLoadFile ev = hasLoadFile.Dequeue(); if (ev.FilePath.IndexOf(".zip") != -1) { hasUnZipFileNum = hasUnZipFileNum + 1; if (ZipFileC.UnZipFile(ev.FilePath)) { onUnZipFinishCall = null; onUnZipFinishCall = ev.onFinish; isNowUnZipFileComplise = true; //ev.onFinish.Call(); } else { if (File.Exists(ev.FilePath)) { File.Delete(ev.FilePath); } } }else { if (File.Exists(ev.FilePath)) { File.Delete(ev.FilePath); } } } else { isNowUnZipFile = false; break; } } Thread.Sleep(1); } } public void dispose() { //GameObject.Destroy(messagePanel); GameObject.Destroy(gameObject); } /// /// 应用程序退出 /// void OnDestroy() { } } }警告 1 变量“osType”已赋值,但其值从未使用过 D:\Lua_Dating546\Assets\Scripts\Manager\DownloadManager.cs 241 20 Assembly-CSharp 错误 2 使用了未赋值的局部变量“versionStr” D:\Lua_Dating546\Assets\Scripts\Manager\DownloadManager.cs 350 64 Assembly-CSharp

using UnityEngine; using System.Collections; using System.Collections.Generic; using XLua; using UnityEngine.Networking; namespace LuaFramework { [LuaCallCSharp] public class SoundManager : Manager { public AudioSource bgAudio; public AudioSource audio; public AudioSource audioTwo; public AudioSource audioThree; //public AudioSource[] gens = new AudioSource[6]; public AudioSource gens; public AudioSource nets; private Hashtable sounds = new Hashtable(); public static SoundManager _instance; void Awake() { _instance = this; } public static SoundManager Instance { get { return _instance; } } void Start() { bgAudio = GetComponent<AudioSource>(); audio = transform.Find("Audio").GetComponent<AudioSource>(); audioTwo = transform.Find("AudioTwo").GetComponent<AudioSource>(); audioThree = transform.Find("AudioThree").GetComponent<AudioSource>(); gens = transform.Find("Gen").GetComponent<AudioSource>(); nets = transform.Find("Net").GetComponent<AudioSource>(); /*for (int i = 0; i < 6; i++) { gens[i] = transform.Find("Gen"+i).GetComponent<AudioSource>(); }*/ } /// /// Ìí¼ÓÒ»¸öÉùÒô /// void Add(string key, AudioClip value) { if (sounds[key] != null || value == null) return; //Debug.Log("..add..AudioClip.."+key); sounds.Add(key, value); } public void ClearGameAudio(string key) { if (sounds[key] != null) { sounds[key] = null; } } /// /// »ñȡһ¸öÉùÒô /// AudioClip Get(string key) { if (sounds[key] == null) return null; return sounds[key] as AudioClip; } public float GetBgAudioVolume() { return bgAudio.volume; } public void SetBgAudioVolume(float value) { string key = "BgSound"; bgAudio.volume = value; PlayerPrefs.SetFloat(key, value); } public float GetGameAudioVolume(float value) { return audio.volume; } public void SetGameAudioVolume(float value) { string key = "GameAudio"; audio.volume = value; PlayerPrefs.SetFloat(key, value); } public void ChangBgVolumeOnGameScene(float value) { bgAudio.volume = value; } public void ChangGameVolueOnGameScene(float value) { audio.volume = value; audioTwo.volume = value; audioThree.volume = value; gens.volume = value; nets.volume = value; /*for (int i = 0; i < 6; i++) { gens[i].volume = value; }*/ } public void EnterMainScene() { bgAudio.volume = 1.0f; audio.volume = 1.0f; } IEnumerator playBgAudioClip(string name) { AudioClip Aclip; if (AppConst.UpdateMode) { AssetBundle built = null; #if UNITY_ANDROID || UNITY_IPHONE string path_2 = "file:///" + AppConst.FrameworkRoot + "/datingui_" + AppConst.UIVersion + "/" + name + ".u3d"; using (UnityWebRequest uwr = UnityWebRequestAssetBundle.GetAssetBundle(path_2)) { yield return uwr.SendWebRequest(); if (uwr.result == UnityWebRequest.Result.Success) { built = DownloadHandlerAssetBundle.GetContent(uwr); } else { Debug.Log("UnityWebRequest error: " + uwr.error + " " + path_2); } } #else byte[] data = null; string path_ = AppConst.FrameworkRoot + "/datingui_" + AppConst.UIVersion + "/" + name + ".u3d"; if (File.Exists(path_)) { FileStream file_ = new FileStream(path_, FileMode.Open, FileAccess.Read); data = new byte[file_.Length]; file_.Read(data, 0, (int)file_.Length); file_.Close(); } if (data != null) { built = AssetBundle.LoadFromMemory(data); } #endif if (built != null) { Aclip = built.LoadAsset(name) as AudioClip; built.Unload(false); Add(name, Aclip); bgAudio.clip = Aclip; bgAudio.Play(); } } else { string path = "datingui_" + AppConst.UIVersion + "/" + name; yield return Aclip = (AudioClip)Resources.Load(path, typeof(AudioClip)); bgAudio.clip = Aclip; bgAudio.Play(); } } /// /// ÊÇ·ñ²¥·Å±³¾°ÒôÀÖ£¬Ä¬ÈÏÊÇ1£º²¥·Å /// /// <returns></returns> public bool CanPlayBackSound() { string key = "BackSound"; int i = PlayerPrefs.GetInt(key, 1); return i == 1; } /// /// ²¥·Å±³¾°ÒôÀÖ /// /// public void PlayBacksound(string name, bool canPlay) { if (bgAudio.clip != null) { if (name.IndexOf(bgAudio.clip.name) > -1) { if (!canPlay) { bgAudio.Stop(); bgAudio.clip = null; //Util.ClearMemory(); return; } } } if (canPlay) { bgAudio.loop = true; //audio.clip = LoadAudioClip(name); //audio.Play(); AudioClip Aclip; Aclip = Get(name); if (Aclip != null) { bgAudio.clip = Aclip; bgAudio.Play(); return; } else { StartCoroutine(playBgAudioClip(name)); } } else { bgAudio.Stop(); bgAudio.clip = null; //Util.ClearMemory(); } } public void PlayGameAudio(string name, bool canPlay) { if (audio.clip != null) { if (name.IndexOf(audio.clip.name) > -1) { if (!canPlay) { audio.Stop(); audio.clip = null; //Util.ClearMemory(); return; } } } if (canPlay) { audio.loop = false; //audio.clip = LoadAudioClip(name); //audio.Play(); AudioClip Aclip; Aclip = Get(name); if (Aclip != null) { audio.clip = Aclip; audio.Play(); return; } else { Debug.Log("...GameAudio..is ..null"); } } else { audio.Stop(); audio.clip = null; //Util.ClearMemory(); } } public void LoopPlayGameAudio(string name) { if (audio.clip != null) { if (name.IndexOf(audio.clip.name) > -1) { audio.loop = true; return; } } AudioClip Aclip; Aclip = Get(name); if (Aclip != null) { //audio.loop = true; audio.clip = Aclip; audio.loop = true; audio.Play(); return; } else { Debug.Log("...GameAudio..is ..null"); } } /// /// ÊÇ·ñ²¥·ÅÒôЧ,ĬÈÏÊÇ1£º²¥·Å /// /// <returns></returns> public bool CanPlaySoundEffect() { string key = "SoundEffect"; int i = PlayerPrefs.GetInt(key, 1); return i == 1; } /// /// ²¥·ÅÒôƵ¼ô¼­ /// /// /// public void Play(AudioClip clip, Vector3 position) { if (!CanPlaySoundEffect()) return; AudioSource.PlayClipAtPoint(clip, position); } /// /// Í£Ö¹ÒôÀÖ /// public void StopBgAudio() { bgAudio.Stop(); //string key = "BackSound"; //PlayerPrefs.SetInt(key,0); Debug.Log("....BackSoundStopAudio"); } /// /// ²¥·ÅÒôÀÖ /// public void PlayBgAudio() { bgAudio.Play(); //string key = "BackSound"; //PlayerPrefs.SetInt(key,1); Debug.Log("....BackSoundPlayAudio"); } public void AudioTwoPlayOneShot(string name) { AudioClip Aclip; Aclip = Get(name); if (Aclip) { //audioTwo.clip = Aclip; audioTwo.PlayOneShot(Aclip); } } public void AudioThreePlayOneShot(string name) { AudioClip Aclip; Aclip = Get(name); if (Aclip) { //audioThree.clip = Aclip; audioThree.PlayOneShot(Aclip); } } public void AudioPlayOneShot(string name) { AudioClip Aclip; Aclip = Get(name); if (Aclip) { //audio.clip = Aclip; audio.PlayOneShot(Aclip); } } public void AudioPlayGen(string name) { AudioClip Aclip; Aclip = Get(name); if (Aclip) { gens.clip = Aclip; gens.Play(); } /*if (genSeat < 6) { AudioClip Aclip; Aclip = Get(name); if (Aclip) { gens[genSeat].PlayOneShot(Aclip); } }*/ } public void AudioPlayNet(string name) { AudioClip Aclip; Aclip = Get(name); if (Aclip) { nets.clip = Aclip; nets.Play(); } } public void ExitGame() { nets.Stop(); gens.Stop(); bgAudio.Stop(); audio.Stop(); audioTwo.Stop(); audioThree.Stop(); } float jindus; public AudioClip LoadAudioClipByPath(string name) { //string path; AudioClip Aclip = Get(name); if (Aclip != null) { return Aclip; } //AudioClip Aclip; if (AppConst.UpdateMode) { AssetBundle built = null; WWW www = null; #if UNITY_ANDROID //string path_2 = "file:///" + AppConst.FrameworkRoot + "/datingui_" + AppConst.UIVersion + "/" + path + name + ".u3d"; string path_2 = "file:///" + AppConst.FrameworkRoot + "/FishAudio_" + AppConst.UIVersion + "/" + name + ".u3d"; www = new WWW(@path_2); //yield return www; if (www.error == null) { built = www.assetBundle; } else { Debug.Log("www null-------- " + path_2); } #else string _path = AppConst.FrameworkRoot + "/FishAudio_" + AppConst.UIVersion + "/" + name + ".u3d"; byte[] data = null;// = OpenFile.GetFileData(path_); if (System.IO.File.Exists(_path)) { System.IO.FileStream file_ = new System.IO.FileStream(_path, System.IO.FileMode.Open, System.IO.FileAccess.Read); data = new byte[file_.Length]; int redline = 0; int allnum = 0; while (true) { byte[] reddata = new byte[1024000]; redline = file_.Read(reddata, 0, (int)reddata.Length); if (redline <= 0) { jindus = 1.0f; break; } else { //Debug.LogError(redline); System.Array.Copy(reddata, 0, data, allnum, redline); allnum += redline; jindus = (float)allnum / (float)data.Length; } } file_.Close(); } if (data != null) { built = AssetBundle.LoadFromMemory(data); } #endif if (built != null) { Aclip = built.LoadAsset(name) as AudioClip; built.Unload(false); Add(name, Aclip); if (Aclip == null) { Debug.Log("Aclip null-------- "); } if (www != null) www.Dispose(); return Aclip; } else { if (www != null) www.Dispose(); return null; } } else { //string path_3 = "datingui_" + AppConst.UIVersion + "/" + path + name; string path_3 = "FishAudio_" + AppConst.UIVersion + "/" + name; Aclip = (AudioClip)Resources.Load(path_3, typeof(AudioClip)); Add(name, Aclip); if (Aclip == null) { Debug.Log("Aclip null-------- "); } return Aclip; } } public void ClearGameAudioClip(string key) { if (sounds[key] != null) { sounds.Remove(key); } } } }

/* * Tencent is pleased to support the open source community by making xLua available. * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. * Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at * http://opensource.org/licenses/MIT * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #if USE_UNI_LUA using LuaAPI = UniLua.Lua; using RealStatePtr = UniLua.ILuaState; using LuaCSFunction = UniLua.CSharpFunctionDelegate; #else using LuaAPI = XLua.LuaDLL.Lua; using RealStatePtr = System.IntPtr; using LuaCSFunction = XLua.LuaDLL.lua_CSFunction; #endif namespace XLua { using System; using System.Collections.Generic; public class LuaEnv : IDisposable { internal RealStatePtr L; private LuaTable _G; internal ObjectTranslator translator; internal int errorFuncRef = -1; #if THREAD_SAFT || HOTFIX_ENABLE internal object luaEnvLock = new object(); #endif public LuaEnv() { #if THREAD_SAFT || HOTFIX_ENABLE lock(luaEnvLock) { #endif LuaIndexes.LUA_REGISTRYINDEX = LuaAPI.xlua_get_registry_index(); ; // Create State L = LuaAPI.luaL_newstate(); //Init Base Libs LuaAPI.luaopen_xlua(L); LuaAPI.luaopen_i64lib(L); LuaAPI.luaopen_perflib(L); translator = new ObjectTranslator(this, L); translator.createFunctionMetatable(L); translator.OpenLib(L); ObjectTranslatorPool.Instance.Add(L, translator); LuaAPI.lua_atpanic(L, StaticLuaCallbacks.Panic); LuaAPI.lua_pushstdcallcfunction(L, StaticLuaCallbacks.Print); LuaAPI.lua_setglobal(L, "print"); //template engine lib register TemplateEngine.LuaTemplate.OpenLib(L); AddSearcher(StaticLuaCallbacks.LoadBuiltinLib, 2); // just after the preload searcher AddSearcher(StaticLuaCallbacks.LoadFromCustomLoaders, 3); AddSearcher(StaticLuaCallbacks.LoadFromResource, 4); AddSearcher(StaticLuaCallbacks.LoadFromStreamingAssetsPath, -1); DoString(init_xlua, "Init"); init_xlua = null; AddBuildin("socket.core", StaticLuaCallbacks.LoadSocketCore); AddBuildin("socket", StaticLuaCallbacks.LoadSocketCore); AddBuildin("mime.core", StaticLuaCallbacks.LoadMimeCore); AddBuildin("rapidjson", StaticLuaCallbacks.LoadRapidJson); AddBuildin("lpeg", StaticLuaCallbacks.LoadLpeg); AddBuildin("sproto.core", StaticLuaCallbacks.LoadSprotoCore); //AddBuildin("pack", StaticLuaCallbacks.LoadPack); LuaAPI.lua_newtable(L); //metatable of indexs and newindexs functions LuaAPI.xlua_pushasciistring(L, "__index"); LuaAPI.lua_pushstdcallcfunction(L, StaticLuaCallbacks.MetaFuncIndex); LuaAPI.lua_rawset(L, -3); LuaAPI.xlua_pushasciistring(L, Utils.LuaIndexsFieldName); LuaAPI.lua_newtable(L); LuaAPI.lua_pushvalue(L, -3); LuaAPI.lua_setmetatable(L, -2); LuaAPI.lua_rawset(L, LuaIndexes.LUA_REGISTRYINDEX); LuaAPI.xlua_pushasciistring(L, Utils.LuaNewIndexsFieldName); LuaAPI.lua_newtable(L); LuaAPI.lua_pushvalue(L, -3); LuaAPI.lua_setmetatable(L, -2); LuaAPI.lua_rawset(L, LuaIndexes.LUA_REGISTRYINDEX); LuaAPI.xlua_pushasciistring(L, Utils.LuaClassIndexsFieldName); LuaAPI.lua_newtable(L); LuaAPI.lua_pushvalue(L, -3); LuaAPI.lua_setmetatable(L, -2); LuaAPI.lua_rawset(L, LuaIndexes.LUA_REGISTRYINDEX); LuaAPI.xlua_pushasciistring(L, Utils.LuaClassNewIndexsFieldName); LuaAPI.lua_newtable(L); LuaAPI.lua_pushvalue(L, -3); LuaAPI.lua_setmetatable(L, -2); LuaAPI.lua_rawset(L, LuaIndexes.LUA_REGISTRYINDEX); LuaAPI.lua_pop(L, 1); // pop metatable of indexs and newindexs functions LuaAPI.xlua_pushasciistring(L, "xlua_main_thread"); LuaAPI.lua_pushthread(L); LuaAPI.lua_rawset(L, LuaIndexes.LUA_REGISTRYINDEX); translator.Alias(typeof(Type), "System.MonoType"); LuaAPI.lua_getglobal(L, "_G"); translator.Get(L, -1, out _G); LuaAPI.lua_pop(L, 1); errorFuncRef = LuaAPI.get_error_func_ref(L); if (initers != null) { for (int i = 0; i < initers.Count; i++) { initers[i](this, translator); } } translator.CreateArrayMetatable(L); translator.CreateDelegateMetatable(L); #if THREAD_SAFT || HOTFIX_ENABLE } #endif } private static List<Action<LuaEnv, ObjectTranslator>> initers = null; public static void AddIniter(Action<LuaEnv, ObjectTranslator> initer) { if (initers == null) { initers = new List<Action<LuaEnv, ObjectTranslator>>(); } initers.Add(initer); } public LuaTable Global { get { return _G; } } public T LoadString<T>(string chunk, string chunkName = "chunk", LuaTable env = null) { #if THREAD_SAFT || HOTFIX_ENABLE lock (luaEnvLock) { #endif if (typeof(T) != typeof(LuaFunction) && !typeof(T).IsSubclassOf(typeof(Delegate))) { throw new InvalidOperationException(typeof(T).Name + " is not a delegate type nor LuaFunction"); } int oldTop = LuaAPI.lua_gettop(L); if (LuaAPI.luaL_loadbuffer(L, chunk, chunkName) != 0) ThrowExceptionFromError(oldTop); if (env != null) { env.push(L); LuaAPI.lua_setfenv(L, -2); } T result = (T)translator.GetObject(L, -1, typeof(T)); LuaAPI.lua_settop(L, oldTop); return result; #if THREAD_SAFT || HOTFIX_ENABLE } #endif } public LuaFunction LoadString(string chunk, string chunkName = "chunk", LuaTable env = null) { return LoadString<LuaFunction>(chunk, chunkName, env); } public object[] DoString(string chunk, string chunkName = "chunk", LuaTable env = null) { #if THREAD_SAFT || HOTFIX_ENABLE lock (luaEnvLock) { #endif int oldTop = LuaAPI.lua_gettop(L); int errFunc = LuaAPI.load_error_func(L, errorFuncRef); if (LuaAPI.luaL_loadbuffer(L, chunk, chunkName) == 0) { if (env != null) { env.push(L); LuaAPI.lua_setfenv(L, -2); } if (LuaAPI.lua_pcall(L, 0, -1, errFunc) == 0) { LuaAPI.lua_remove(L, errFunc); return translator.popValues(L, oldTop); } else ThrowExceptionFromError(oldTop); } else ThrowExceptionFromError(oldTop); return null; #if THREAD_SAFT || HOTFIX_ENABLE } #endif } private void AddSearcher(LuaCSFunction searcher, int index) { #if THREAD_SAFT || HOTFIX_ENABLE lock (luaEnvLock) { #endif //insert the loader LuaAPI.xlua_getloaders(L); if (!LuaAPI.lua_istable(L, -1)) { throw new Exception("Can not set searcher!"); } uint len = LuaAPI.xlua_objlen(L, -1); index = index < 0 ? (int)(len + index + 2) : index; for (int e = (int)len + 1; e > index; e--) { LuaAPI.xlua_rawgeti(L, -1, e - 1); LuaAPI.xlua_rawseti(L, -2, e); } LuaAPI.lua_pushstdcallcfunction(L, searcher); LuaAPI.xlua_rawseti(L, -2, index); LuaAPI.lua_pop(L, 1); #if THREAD_SAFT || HOTFIX_ENABLE } #endif } public void Alias(Type type, string alias) { translator.Alias(type, alias); } int last_check_point = 0; int max_check_per_tick = 20; static bool ObjectValidCheck(object obj) { return (!(obj is UnityEngine.Object)) || ((obj as UnityEngine.Object) != null); } Func<object, bool> object_valid_checker = new Func<object, bool>(ObjectValidCheck); public void Tick() { #if THREAD_SAFT || HOTFIX_ENABLE lock (luaEnvLock) { #endif lock (refQueue) { while (refQueue.Count > 0) { GCAction gca = refQueue.Dequeue(); translator.ReleaseLuaBase(L, gca.Reference, gca.IsDelegate); } } last_check_point = translator.objects.Check(last_check_point, max_check_per_tick, object_valid_checker, translator.reverseMap); #if THREAD_SAFT || HOTFIX_ENABLE } #endif } //兼容API public void GC() { Tick(); } public LuaTable NewTable() { #if THREAD_SAFT || HOTFIX_ENABLE lock (luaEnvLock) { #endif int oldTop = LuaAPI.lua_gettop(L); LuaAPI.lua_newtable(L); LuaTable returnVal = (LuaTable)translator.GetObject(L, -1, typeof(LuaTable)); LuaAPI.lua_settop(L, oldTop); return returnVal; #if THREAD_SAFT || HOTFIX_ENABLE } #endif } private bool disposed = false; public void Dispose() { Dispose(true); System.GC.Collect(); System.GC.WaitForPendingFinalizers(); } public virtual void Dispose(bool dispose) { #if THREAD_SAFT || HOTFIX_ENABLE lock (luaEnvLock) { #endif if (disposed) return; Tick(); LuaAPI.lua_close(L); ObjectTranslatorPool.Instance.Remove(L); if (translator != null) { translator = null; } L = IntPtr.Zero; disposed = true; #if THREAD_SAFT || HOTFIX_ENABLE } #endif } public void ThrowExceptionFromError(int oldTop) { #if THREAD_SAFT || HOTFIX_ENABLE lock (luaEnvLock) { #endif object err = translator.GetObject(L, -1); LuaAPI.lua_settop(L, oldTop); // A pre-wrapped exception - just rethrow it (stack trace of InnerException will be preserved) Exception ex = err as Exception; if (ex != null) throw ex; // A non-wrapped Lua error (best interpreted as a string) - wrap it and throw it if (err == null) err = "Unknown Lua Error"; throw new LuaException(err.ToString()); #if THREAD_SAFT || HOTFIX_ENABLE } #endif } internal struct GCAction { public int Reference; public bool IsDelegate; } Queue<GCAction> refQueue = new Queue<GCAction>(); internal void equeueGCAction(GCAction action) { lock (refQueue) { refQueue.Enqueue(action); } } private string init_xlua = @" local metatable = {} local rawget = rawget local setmetatable = setmetatable local import_type = xlua.import_type local load_assembly = xlua.load_assembly function metatable:__index(key) local fqn = rawget(self,'.fqn') fqn = ((fqn and fqn .. '.') or '') .. key local obj = import_type(fqn) if obj == nil then -- It might be an assembly, so we load it too. obj = { ['.fqn'] = fqn } setmetatable(obj, metatable) elseif obj == true then return rawget(self, key) end -- Cache this lookup rawset(self, key, obj) return obj end -- A non-type has been called; e.g. foo = System.Foo() function metatable:__call(...) error('No such type: ' .. rawget(self,'.fqn'), 2) end CS = CS or {} setmetatable(CS, metatable) typeof = function(t) return t.UnderlyingSystemType end cast = xlua.cast if not setfenv or not getfenv then local function getfunction(level) local info = debug.getinfo(level + 1, 'f') return info and info.func end function setfenv(fn, env) if type(fn) == 'number' then fn = getfunction(fn + 1) end local i = 1 while true do local name = debug.getupvalue(fn, i) if name == '_ENV' then debug.upvaluejoin(fn, i, (function() return env end), 1) break elseif not name then break end i = i + 1 end return fn end function getfenv(fn) if type(fn) == 'number' then fn = getfunction(fn + 1) end local i = 1 while true do local name, val = debug.getupvalue(fn, i) if name == '_ENV' then return val elseif not name then break end i = i + 1 end end end xlua.hotfix = function(cs, field, func) local tbl = (type(field) == 'table') and field or {[field] = func} for k, v in pairs(tbl) do local cflag = '' if k == '.ctor' then cflag = '_c' k = 'ctor' end xlua.access(cs, cflag .. '__Hitfix0_'..k, v) -- at least one pcall(function() for i = 1, 99 do xlua.access(cs, '__Hitfix'..i..'_'..k, v) end end) end end "; public delegate byte[] CustomLoader(ref string filepath); internal List<CustomLoader> customLoaders = new List<CustomLoader>(); //loader : CustomLoader, filepath参数:(ref类型)输入是require的参数,如果需要支持调试,需要输出真实路径。 // 返回值:如果返回null,代表加载该源下无合适的文件,否则返回UTF8编码的byte[] public void AddLoader(CustomLoader loader) { customLoaders.Add(loader); } internal Dictionary<string, LuaCSFunction> buildin_initer = new Dictionary<string, LuaCSFunction>(); public void AddBuildin(string name, LuaCSFunction initer) { if (!initer.Method.IsStatic || !Attribute.IsDefined(initer.Method, typeof(MonoPInvokeCallbackAttribute))) { throw new Exception("initer must be static and has MonoPInvokeCallback Attribute!"); } buildin_initer.Add(name, initer); } //The garbage-collector pause controls how long the collector waits before starting a new cycle. //Larger values make the collector less aggressive. Values smaller than 100 mean the collector //will not wait to start a new cycle. A value of 200 means that the collector waits for the total //memory in use to double before starting a new cycle. public int GcPause { get { #if THREAD_SAFT || HOTFIX_ENABLE lock (luaEnvLock) { #endif int val = LuaAPI.lua_gc(L, LuaGCOptions.LUA_GCSETPAUSE, 200); LuaAPI.lua_gc(L, LuaGCOptions.LUA_GCSETPAUSE, val); return val; #if THREAD_SAFT || HOTFIX_ENABLE } #endif } set { #if THREAD_SAFT || HOTFIX_ENABLE lock (luaEnvLock) { #endif LuaAPI.lua_gc(L, LuaGCOptions.LUA_GCSETPAUSE, value); #if THREAD_SAFT || HOTFIX_ENABLE } #endif } } //The step multiplier controls the relative speed of the collector relative to memory allocation. //Larger values make the collector more aggressive but also increase the size of each incremental //step. Values smaller than 100 make the collector too slow and can result in the collector never //finishing a cycle. The default, 200, means that the collector runs at "twice" the speed of memory //allocation. public int GcStepmul { get { #if THREAD_SAFT || HOTFIX_ENABLE lock (luaEnvLock) { #endif int val = LuaAPI.lua_gc(L, LuaGCOptions.LUA_GCSETSTEPMUL, 200); LuaAPI.lua_gc(L, LuaGCOptions.LUA_GCSETSTEPMUL, val); return val; #if THREAD_SAFT || HOTFIX_ENABLE } #endif } set { #if THREAD_SAFT || HOTFIX_ENABLE lock (luaEnvLock) { #endif LuaAPI.lua_gc(L, LuaGCOptions.LUA_GCSETSTEPMUL, value); #if THREAD_SAFT || HOTFIX_ENABLE } #endif } } public void FullGc() { #if THREAD_SAFT || HOTFIX_ENABLE lock (luaEnvLock) { #endif LuaAPI.lua_gc(L, LuaGCOptions.LUA_GCCOLLECT, 0); #if THREAD_SAFT || HOTFIX_ENABLE } #endif } public void StopGc() { #if THREAD_SAFT || HOTFIX_ENABLE lock (luaEnvLock) { #endif LuaAPI.lua_gc(L, LuaGCOptions.LUA_GCSTOP, 0); #if THREAD_SAFT || HOTFIX_ENABLE } #endif } public void RestartGc() { #if THREAD_SAFT || HOTFIX_ENABLE lock (luaEnvLock) { #endif LuaAPI.lua_gc(L, LuaGCOptions.LUA_GCRESTART, 0); #if THREAD_SAFT || HOTFIX_ENABLE } #endif } public bool GcStep(int data) { #if THREAD_SAFT || HOTFIX_ENABLE lock (luaEnvLock) { #endif return LuaAPI.lua_gc(L, LuaGCOptions.LUA_GCSTEP, data) != 0; #if THREAD_SAFT || HOTFIX_ENABLE } #endif } public int Memroy { get { #if THREAD_SAFT || HOTFIX_ENABLE lock (luaEnvLock) { #endif return LuaAPI.lua_gc(L, LuaGCOptions.LUA_GCCOUNT, 0); #if THREAD_SAFT || HOTFIX_ENABLE } #endif } } } } LuaException: c# exception:System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary. at System.Collections.Generic.Dictionary2[System.String,FishPathData].get_Item (System.String key) [0x000a2] in /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:150 at FishPathManager.getPath (System.String name) [0x00021] in D:\Lua_Dating546\Assets\Scripts\Util\FishPathManager.cs:117 at fish.setPath (System.String pathName, Single lifeTime, Boolean freeGroup, Single roat, Single speed) [0x00000] in D:\Lua_Dating546\Assets\Scripts\Util\fish.cs:744 at CSObjectWrap.fishWrap.setPath (IntPtr L) [0x000a4] in D:\Lua_Dating546\Assets\XLua\Gen\fishWrap.cs:403 stack traceback: [C]: in method 'setPath' game.fish.gameobject.Fish:192: in function 'game.fish.gameobject.Fish.setPath' game.fish.gameobject.Fish:131: in function 'game.fish.gameobject.Fish.initInfo' game.fish.view.FishGameRoot:881: in function 'game.fish.view.FishGameRoot.createOneFish' game.fish.view.FishGameRoot:776: in function 'game.fish.view.FishGameRoot.Update' base.system.UpdateBeat:22: in function 'base.system.UpdateBeat.Update' base.Main:13: in function 'update' XLua.LuaEnv.ThrowExceptionFromError (Int32 oldTop) (at Assets/XLua/Src/LuaEnv.cs:367) XLua.DelegateBridge.SystemVoid () (at Assets/XLua/Gen/DelegatesGensBridge.cs:34) LuaFramework.LuaManager.Update () (at Assets/Scripts/Manager/LuaManager.cs:111)

using UnityEngine; using System.Collections; using System.Collections.Generic; using XLua; namespace LuaFramework { [LuaCallCSharp] public class SoundManager : Manager { public AudioSource bgAudio; public AudioSource audio; public AudioSource audioTwo; public AudioSource audioThree; //public AudioSource[] gens = new AudioSource[6]; public AudioSource gens; public AudioSource nets; private Hashtable sounds = new Hashtable(); public static SoundManager _instance; void Awake() { _instance = this; } public static SoundManager Instance { get { return _instance; } } void Start() { bgAudio = GetComponent<AudioSource>(); audio = transform.Find("Audio").GetComponent<AudioSource>(); audioTwo = transform.Find("AudioTwo").GetComponent<AudioSource>(); audioThree = transform.Find("AudioThree").GetComponent<AudioSource>(); gens = transform.Find("Gen").GetComponent<AudioSource>(); nets = transform.Find("Net").GetComponent<AudioSource>(); /*for (int i = 0; i < 6; i++) { gens[i] = transform.Find("Gen"+i).GetComponent<AudioSource>(); }*/ } /// /// Ìí¼ÓÒ»¸öÉùÒô /// void Add(string key, AudioClip value) { if (sounds[key] != null || value == null) return; //Debug.Log("..add..AudioClip.."+key); sounds.Add(key, value); } public void ClearGameAudio(string key) { if (sounds[key] != null) { sounds[key] = null; } } /// /// »ñȡһ¸öÉùÒô /// AudioClip Get(string key) { if (sounds[key] == null) return null; return sounds[key] as AudioClip; } public float GetBgAudioVolume() { return bgAudio.volume; } public void SetBgAudioVolume(float value) { string key = "BgSound"; bgAudio.volume = value; PlayerPrefs.SetFloat(key, value); } public float GetGameAudioVolume(float value) { return audio.volume; } public void SetGameAudioVolume(float value) { string key = "GameAudio"; audio.volume = value; PlayerPrefs.SetFloat(key,value); } public void ChangBgVolumeOnGameScene(float value) { bgAudio.volume = value; } public void ChangGameVolueOnGameScene(float value) { audio.volume = value; audioTwo.volume = value; audioThree.volume = value; gens.volume = value; nets.volume = value; /*for (int i = 0; i < 6; i++) { gens[i].volume = value; }*/ } public void EnterMainScene() { bgAudio.volume = 1.0f; audio.volume = 1.0f; } IEnumerator playBgAudioClip(string name) { AudioClip Aclip; if (AppConst.UpdateMode) { AssetBundle built = null; #if UNITY_ANDROID || UNITY_IPHONE string path_2 = "file:///" + AppConst.FrameworkRoot + "/datingui_" + AppConst.UIVersion + "/" + name + ".u3d"; WWW www = new WWW(@path_2); yield return www; if (www.error == null) { yield return built = www.assetBundle; } else { Debug.Log("www null-------- " + path_2); } #else byte[] data = null;// = OpenFile.GetFileData(path_); if (File.Exists(path_)) { FileStream file_ = new FileStream(path_, FileMode.Open, FileAccess.Read); yield return data = new byte[file_.Length]; file_.Read(data, 0, (int)file_.Length); file_.Close(); } if (data != null) { yield return built = AssetBundle.LoadFromMemory(data); } #endif if (built != null) { Aclip = built.LoadAsset(name) as AudioClip; built.Unload(false); Add(name, Aclip); bgAudio.clip = Aclip; bgAudio.Play(); } www.Dispose(); }else { string path = "datingui_" + AppConst.UIVersion + "/" + name; yield return Aclip = (AudioClip)Resources.Load(path, typeof(AudioClip)); bgAudio.clip = Aclip; bgAudio.Play(); } } /// /// ÊÇ·ñ²¥·Å±³¾°ÒôÀÖ£¬Ä¬ÈÏÊÇ1£º²¥·Å /// /// <returns></returns> public bool CanPlayBackSound() { string key = "BackSound"; int i = PlayerPrefs.GetInt(key, 1); return i == 1; } /// /// ²¥·Å±³¾°ÒôÀÖ /// /// public void PlayBacksound(string name, bool canPlay) { if (bgAudio.clip != null) { if (name.IndexOf(bgAudio.clip.name) > -1) { if (!canPlay) { bgAudio.Stop(); bgAudio.clip = null; //Util.ClearMemory(); return; } } } if (canPlay) { bgAudio.loop = true; //audio.clip = LoadAudioClip(name); //audio.Play(); AudioClip Aclip; Aclip = Get(name); if (Aclip != null) { bgAudio.clip = Aclip; bgAudio.Play(); return; } else { StartCoroutine(playBgAudioClip(name)); } } else { bgAudio.Stop(); bgAudio.clip = null; //Util.ClearMemory(); } } public void PlayGameAudio(string name, bool canPlay) { if (audio.clip != null) { if (name.IndexOf(audio.clip.name) > -1) { if (!canPlay) { audio.Stop(); audio.clip = null; //Util.ClearMemory(); return; } } } if (canPlay) { audio.loop = false; //audio.clip = LoadAudioClip(name); //audio.Play(); AudioClip Aclip; Aclip = Get(name); if (Aclip != null) { audio.clip = Aclip; audio.Play(); return; } else { Debug.Log("...GameAudio..is ..null"); } } else { audio.Stop(); audio.clip = null; //Util.ClearMemory(); } } public void LoopPlayGameAudio(string name) { if (audio.clip != null) { if (name.IndexOf(audio.clip.name) > -1) { audio.loop = true; return; } } AudioClip Aclip; Aclip = Get(name); if (Aclip != null) { //audio.loop = true; audio.clip = Aclip; audio.loop = true; audio.Play(); return; } else { Debug.Log("...GameAudio..is ..null"); } } /// /// ÊÇ·ñ²¥·ÅÒôЧ,ĬÈÏÊÇ1£º²¥·Å /// /// <returns></returns> public bool CanPlaySoundEffect() { string key = "SoundEffect"; int i = PlayerPrefs.GetInt(key, 1); return i == 1; } /// /// ²¥·ÅÒôƵ¼ô¼­ /// /// /// public void Play(AudioClip clip, Vector3 position) { if (!CanPlaySoundEffect()) return; AudioSource.PlayClipAtPoint(clip, position); } /// /// Í£Ö¹ÒôÀÖ /// public void StopBgAudio() { bgAudio.Stop(); //string key = "BackSound"; //PlayerPrefs.SetInt(key,0); Debug.Log("....BackSoundStopAudio"); } /// /// ²¥·ÅÒôÀÖ /// public void PlayBgAudio() { bgAudio.Play(); //string key = "BackSound"; //PlayerPrefs.SetInt(key,1); Debug.Log("....BackSoundPlayAudio"); } public void AudioTwoPlayOneShot(string name) { AudioClip Aclip; Aclip = Get(name); if (Aclip) { //audioTwo.clip = Aclip; audioTwo.PlayOneShot(Aclip); } } public void AudioThreePlayOneShot(string name) { AudioClip Aclip; Aclip = Get(name); if (Aclip) { //audioThree.clip = Aclip; audioThree.PlayOneShot(Aclip); } } public void AudioPlayOneShot(string name) { AudioClip Aclip; Aclip = Get(name); if (Aclip) { //audio.clip = Aclip; audio.PlayOneShot(Aclip); } } public void AudioPlayGen(string name) { AudioClip Aclip; Aclip = Get(name); if (Aclip) { gens.clip = Aclip; gens.Play(); } /*if (genSeat < 6) { AudioClip Aclip; Aclip = Get(name); if (Aclip) { gens[genSeat].PlayOneShot(Aclip); } }*/ } public void AudioPlayNet(string name) { AudioClip Aclip; Aclip = Get(name); if (Aclip) { nets.clip = Aclip; nets.Play(); } } public void ExitGame() { nets.Stop(); gens.Stop(); bgAudio.Stop(); audio.Stop(); audioTwo.Stop(); audioThree.Stop(); } float jindus; public AudioClip LoadAudioClipByPath(string name) { //string path; AudioClip Aclip = Get(name); if (Aclip != null) { return Aclip; } //AudioClip Aclip; if (AppConst.UpdateMode) { AssetBundle built = null; WWW www = null; #if UNITY_ANDROID //string path_2 = "file:///" + AppConst.FrameworkRoot + "/datingui_" + AppConst.UIVersion + "/" + path + name + ".u3d"; string path_2 = "file:///" + AppConst.FrameworkRoot + "/FishAudio_" + AppConst.UIVersion + "/" + name + ".u3d"; www = new WWW(@path_2); //yield return www; if (www.error == null) { built = www.assetBundle; } else { Debug.Log("www null-------- " + path_2); } #else string _path = AppConst.FrameworkRoot + "/FishAudio_"+ AppConst.UIVersion + "/" + name + ".u3d"; byte[] data = null;// = OpenFile.GetFileData(path_); if (System.IO.File.Exists(_path)) { System.IO.FileStream file_ = new System.IO.FileStream(_path, System.IO.FileMode.Open, System.IO.FileAccess.Read); data = new byte[file_.Length]; int redline = 0; int allnum = 0; while (true) { byte[] reddata = new byte[1024000]; redline = file_.Read(reddata, 0, (int)reddata.Length); if (redline <= 0) { jindus = 1.0f; break; } else { //Debug.LogError(redline); System.Array.Copy(reddata, 0, data, allnum, redline); allnum += redline; jindus = (float)allnum / (float)data.Length; } } file_.Close(); } if (data != null) { built = AssetBundle.LoadFromMemory(data); } #endif if (built != null) { Aclip = built.LoadAsset(name) as AudioClip; built.Unload(false); Add(name, Aclip); if (Aclip == null) { Debug.Log("Aclip null-------- "); } if (www != null) www.Dispose(); return Aclip; }else { if (www != null) www.Dispose(); return null; } }else { //string path_3 = "datingui_" + AppConst.UIVersion + "/" + path + name; string path_3 = "FishAudio_" + AppConst.UIVersion + "/" + name; Aclip = (AudioClip)Resources.Load(path_3, typeof(AudioClip)); Add(name, Aclip); if (Aclip == null) { Debug.Log("Aclip null-------- "); } return Aclip; } } public void ClearGameAudioClip(string key) { if (sounds[key] != null) { sounds.Remove(key); } } } }这个代码是Unity5.3.3f1版本的,现在升级到Unity2021.3.45f1版本后怎么兼容?并且把修改后的完整代码给我

using UnityEngine; using System; using System.Collections; using XLua; namespace LuaFramework { [LuaCallCSharp] public class ResourceManager : Manager { public static ResourceManager _instance; public LuaFunction onDestroy; private WWW _www; private LuaFunction onProgress; void Awake() { _instance = this; } // 修复1: 使用传统属性语法替代表达式体属性 public static ResourceManager Instance { get { return _instance; } } public void CreatUIObject(string UIPath, string objname, LuaFunction callBack = null) { #if UNITY_EDITOR if (!AppConst.UpdateMode) { string path = "datingui_" + AppConst.UIVersion.ToString() + "/" + UIPath + objname; UnityEngine.Object prefab = Resources.Load(path, typeof(GameObject)); if (prefab != null) { GameObject obj = Instantiate(prefab) as GameObject; obj.transform.localScale = Vector3.one; obj.transform.localPosition = Vector3.zero; if (callBack != null) { callBack.Call(obj); } } else { if (callBack != null) { callBack.Call(null); } } } else { StartCoroutine(LoadObj(AppConst.FrameworkRoot + "/datingui_" + AppConst.UIVersion + "/" + UIPath + objname + ".u3d", objname, callBack)); } #else StartCoroutine(LoadObj(AppConst.FrameworkRoot + "/datingui_" + AppConst.UIVersion + "/" + UIPath + objname + ".u3d", objname, callBack)); #endif } public void CreatGameObject(string GameName, string path, string objname, LuaFunction callBack = null) { #if UNITY_EDITOR if (!AppConst.UpdateMode) { GameObject obj = Instantiate(Resources.Load<GameObject>("gameui" + AppConst.UIVersion + "/" + GameName + "/" + path + objname)); if (obj != null) { obj.transform.localScale = Vector3.one; obj.transform.localPosition = Vector3.zero; } if (callBack != null) { callBack.Call(obj); } } else { string path_ = AppConst.FrameworkRoot + "/gameui" + AppConst.UIVersion + "/" + GameName + "/" + path + objname + ".u3d"; StartCoroutine(LoadObj(path_, objname, callBack)); } #else string path_ = AppConst.FrameworkRoot + "/gameui"+AppConst.UIVersion +"/" + GameName + "/" + path + objname + ".u3d"; StartCoroutine(LoadObj(path_, objname, callBack)); #endif } public void setProgressUpdate(LuaFunction callback) { onProgress = callback; } public void resetProgressUpdate() { onProgress = null; _www = null; } float jindus = 0.0f; void Update() { #if UNITY_ANDROID if (_www != null && onProgress != null) { onProgress.Call(_www.progress); } #else if (onProgress != null) { onProgress.Call(jindus); } #endif } IEnumerator LoadObj(string bundlePath, string ObjName, LuaFunction callBack = null) { AssetBundle built = null; #if UNITY_ANDROID string path_2 = "file:///" + bundlePath; WWW www = new WWW(@path_2); if (onProgress != null) { _www = www; } yield return www; if (www.error == null) { built = www.assetBundle; } else { Debug.Log("www error: " + www.error + " at path: " + path_2); } #else string path_ = bundlePath; byte[] data = null; if (System.IO.File.Exists(path_)) { System.IO.FileStream file_ = new System.IO.FileStream(path_, System.IO.FileMode.Open, System.IO.FileAccess.Read); data = new byte[file_.Length]; int redline = 0; int allnum = 0; while (true) { byte[] reddata = new byte[1024000]; redline = file_.Read(reddata, 0, reddata.Length); if (redline <= 0) { jindus = 1.0f; break; } else { System.Array.Copy(reddata, 0, data, allnum, redline); allnum += redline; jindus = (float)allnum / (float)data.Length; } yield return null; } file_.Close(); file_.Dispose(); } if (data != null) { built = AssetBundle.LoadFromMemory(data); } #endif GameObject obj = null; if (built != null) { UnityEngine.Object asset = built.LoadAsset(ObjName); if (asset != null) { obj = Instantiate(asset) as GameObject; if (obj != null) { obj.transform.localScale = Vector3.one; obj.transform.localPosition = Vector3.zero; } } built.Unload(false); } if (callBack != null) { callBack.Call(obj); } #if UNITY_ANDROID www.Dispose(); #endif yield break; } void OnDestroy() { if (onDestroy != null) { onDestroy.Call(); } } } }帮我检查一下优化代码在UNITY5.3.8里面使用

using UnityEngine; using System.Collections; using System.Net; using System.Threading; using System.IO; //using System.Text; //using System.Text.RegularExpressions; using System; /// /// 通知总下载文件大小 /// /// public delegate void NotifyFileSizeHandler(long fileSize); /// /// 通知已下载的文件(进度) /// /// public delegate void NotifyDownLoadedSizeHandler(float downLoadedSize); /// /// 通知下载错误消息 /// public delegate void NotifyDownLoadErrorHandler(); /// /// 通知下载完成 /// public delegate void NotifyDownLoadedCompleteHandler(string pathToSave); /// /// Http下载 /// public class HttpDownLoader : MonoBehaviour { private Thread thread; //static readonly object m_lockObj = new object(); //string saveZippath = string.Empty; string filenamepath = ""; long contentLength; private HttpWebRequest request; private HttpWebRequest requestGetCount; private HttpWebResponse readResponse; private HttpWebResponse myHttpWebResponse; int nReadSize = 0; long n = 0; int read = 0; bool isClosed = false; bool isHasError = false; bool isComplete = false; // //isInitData == 0 初始状态 //isInitData == 1 创建soket //isInitData == 2 soket创建成功,开始下载数据 //isInitData == 3 数据下载完成 int isInitData = 0; int len = 2 * 1024 * 1024; byte[] buffer; string uri = string.Empty; Stream ns; //NetworkStream networkStream; FileStream fileStream; public NotifyFileSizeHandler notifyFileSizeHandler; //总下载文件大小 public NotifyDownLoadedSizeHandler notifyDownLoadedSizeHandler;//已下载的文件大小 public Action notifyDownLoadErrorHandler; public NotifyDownLoadedCompleteHandler notifyDownLoadedCompleteHandler; //下载完成 void Awake() { buffer = new byte[len]; //创建线程 thread = new Thread(ThreadRun); } //线程通信 /// /// /// //线程执行方法 void ThreadRun() { while (true) { //lock(m_lockObj) { if (isComplete) { break; } if (isHasError) { break; //有异常则退出 } if (isInitData == 1) //创建socket { isInitData = 0; CreateSocket(); } else if (isInitData == 2) { fileStream.Write(buffer, 0, nReadSize); n = fileStream.Length; if (n < contentLength) { try { int idix = 0; while (idix < 60000) { //UnityEngine.Debug.Log(".......Read....... while (idix < 60000)........."); idix = idix + 1; try { nReadSize = ns.Read(buffer, 0, len); } catch { isHasError = true; } if (nReadSize > 0) { idix = 0; break; } if (isHasError) { break; } } if (idix >= 60000) { isHasError = true; ErrorCall(); } } catch { //关闭流 isHasError = true; ErrorCall(); } } else { if (!isClosed) { isClosed = true; ns.Close(); fileStream.Flush(); fileStream.Close(); isInitData = 3; isComplete = true; } } } if (thread != null) { Thread.Sleep(1); } //} } } void CreateSocket() { try { //UnityEngine.Debug.Log(".....CreateSocket.............."); //打开网络连接 try{ requestGetCount = (HttpWebRequest)HttpWebRequest.Create(uri); //setCommonHttpReqPara(ref requestGetCount); requestGetCount.Timeout = 5000; myHttpWebResponse = (HttpWebResponse)requestGetCount.GetResponse(); if (myHttpWebResponse.StatusCode == HttpStatusCode.OK || myHttpWebResponse.StatusCode == HttpStatusCode.PartialContent) { //UnityEngine.Debug.Log(".....myHttpWebResponse.StatusCode == HttpStatusCode.OK..........."); } else { //UnityEngine.Debug.Log(".....myHttpWebResponse.StatusCode.........."); //UnityEngine.Debug.Log(myHttpWebResponse.StatusCode); isHasError = true; ErrorCall(); return; } contentLength = myHttpWebResponse.ContentLength; requestGetCount.Abort(); requestGetCount = null; myHttpWebResponse.Close(); myHttpWebResponse = null; request = (HttpWebRequest)HttpWebRequest.Create(uri); request.Timeout = 5000; //setCommonHttpReqPara(ref request); } catch(WebException e) { //UnityEngine.Debug.Log(".....WebException....WebException..........."); isHasError = true; return; } //UnityEngine.Debug.Log(".....CreateSocket....contentLength..........."); //UnityEngine.Debug.Log(contentLength); //打开上次下载的文件或新建文件 long lStartPos = 0; if (File.Exists(filenamepath)) { fileStream = File.OpenWrite(filenamepath); lStartPos = fileStream.Length; fileStream.Seek(lStartPos, SeekOrigin.Current);//移动文件流中的当前指针 } else { fileStream = new FileStream(filenamepath, FileMode.Create); } if (lStartPos >= contentLength) { isComplete = true; return; } if (lStartPos > 0) { try { request.AddRange((int)lStartPos);//设置Range值 } catch { isHasError = true; } } //向服务器请求,获得服务器回应数据流 try { readResponse = (HttpWebResponse)request.GetResponse(); if (readResponse.StatusCode == HttpStatusCode.OK || readResponse.StatusCode == HttpStatusCode.PartialContent) { //UnityEngine.Debug.Log(".....readResponse.StatusCode == HttpStatusCode.OK..........."); ns = readResponse.GetResponseStream(); ns.ReadTimeout = 5000; } else { //UnityEngine.Debug.Log(".....readResponse.StatusCode.........."); //UnityEngine.Debug.Log(readResponse.StatusCode); isHasError = true; ErrorCall(); return; } } catch { isHasError = true; } int idix = 0; while(idix < 60000) { //UnityEngine.Debug.Log(".......CreateSocket....... while (idix < 60000)........."); idix = idix + 1; nReadSize = ns.Read(buffer, 0, len); if (nReadSize >0) { idix = 0; break; } if (isHasError) { break; } } if (idix >= 20000) { isHasError = true; ErrorCall(); } idix = 0; if (notifyFileSizeHandler != null) notifyFileSizeHandler(contentLength); isInitData = 2; } catch (Exception ex)//捕获异常 { isHasError = true; //关闭流 ErrorCall(); throw ex; } } void ErrorCall() { if (requestGetCount != null) { requestGetCount.Abort(); requestGetCount = null; } if (myHttpWebResponse != null) { myHttpWebResponse.Close(); myHttpWebResponse = null; } if (request != null) { request.Abort(); request = null; } if (readResponse != null) { readResponse.Close(); request = null; } isClosed = true; if (ns != null) { ns.Close(); ns = null; } if (fileStream != null) { fileStream.Close(); fileStream = null; } } void Start() { } public void Init(string downloadurl_, string SavePath_, NotifyDownLoadedSizeHandler progress, NotifyDownLoadedCompleteHandler finish, Action erro) { System.Net.ServicePointManager.DefaultConnectionLimit = 200; //UnityEngine.Debug.Log(".............downloadurl_.............."); //UnityEngine.Debug.Log(downloadurl_); n = 0; contentLength = 0; //lock (m_lockObj) { uri = downloadurl_; filenamepath = SavePath_; notifyDownLoadedSizeHandler = progress; notifyDownLoadedCompleteHandler = finish; notifyDownLoadErrorHandler = erro; isInitData = 1; //} //启动线程 thread.Start(); } public static HttpDownLoader newHttpDownLoader() { GameObject go = new GameObject(); go.name = "ResDownLoader"; HttpDownLoader result = go.AddComponent<HttpDownLoader>(); return result; } void Update() { if (isHasError) { if (thread != null) { thread.Abort(); thread.Join(); thread = null; } if (notifyDownLoadErrorHandler != null) { notifyDownLoadErrorHandler(); notifyDownLoadErrorHandler = null; } Destroy(gameObject); return; } if (n != 0) { if (notifyDownLoadedSizeHandler != null) { notifyDownLoadedSizeHandler((float)n / (float)contentLength); } } if (isComplete) { //UnityEngine.Debug.Log(".............isComplete............"); if (thread != null) { thread.Abort(); thread.Join(); thread = null; } notifyDownLoadErrorHandler = null; if (notifyDownLoadedCompleteHandler != null) { notifyDownLoadedCompleteHandler(filenamepath); Destroy(gameObject); return; } } } void OnDestroy() { if (thread != null) { thread.Abort(); thread.Join(); thread = null; } if (fileStream != null) { fileStream.Close(); fileStream.Dispose(); fileStream = null; } if (request != null) { request.Abort(); request = null; } if (requestGetCount != null) { requestGetCount.Abort(); requestGetCount = null; } if (myHttpWebResponse != null) { myHttpWebResponse.Close(); myHttpWebResponse = null; } if (readResponse !=null) { readResponse.Close(); readResponse = null; } if (ns != null) { ns.Close(); ns = null; } } }

#if USE_UNI_LUA using LuaAPI = UniLua.Lua; using RealStatePtr = UniLua.ILuaState; using LuaCSFunction = UniLua.CSharpFunctionDelegate; #else using LuaAPI = XLua.LuaDLL.Lua; using RealStatePtr = System.IntPtr; using LuaCSFunction = XLua.LuaDLL.lua_CSFunction; #endif using XLua; using System.Collections.Generic; namespace CSObjectWrap { public class UnityEngineWWWWrap { public static void __Register(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); Utils.BeginObjectRegister(typeof(UnityEngine.WWW), L, translator, 0, 5, 15, 1); Utils.RegisterFunc(L, Utils.METHOD_IDX, "Dispose", Dispose); Utils.RegisterFunc(L, Utils.METHOD_IDX, "InitWWW", InitWWW); Utils.RegisterFunc(L, Utils.METHOD_IDX, "GetAudioClip", GetAudioClip); Utils.RegisterFunc(L, Utils.METHOD_IDX, "GetAudioClipCompressed", GetAudioClipCompressed); Utils.RegisterFunc(L, Utils.METHOD_IDX, "LoadImageIntoTexture", LoadImageIntoTexture); Utils.RegisterFunc(L, Utils.GETTER_IDX, "responseHeaders", get_responseHeaders); Utils.RegisterFunc(L, Utils.GETTER_IDX, "text", get_text); Utils.RegisterFunc(L, Utils.GETTER_IDX, "bytes", get_bytes); Utils.RegisterFunc(L, Utils.GETTER_IDX, "size", get_size); Utils.RegisterFunc(L, Utils.GETTER_IDX, "error", get_error); Utils.RegisterFunc(L, Utils.GETTER_IDX, "texture", get_texture); Utils.RegisterFunc(L, Utils.GETTER_IDX, "textureNonReadable", get_textureNonReadable); Utils.RegisterFunc(L, Utils.GETTER_IDX, "audioClip", get_audioClip); Utils.RegisterFunc(L, Utils.GETTER_IDX, "isDone", get_isDone); Utils.RegisterFunc(L, Utils.GETTER_IDX, "progress", get_progress); Utils.RegisterFunc(L, Utils.GETTER_IDX, "uploadProgress", get_uploadProgress); Utils.RegisterFunc(L, Utils.GETTER_IDX, "bytesDownloaded", get_bytesDownloaded); Utils.RegisterFunc(L, Utils.GETTER_IDX, "url", get_url); Utils.RegisterFunc(L, Utils.GETTER_IDX, "assetBundle", get_assetBundle); Utils.RegisterFunc(L, Utils.GETTER_IDX, "threadPriority", get_threadPriority); Utils.RegisterFunc(L, Utils.SETTER_IDX, "threadPriority", set_threadPriority); Utils.EndObjectRegister(typeof(UnityEngine.WWW), L, translator, null, null, null, null, null); Utils.BeginClassRegister(typeof(UnityEngine.WWW), L, __CreateInstance, 4, 0, 0); Utils.RegisterFunc(L, Utils.CLS_IDX, "EscapeURL", EscapeURL_xlua_st_); Utils.RegisterFunc(L, Utils.CLS_IDX, "UnEscapeURL", UnEscapeURL_xlua_st_); Utils.RegisterFunc(L, Utils.CLS_IDX, "LoadFromCacheOrDownload", LoadFromCacheOrDownload_xlua_st_); Utils.RegisterObject(L, translator, Utils.CLS_IDX, "UnderlyingSystemType", typeof(UnityEngine.WWW)); Utils.EndClassRegister(typeof(UnityEngine.WWW), L, translator); } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int __CreateInstance(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { if(LuaAPI.lua_gettop(L) == 2 && (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING)) { string url = LuaAPI.lua_tostring(L, 2); UnityEngine.WWW __cl_gen_ret = new UnityEngine.WWW(url); translator.Push(L, __cl_gen_ret); return 1; } if(LuaAPI.lua_gettop(L) == 3 && (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING) && translator.Assignable<UnityEngine.WWWForm>(L, 3)) { string url = LuaAPI.lua_tostring(L, 2); UnityEngine.WWWForm form = (UnityEngine.WWWForm)translator.GetObject(L, 3, typeof(UnityEngine.WWWForm)); UnityEngine.WWW __cl_gen_ret = new UnityEngine.WWW(url, form); translator.Push(L, __cl_gen_ret); return 1; } if(LuaAPI.lua_gettop(L) == 3 && (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING) && (LuaAPI.lua_isnil(L, 3) || LuaAPI.lua_type(L, 3) == LuaTypes.LUA_TSTRING)) { string url = LuaAPI.lua_tostring(L, 2); byte[] postData = LuaAPI.lua_tobytes(L, 3); UnityEngine.WWW __cl_gen_ret = new UnityEngine.WWW(url, postData); translator.Push(L, __cl_gen_ret); return 1; } if(LuaAPI.lua_gettop(L) == 4 && (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING) && (LuaAPI.lua_isnil(L, 3) || LuaAPI.lua_type(L, 3) == LuaTypes.LUA_TSTRING) && translator.Assignable<System.Collections.Generic.Dictionary<string, string>>(L, 4)) { string url = LuaAPI.lua_tostring(L, 2); byte[] postData = LuaAPI.lua_tobytes(L, 3); System.Collections.Generic.Dictionary<string, string> headers = (System.Collections.Generic.Dictionary<string, string>)translator.GetObject(L, 4, typeof(System.Collections.Generic.Dictionary<string, string>)); UnityEngine.WWW __cl_gen_ret = new UnityEngine.WWW(url, postData, headers); translator.Push(L, __cl_gen_ret); return 1; } } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return LuaAPI.luaL_error(L, "invalid arguments to UnityEngine.WWW constructor!"); } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int Dispose(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); UnityEngine.WWW __cl_gen_to_be_invoked = (UnityEngine.WWW)translator.FastGetCSObj(L, 1); try { { __cl_gen_to_be_invoked.Dispose( ); return 0; } } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int InitWWW(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); UnityEngine.WWW __cl_gen_to_be_invoked = (UnityEngine.WWW)translator.FastGetCSObj(L, 1); try { { string url = LuaAPI.lua_tostring(L, 2); byte[] postData = LuaAPI.lua_tobytes(L, 3); string[] iHeaders = (string[])translator.GetObject(L, 4, typeof(string[])); __cl_gen_to_be_invoked.InitWWW( url, postData, iHeaders ); return 0; } } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int EscapeURL_xlua_st_(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); int __gen_param_count = LuaAPI.lua_gettop(L); try { if(__gen_param_count == 1&& (LuaAPI.lua_isnil(L, 1) || LuaAPI.lua_type(L, 1) == LuaTypes.LUA_TSTRING)) { string s = LuaAPI.lua_tostring(L, 1); string __cl_gen_ret = UnityEngine.WWW.EscapeURL( s ); LuaAPI.lua_pushstring(L, __cl_gen_ret); return 1; } if(__gen_param_count == 2&& (LuaAPI.lua_isnil(L, 1) || LuaAPI.lua_type(L, 1) == LuaTypes.LUA_TSTRING)&& translator.Assignable<System.Text.Encoding>(L, 2)) { string s = LuaAPI.lua_tostring(L, 1); System.Text.Encoding e = (System.Text.Encoding)translator.GetObject(L, 2, typeof(System.Text.Encoding)); string __cl_gen_ret = UnityEngine.WWW.EscapeURL( s, e ); LuaAPI.lua_pushstring(L, __cl_gen_ret); return 1; } } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return LuaAPI.luaL_error(L, "invalid arguments to UnityEngine.WWW.EscapeURL!"); } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int UnEscapeURL_xlua_st_(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); int __gen_param_count = LuaAPI.lua_gettop(L); try { if(__gen_param_count == 1&& (LuaAPI.lua_isnil(L, 1) || LuaAPI.lua_type(L, 1) == LuaTypes.LUA_TSTRING)) { string s = LuaAPI.lua_tostring(L, 1); string __cl_gen_ret = UnityEngine.WWW.UnEscapeURL( s ); LuaAPI.lua_pushstring(L, __cl_gen_ret); return 1; } if(__gen_param_count == 2&& (LuaAPI.lua_isnil(L, 1) || LuaAPI.lua_type(L, 1) == LuaTypes.LUA_TSTRING)&& translator.Assignable<System.Text.Encoding>(L, 2)) { string s = LuaAPI.lua_tostring(L, 1); System.Text.Encoding e = (System.Text.Encoding)translator.GetObject(L, 2, typeof(System.Text.Encoding)); string __cl_gen_ret = UnityEngine.WWW.UnEscapeURL( s, e ); LuaAPI.lua_pushstring(L, __cl_gen_ret); return 1; } } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return LuaAPI.luaL_error(L, "invalid arguments to UnityEngine.WWW.UnEscapeURL!"); } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int GetAudioClip(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); UnityEngine.WWW __cl_gen_to_be_invoked = (UnityEngine.WWW)translator.FastGetCSObj(L, 1); int __gen_param_count = LuaAPI.lua_gettop(L); try { if(__gen_param_count == 2&& LuaTypes.LUA_TBOOLEAN == LuaAPI.lua_type(L, 2)) { bool threeD = LuaAPI.lua_toboolean(L, 2); UnityEngine.AudioClip __cl_gen_ret = __cl_gen_to_be_invoked.GetAudioClip( threeD ); translator.Push(L, __cl_gen_ret); return 1; } if(__gen_param_count == 3&& LuaTypes.LUA_TBOOLEAN == LuaAPI.lua_type(L, 2)&& LuaTypes.LUA_TBOOLEAN == LuaAPI.lua_type(L, 3)) { bool threeD = LuaAPI.lua_toboolean(L, 2); bool stream = LuaAPI.lua_toboolean(L, 3); UnityEngine.AudioClip __cl_gen_ret = __cl_gen_to_be_invoked.GetAudioClip( threeD, stream ); translator.Push(L, __cl_gen_ret); return 1; } if(__gen_param_count == 4&& LuaTypes.LUA_TBOOLEAN == LuaAPI.lua_type(L, 2)&& LuaTypes.LUA_TBOOLEAN == LuaAPI.lua_type(L, 3)&& translator.Assignable<UnityEngine.AudioType>(L, 4)) { bool threeD = LuaAPI.lua_toboolean(L, 2); bool stream = LuaAPI.lua_toboolean(L, 3); UnityEngine.AudioType audioType;translator.Get(L, 4, out audioType); UnityEngine.AudioClip __cl_gen_ret = __cl_gen_to_be_invoked.GetAudioClip( threeD, stream, audioType ); translator.Push(L, __cl_gen_ret); return 1; } } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return LuaAPI.luaL_error(L, "invalid arguments to UnityEngine.WWW.GetAudioClip!"); } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int GetAudioClipCompressed(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); UnityEngine.WWW __cl_gen_to_be_invoked = (UnityEngine.WWW)translator.FastGetCSObj(L, 1); int __gen_param_count = LuaAPI.lua_gettop(L); try { if(__gen_param_count == 1) { UnityEngine.AudioClip __cl_gen_ret = __cl_gen_to_be_invoked.GetAudioClipCompressed( ); translator.Push(L, __cl_gen_ret); return 1; } if(__gen_param_count == 2&& LuaTypes.LUA_TBOOLEAN == LuaAPI.lua_type(L, 2)) { bool threeD = LuaAPI.lua_toboolean(L, 2); UnityEngine.AudioClip __cl_gen_ret = __cl_gen_to_be_invoked.GetAudioClipCompressed( threeD ); translator.Push(L, __cl_gen_ret); return 1; } if(__gen_param_count == 3&& LuaTypes.LUA_TBOOLEAN == LuaAPI.lua_type(L, 2)&& translator.Assignable<UnityEngine.AudioType>(L, 3)) { bool threeD = LuaAPI.lua_toboolean(L, 2); UnityEngine.AudioType audioType;translator.Get(L, 3, out audioType); UnityEngine.AudioClip __cl_gen_ret = __cl_gen_to_be_invoked.GetAudioClipCompressed( threeD, audioType ); translator.Push(L, __cl_gen_ret); return 1; } } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return LuaAPI.luaL_error(L, "invalid arguments to UnityEngine.WWW.GetAudioClipCompressed!"); } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int LoadImageIntoTexture(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); UnityEngine.WWW __cl_gen_to_be_invoked = (UnityEngine.WWW)translator.FastGetCSObj(L, 1); try { { UnityEngine.Texture2D tex = (UnityEngine.Texture2D)translator.GetObject(L, 2, typeof(UnityEngine.Texture2D)); __cl_gen_to_be_invoked.LoadImageIntoTexture( tex ); return 0; } } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int LoadFromCacheOrDownload_xlua_st_(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); int __gen_param_count = LuaAPI.lua_gettop(L); try { if(__gen_param_count == 2&& (LuaAPI.lua_isnil(L, 1) || LuaAPI.lua_type(L, 1) == LuaTypes.LUA_TSTRING)&& LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 2)) { string url = LuaAPI.lua_tostring(L, 1); int version = LuaAPI.xlua_tointeger(L, 2); UnityEngine.WWW __cl_gen_ret = UnityEngine.WWW.LoadFromCacheOrDownload( url, version ); translator.Push(L, __cl_gen_ret); return 1; } if(__gen_param_count == 3&& (LuaAPI.lua_isnil(L, 1) || LuaAPI.lua_type(L, 1) == LuaTypes.LUA_TSTRING)&& LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 2)&& LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 3)) { string url = LuaAPI.lua_tostring(L, 1); int version = LuaAPI.xlua_tointeger(L, 2); uint crc = LuaAPI.xlua_touint(L, 3); UnityEngine.WWW __cl_gen_ret = UnityEngine.WWW.LoadFromCacheOrDownload( url, version, crc ); translator.Push(L, __cl_gen_ret); return 1; } if(__gen_param_count == 2&& (LuaAPI.lua_isnil(L, 1) || LuaAPI.lua_type(L, 1) == LuaTypes.LUA_TSTRING)&& translator.Assignable<UnityEngine.Hash128>(L, 2)) { string url = LuaAPI.lua_tostring(L, 1); UnityEngine.Hash128 hash;translator.Get(L, 2, out hash); UnityEngine.WWW __cl_gen_ret = UnityEngine.WWW.LoadFromCacheOrDownload( url, hash ); translator.Push(L, __cl_gen_ret); return 1; } if(__gen_param_count == 3&& (LuaAPI.lua_isnil(L, 1) || LuaAPI.lua_type(L, 1) == LuaTypes.LUA_TSTRING)&& translator.Assignable<UnityEngine.Hash128>(L, 2)&& LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 3)) { string url = LuaAPI.lua_tostring(L, 1); UnityEngine.Hash128 hash;translator.Get(L, 2, out hash); uint crc = LuaAPI.xlua_touint(L, 3); UnityEngine.WWW __cl_gen_ret = UnityEngine.WWW.LoadFromCacheOrDownload( url, hash, crc ); translator.Push(L, __cl_gen_ret); return 1; } } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return LuaAPI.luaL_error(L, "invalid arguments to UnityEngine.WWW.LoadFromCacheOrDownload!"); } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int get_responseHeaders(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UnityEngine.WWW __cl_gen_to_be_invoked = (UnityEngine.WWW)translator.FastGetCSObj(L, 1); translator.Push(L, __cl_gen_to_be_invoked.responseHeaders); } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 1; } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int get_text(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UnityEngine.WWW __cl_gen_to_be_invoked = (UnityEngine.WWW)translator.FastGetCSObj(L, 1); LuaAPI.lua_pushstring(L, __cl_gen_to_be_invoked.text); } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 1; } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int get_bytes(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UnityEngine.WWW __cl_gen_to_be_invoked = (UnityEngine.WWW)translator.FastGetCSObj(L, 1); LuaAPI.lua_pushstring(L, __cl_gen_to_be_invoked.bytes); } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 1; } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int get_size(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UnityEngine.WWW __cl_gen_to_be_invoked = (UnityEngine.WWW)translator.FastGetCSObj(L, 1); LuaAPI.xlua_pushinteger(L, __cl_gen_to_be_invoked.size); } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 1; } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int get_error(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UnityEngine.WWW __cl_gen_to_be_invoked = (UnityEngine.WWW)translator.FastGetCSObj(L, 1); LuaAPI.lua_pushstring(L, __cl_gen_to_be_invoked.error); } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 1; } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int get_texture(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UnityEngine.WWW __cl_gen_to_be_invoked = (UnityEngine.WWW)translator.FastGetCSObj(L, 1); translator.Push(L, __cl_gen_to_be_invoked.texture); } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 1; } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int get_textureNonReadable(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UnityEngine.WWW __cl_gen_to_be_invoked = (UnityEngine.WWW)translator.FastGetCSObj(L, 1); translator.Push(L, __cl_gen_to_be_invoked.textureNonReadable); } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 1; } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int get_audioClip(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UnityEngine.WWW __cl_gen_to_be_invoked = (UnityEngine.WWW)translator.FastGetCSObj(L, 1); translator.Push(L, __cl_gen_to_be_invoked.GetAudioClip()); } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 1; } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int get_isDone(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UnityEngine.WWW __cl_gen_to_be_invoked = (UnityEngine.WWW)translator.FastGetCSObj(L, 1); LuaAPI.lua_pushboolean(L, __cl_gen_to_be_invoked.isDone); } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 1; } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int get_progress(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UnityEngine.WWW __cl_gen_to_be_invoked = (UnityEngine.WWW)translator.FastGetCSObj(L, 1); LuaAPI.lua_pushnumber(L, __cl_gen_to_be_invoked.progress); } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 1; } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int get_uploadProgress(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UnityEngine.WWW __cl_gen_to_be_invoked = (UnityEngine.WWW)translator.FastGetCSObj(L, 1); LuaAPI.lua_pushnumber(L, __cl_gen_to_be_invoked.uploadProgress); } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 1; } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int get_bytesDownloaded(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UnityEngine.WWW __cl_gen_to_be_invoked = (UnityEngine.WWW)translator.FastGetCSObj(L, 1); LuaAPI.xlua_pushinteger(L, __cl_gen_to_be_invoked.bytesDownloaded); } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 1; } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int get_url(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UnityEngine.WWW __cl_gen_to_be_invoked = (UnityEngine.WWW)translator.FastGetCSObj(L, 1); LuaAPI.lua_pushstring(L, __cl_gen_to_be_invoked.url); } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 1; } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int get_assetBundle(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UnityEngine.WWW __cl_gen_to_be_invoked = (UnityEngine.WWW)translator.FastGetCSObj(L, 1); translator.Push(L, __cl_gen_to_be_invoked.assetBundle); } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 1; } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int get_threadPriority(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UnityEngine.WWW __cl_gen_to_be_invoked = (UnityEngine.WWW)translator.FastGetCSObj(L, 1); translator.Push(L, __cl_gen_to_be_invoked.threadPriority); } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 1; } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int set_threadPriority(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UnityEngine.WWW __cl_gen_to_be_invoked = (UnityEngine.WWW)translator.FastGetCSObj(L, 1); UnityEngine.ThreadPriority __cl_gen_value;translator.Get(L, 2, out __cl_gen_value); __cl_gen_to_be_invoked.threadPriority = __cl_gen_value; } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 0; } } } Assets\XLua\Gen\UnityEngineWWWWrap.cs(167,44): error CS1061: 'WWW' does not contain a definition for 'InitWWW' and no accessible extension method 'InitWWW' accepting a first argument of type 'WWW' could be found (are you missing a using directive or an assembly reference?) Assets\XLua\Gen\UnityEngineRandomWrap.cs(60,6): error CS0723: Cannot declare a variable of static type 'Random' Assets\XLua\Gen\UnityEngineRandomWrap.cs(60,40): error CS0712: Cannot create an instance of the static class 'Random' Assets\XLua\Gen\UnityEngineShaderWrap.cs(69,44): error CS1729: 'Shader' does not contain a constructor that takes 0 arguments

#if USE_UNI_LUA using LuaAPI = UniLua.Lua; using RealStatePtr = UniLua.ILuaState; using LuaCSFunction = UniLua.CSharpFunctionDelegate; #else using LuaAPI = XLua.LuaDLL.Lua; using RealStatePtr = System.IntPtr; using LuaCSFunction = XLua.LuaDLL.lua_CSFunction; #endif using XLua; using System.Collections.Generic; namespace CSObjectWrap { public class UnityEngineMaterialWrap { public static void __Register(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); Utils.BeginObjectRegister(typeof(UnityEngine.Material), L, translator, 0, 26, 9, 8); Utils.RegisterFunc(L, Utils.METHOD_IDX, "SetColor", SetColor); Utils.RegisterFunc(L, Utils.METHOD_IDX, "GetColor", GetColor); Utils.RegisterFunc(L, Utils.METHOD_IDX, "SetVector", SetVector); Utils.RegisterFunc(L, Utils.METHOD_IDX, "GetVector", GetVector); Utils.RegisterFunc(L, Utils.METHOD_IDX, "SetTexture", SetTexture); Utils.RegisterFunc(L, Utils.METHOD_IDX, "GetTexture", GetTexture); Utils.RegisterFunc(L, Utils.METHOD_IDX, "SetTextureOffset", SetTextureOffset); Utils.RegisterFunc(L, Utils.METHOD_IDX, "GetTextureOffset", GetTextureOffset); Utils.RegisterFunc(L, Utils.METHOD_IDX, "SetTextureScale", SetTextureScale); Utils.RegisterFunc(L, Utils.METHOD_IDX, "GetTextureScale", GetTextureScale); Utils.RegisterFunc(L, Utils.METHOD_IDX, "SetMatrix", SetMatrix); Utils.RegisterFunc(L, Utils.METHOD_IDX, "GetMatrix", GetMatrix); Utils.RegisterFunc(L, Utils.METHOD_IDX, "SetFloat", SetFloat); Utils.RegisterFunc(L, Utils.METHOD_IDX, "GetFloat", GetFloat); Utils.RegisterFunc(L, Utils.METHOD_IDX, "SetInt", SetInt); Utils.RegisterFunc(L, Utils.METHOD_IDX, "GetInt", GetInt); Utils.RegisterFunc(L, Utils.METHOD_IDX, "SetBuffer", SetBuffer); Utils.RegisterFunc(L, Utils.METHOD_IDX, "HasProperty", HasProperty); Utils.RegisterFunc(L, Utils.METHOD_IDX, "GetTag", GetTag); Utils.RegisterFunc(L, Utils.METHOD_IDX, "SetOverrideTag", SetOverrideTag); Utils.RegisterFunc(L, Utils.METHOD_IDX, "Lerp", Lerp); Utils.RegisterFunc(L, Utils.METHOD_IDX, "SetPass", SetPass); Utils.RegisterFunc(L, Utils.METHOD_IDX, "CopyPropertiesFromMaterial", CopyPropertiesFromMaterial); Utils.RegisterFunc(L, Utils.METHOD_IDX, "EnableKeyword", EnableKeyword); Utils.RegisterFunc(L, Utils.METHOD_IDX, "DisableKeyword", DisableKeyword); Utils.RegisterFunc(L, Utils.METHOD_IDX, "IsKeywordEnabled", IsKeywordEnabled); Utils.RegisterFunc(L, Utils.GETTER_IDX, "shader", get_shader); Utils.RegisterFunc(L, Utils.GETTER_IDX, "color", get_color); Utils.RegisterFunc(L, Utils.GETTER_IDX, "mainTexture", get_mainTexture); Utils.RegisterFunc(L, Utils.GETTER_IDX, "mainTextureOffset", get_mainTextureOffset); Utils.RegisterFunc(L, Utils.GETTER_IDX, "mainTextureScale", get_mainTextureScale); Utils.RegisterFunc(L, Utils.GETTER_IDX, "passCount", get_passCount); Utils.RegisterFunc(L, Utils.GETTER_IDX, "renderQueue", get_renderQueue); Utils.RegisterFunc(L, Utils.GETTER_IDX, "shaderKeywords", get_shaderKeywords); Utils.RegisterFunc(L, Utils.GETTER_IDX, "globalIlluminationFlags", get_globalIlluminationFlags); Utils.RegisterFunc(L, Utils.SETTER_IDX, "shader", set_shader); Utils.RegisterFunc(L, Utils.SETTER_IDX, "color", set_color); Utils.RegisterFunc(L, Utils.SETTER_IDX, "mainTexture", set_mainTexture); Utils.RegisterFunc(L, Utils.SETTER_IDX, "mainTextureOffset", set_mainTextureOffset); Utils.RegisterFunc(L, Utils.SETTER_IDX, "mainTextureScale", set_mainTextureScale); Utils.RegisterFunc(L, Utils.SETTER_IDX, "renderQueue", set_renderQueue); Utils.RegisterFunc(L, Utils.SETTER_IDX, "shaderKeywords", set_shaderKeywords); Utils.RegisterFunc(L, Utils.SETTER_IDX, "globalIlluminationFlags", set_globalIlluminationFlags); Utils.EndObjectRegister(typeof(UnityEngine.Material), L, translator, null, null, null, null, null); Utils.BeginClassRegister(typeof(UnityEngine.Material), L, __CreateInstance, 1, 0, 0); Utils.RegisterObject(L, translator, Utils.CLS_IDX, "UnderlyingSystemType", typeof(UnityEngine.Material)); Utils.EndClassRegister(typeof(UnityEngine.Material), L, translator); } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int __CreateInstance(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { if(LuaAPI.lua_gettop(L) == 2 && translator.Assignable<UnityEngine.Shader>(L, 2)) { UnityEngine.Shader shader = (UnityEngine.Shader)translator.GetObject(L, 2, typeof(UnityEngine.Shader)); UnityEngine.Material __cl_gen_ret = new UnityEngine.Material(shader); translator.Push(L, __cl_gen_ret); return 1; } if(LuaAPI.lua_gettop(L) == 2 && translator.Assignable<UnityEngine.Material>(L, 2)) { UnityEngine.Material source = (UnityEngine.Material)translator.GetObject(L, 2, typeof(UnityEngine.Material)); UnityEngine.Material __cl_gen_ret = new UnityEngine.Material(source); translator.Push(L, __cl_gen_ret); return 1; } } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return LuaAPI.luaL_error(L, "invalid arguments to UnityEngine.Material constructor!"); } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int SetColor(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); UnityEngine.Material __cl_gen_to_be_invoked = (UnityEngine.Material)translator.FastGetCSObj(L, 1); int __gen_param_count = LuaAPI.lua_gettop(L); try { if(__gen_param_count == 3&& LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 2)&& translator.Assignable<UnityEngine.Color>(L, 3)) { int nameID = LuaAPI.xlua_tointeger(L, 2); UnityEngine.Color color;translator.Get(L, 3, out color); __cl_gen_to_be_invoked.SetColor( nameID, color ); return 0; } if(__gen_param_count == 3&& (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING)&& translator.Assignable<UnityEngine.Color>(L, 3)) { string propertyName = LuaAPI.lua_tostring(L, 2); UnityEngine.Color color;translator.Get(L, 3, out color); __cl_gen_to_be_invoked.SetColor( propertyName, color ); return 0; } } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return LuaAPI.luaL_error(L, "invalid arguments to UnityEngine.Material.SetColor!"); } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int GetColor(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); UnityEngine.Material __cl_gen_to_be_invoked = (UnityEngine.Material)translator.FastGetCSObj(L, 1); int __gen_param_count = LuaAPI.lua_gettop(L); try { if(__gen_param_count == 2&& LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 2)) { int nameID = LuaAPI.xlua_tointeger(L, 2); UnityEngine.Color __cl_gen_ret = __cl_gen_to_be_invoked.GetColor( nameID ); translator.PushUnityEngineColor(L, __cl_gen_ret); return 1; } if(__gen_param_count == 2&& (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING)) { string propertyName = LuaAPI.lua_tostring(L, 2); UnityEngine.Color __cl_gen_ret = __cl_gen_to_be_invoked.GetColor( propertyName ); translator.PushUnityEngineColor(L, __cl_gen_ret); return 1; } } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return LuaAPI.luaL_error(L, "invalid arguments to UnityEngine.Material.GetColor!"); } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int SetVector(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); UnityEngine.Material __cl_gen_to_be_invoked = (UnityEngine.Material)translator.FastGetCSObj(L, 1); int __gen_param_count = LuaAPI.lua_gettop(L); try { if(__gen_param_count == 3&& LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 2)&& translator.Assignable<UnityEngine.Vector4>(L, 3)) { int nameID = LuaAPI.xlua_tointeger(L, 2); UnityEngine.Vector4 vector;translator.Get(L, 3, out vector); __cl_gen_to_be_invoked.SetVector( nameID, vector ); return 0; } if(__gen_param_count == 3&& (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING)&& translator.Assignable<UnityEngine.Vector4>(L, 3)) { string propertyName = LuaAPI.lua_tostring(L, 2); UnityEngine.Vector4 vector;translator.Get(L, 3, out vector); __cl_gen_to_be_invoked.SetVector( propertyName, vector ); return 0; } } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return LuaAPI.luaL_error(L, "invalid arguments to UnityEngine.Material.SetVector!"); } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int GetVector(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); UnityEngine.Material __cl_gen_to_be_invoked = (UnityEngine.Material)translator.FastGetCSObj(L, 1); int __gen_param_count = LuaAPI.lua_gettop(L); try { if(__gen_param_count == 2&& LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 2)) { int nameID = LuaAPI.xlua_tointeger(L, 2); UnityEngine.Vector4 __cl_gen_ret = __cl_gen_to_be_invoked.GetVector( nameID ); translator.PushUnityEngineVector4(L, __cl_gen_ret); return 1; } if(__gen_param_count == 2&& (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING)) { string propertyName = LuaAPI.lua_tostring(L, 2); UnityEngine.Vector4 __cl_gen_ret = __cl_gen_to_be_invoked.GetVector( propertyName ); translator.PushUnityEngineVector4(L, __cl_gen_ret); return 1; } } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return LuaAPI.luaL_error(L, "invalid arguments to UnityEngine.Material.GetVector!"); } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int SetTexture(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); UnityEngine.Material __cl_gen_to_be_invoked = (UnityEngine.Material)translator.FastGetCSObj(L, 1); int __gen_param_count = LuaAPI.lua_gettop(L); try { if(__gen_param_count == 3&& LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 2)&& translator.Assignable<UnityEngine.Texture>(L, 3)) { int nameID = LuaAPI.xlua_tointeger(L, 2); UnityEngine.Texture texture = (UnityEngine.Texture)translator.GetObject(L, 3, typeof(UnityEngine.Texture)); __cl_gen_to_be_invoked.SetTexture( nameID, texture ); return 0; } if(__gen_param_count == 3&& (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING)&& translator.Assignable<UnityEngine.Texture>(L, 3)) { string propertyName = LuaAPI.lua_tostring(L, 2); UnityEngine.Texture texture = (UnityEngine.Texture)translator.GetObject(L, 3, typeof(UnityEngine.Texture)); __cl_gen_to_be_invoked.SetTexture( propertyName, texture ); return 0; } } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return LuaAPI.luaL_error(L, "invalid arguments to UnityEngine.Material.SetTexture!"); } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int GetTexture(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); UnityEngine.Material __cl_gen_to_be_invoked = (UnityEngine.Material)translator.FastGetCSObj(L, 1); int __gen_param_count = LuaAPI.lua_gettop(L); try { if(__gen_param_count == 2&& LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 2)) { int nameID = LuaAPI.xlua_tointeger(L, 2); UnityEngine.Texture __cl_gen_ret = __cl_gen_to_be_invoked.GetTexture( nameID ); translator.Push(L, __cl_gen_ret); return 1; } if(__gen_param_count == 2&& (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING)) { string propertyName = LuaAPI.lua_tostring(L, 2); UnityEngine.Texture __cl_gen_ret = __cl_gen_to_be_invoked.GetTexture( propertyName ); translator.Push(L, __cl_gen_ret); return 1; } } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return LuaAPI.luaL_error(L, "invalid arguments to UnityEngine.Material.GetTexture!"); } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int SetTextureOffset(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); UnityEngine.Material __cl_gen_to_be_invoked = (UnityEngine.Material)translator.FastGetCSObj(L, 1); try { { string propertyName = LuaAPI.lua_tostring(L, 2); UnityEngine.Vector2 offset;translator.Get(L, 3, out offset); __cl_gen_to_be_invoked.SetTextureOffset( propertyName, offset ); return 0; } } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int GetTextureOffset(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); UnityEngine.Material __cl_gen_to_be_invoked = (UnityEngine.Material)translator.FastGetCSObj(L, 1); try { { string propertyName = LuaAPI.lua_tostring(L, 2); UnityEngine.Vector2 __cl_gen_ret = __cl_gen_to_be_invoked.GetTextureOffset( propertyName ); translator.PushUnityEngineVector2(L, __cl_gen_ret); return 1; } } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int SetTextureScale(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); UnityEngine.Material __cl_gen_to_be_invoked = (UnityEngine.Material)translator.FastGetCSObj(L, 1); try { { string propertyName = LuaAPI.lua_tostring(L, 2); UnityEngine.Vector2 scale;translator.Get(L, 3, out scale); __cl_gen_to_be_invoked.SetTextureScale( propertyName, scale ); return 0; } } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int GetTextureScale(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); UnityEngine.Material __cl_gen_to_be_invoked = (UnityEngine.Material)translator.FastGetCSObj(L, 1); try { { string propertyName = LuaAPI.lua_tostring(L, 2); UnityEngine.Vector2 __cl_gen_ret = __cl_gen_to_be_invoked.GetTextureScale( propertyName ); translator.PushUnityEngineVector2(L, __cl_gen_ret); return 1; } } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int SetMatrix(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); UnityEngine.Material __cl_gen_to_be_invoked = (UnityEngine.Material)translator.FastGetCSObj(L, 1); int __gen_param_count = LuaAPI.lua_gettop(L); try { if(__gen_param_count == 3&& LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 2)&& translator.Assignable<UnityEngine.Matrix4x4>(L, 3)) { int nameID = LuaAPI.xlua_tointeger(L, 2); UnityEngine.Matrix4x4 matrix;translator.Get(L, 3, out matrix); __cl_gen_to_be_invoked.SetMatrix( nameID, matrix ); return 0; } if(__gen_param_count == 3&& (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING)&& translator.Assignable<UnityEngine.Matrix4x4>(L, 3)) { string propertyName = LuaAPI.lua_tostring(L, 2); UnityEngine.Matrix4x4 matrix;translator.Get(L, 3, out matrix); __cl_gen_to_be_invoked.SetMatrix( propertyName, matrix ); return 0; } } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return LuaAPI.luaL_error(L, "invalid arguments to UnityEngine.Material.SetMatrix!"); } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int GetMatrix(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); UnityEngine.Material __cl_gen_to_be_invoked = (UnityEngine.Material)translator.FastGetCSObj(L, 1); int __gen_param_count = LuaAPI.lua_gettop(L); try { if(__gen_param_count == 2&& LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 2)) { int nameID = LuaAPI.xlua_tointeger(L, 2); UnityEngine.Matrix4x4 __cl_gen_ret = __cl_gen_to_be_invoked.GetMatrix( nameID ); translator.Push(L, __cl_gen_ret); return 1; } if(__gen_param_count == 2&& (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING)) { string propertyName = LuaAPI.lua_tostring(L, 2); UnityEngine.Matrix4x4 __cl_gen_ret = __cl_gen_to_be_invoked.GetMatrix( propertyName ); translator.Push(L, __cl_gen_ret); return 1; } } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return LuaAPI.luaL_error(L, "invalid arguments to UnityEngine.Material.GetMatrix!"); } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int SetFloat(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); UnityEngine.Material __cl_gen_to_be_invoked = (UnityEngine.Material)translator.FastGetCSObj(L, 1); int __gen_param_count = LuaAPI.lua_gettop(L); try { if(__gen_param_count == 3&& LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 2)&& LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 3)) { int nameID = LuaAPI.xlua_tointeger(L, 2); float value = (float)LuaAPI.lua_tonumber(L, 3); __cl_gen_to_be_invoked.SetFloat( nameID, value ); return 0; } if(__gen_param_count == 3&& (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING)&& LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 3)) { string propertyName = LuaAPI.lua_tostring(L, 2); float value = (float)LuaAPI.lua_tonumber(L, 3); __cl_gen_to_be_invoked.SetFloat( propertyName, value ); return 0; } } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return LuaAPI.luaL_error(L, "invalid arguments to UnityEngine.Material.SetFloat!"); } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int GetFloat(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); UnityEngine.Material __cl_gen_to_be_invoked = (UnityEngine.Material)translator.FastGetCSObj(L, 1); int __gen_param_count = LuaAPI.lua_gettop(L); try { if(__gen_param_count == 2&& LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 2)) { int nameID = LuaAPI.xlua_tointeger(L, 2); float __cl_gen_ret = __cl_gen_to_be_invoked.GetFloat( nameID ); LuaAPI.lua_pushnumber(L, __cl_gen_ret); return 1; } if(__gen_param_count == 2&& (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING)) { string propertyName = LuaAPI.lua_tostring(L, 2); float __cl_gen_ret = __cl_gen_to_be_invoked.GetFloat( propertyName ); LuaAPI.lua_pushnumber(L, __cl_gen_ret); return 1; } } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return LuaAPI.luaL_error(L, "invalid arguments to UnityEngine.Material.GetFloat!"); } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int SetInt(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); UnityEngine.Material __cl_gen_to_be_invoked = (UnityEngine.Material)translator.FastGetCSObj(L, 1); int __gen_param_count = LuaAPI.lua_gettop(L); try { if(__gen_param_count == 3&& LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 2)&& LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 3)) { int nameID = LuaAPI.xlua_tointeger(L, 2); int value = LuaAPI.xlua_tointeger(L, 3); __cl_gen_to_be_invoked.SetInt( nameID, value ); return 0; } if(__gen_param_count == 3&& (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING)&& LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 3)) { string propertyName = LuaAPI.lua_tostring(L, 2); int value = LuaAPI.xlua_tointeger(L, 3); __cl_gen_to_be_invoked.SetInt( propertyName, value ); return 0; } } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return LuaAPI.luaL_error(L, "invalid arguments to UnityEngine.Material.SetInt!"); } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int GetInt(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); UnityEngine.Material __cl_gen_to_be_invoked = (UnityEngine.Material)translator.FastGetCSObj(L, 1); int __gen_param_count = LuaAPI.lua_gettop(L); try { if(__gen_param_count == 2&& LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 2)) { int nameID = LuaAPI.xlua_tointeger(L, 2); int __cl_gen_ret = __cl_gen_to_be_invoked.GetInt( nameID ); LuaAPI.xlua_pushinteger(L, __cl_gen_ret); return 1; } if(__gen_param_count == 2&& (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING)) { string propertyName = LuaAPI.lua_tostring(L, 2); int __cl_gen_ret = __cl_gen_to_be_invoked.GetInt( propertyName ); LuaAPI.xlua_pushinteger(L, __cl_gen_ret); return 1; } } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return LuaAPI.luaL_error(L, "invalid arguments to UnityEngine.Material.GetInt!"); } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int SetBuffer(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); UnityEngine.Material __cl_gen_to_be_invoked = (UnityEngine.Material)translator.FastGetCSObj(L, 1); try { { string propertyName = LuaAPI.lua_tostring(L, 2); UnityEngine.ComputeBuffer buffer = (UnityEngine.ComputeBuffer)translator.GetObject(L, 3, typeof(UnityEngine.ComputeBuffer)); __cl_gen_to_be_invoked.SetBuffer( propertyName, buffer ); return 0; } } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int HasProperty(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); UnityEngine.Material __cl_gen_to_be_invoked = (UnityEngine.Material)translator.FastGetCSObj(L, 1); int __gen_param_count = LuaAPI.lua_gettop(L); try { if(__gen_param_count == 2&& LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 2)) { int nameID = LuaAPI.xlua_tointeger(L, 2); bool __cl_gen_ret = __cl_gen_to_be_invoked.HasProperty( nameID ); LuaAPI.lua_pushboolean(L, __cl_gen_ret); return 1; } if(__gen_param_count == 2&& (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING)) { string propertyName = LuaAPI.lua_tostring(L, 2); bool __cl_gen_ret = __cl_gen_to_be_invoked.HasProperty( propertyName ); LuaAPI.lua_pushboolean(L, __cl_gen_ret); return 1; } } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return LuaAPI.luaL_error(L, "invalid arguments to UnityEngine.Material.HasProperty!"); } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int GetTag(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); UnityEngine.Material __cl_gen_to_be_invoked = (UnityEngine.Material)translator.FastGetCSObj(L, 1); int __gen_param_count = LuaAPI.lua_gettop(L); try { if(__gen_param_count == 3&& (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING)&& LuaTypes.LUA_TBOOLEAN == LuaAPI.lua_type(L, 3)) { string tag = LuaAPI.lua_tostring(L, 2); bool searchFallbacks = LuaAPI.lua_toboolean(L, 3); string __cl_gen_ret = __cl_gen_to_be_invoked.GetTag( tag, searchFallbacks ); LuaAPI.lua_pushstring(L, __cl_gen_ret); return 1; } if(__gen_param_count == 4&& (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING)&& LuaTypes.LUA_TBOOLEAN == LuaAPI.lua_type(L, 3)&& (LuaAPI.lua_isnil(L, 4) || LuaAPI.lua_type(L, 4) == LuaTypes.LUA_TSTRING)) { string tag = LuaAPI.lua_tostring(L, 2); bool searchFallbacks = LuaAPI.lua_toboolean(L, 3); string defaultValue = LuaAPI.lua_tostring(L, 4); string __cl_gen_ret = __cl_gen_to_be_invoked.GetTag( tag, searchFallbacks, defaultValue ); LuaAPI.lua_pushstring(L, __cl_gen_ret); return 1; } } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return LuaAPI.luaL_error(L, "invalid arguments to UnityEngine.Material.GetTag!"); } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int SetOverrideTag(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); UnityEngine.Material __cl_gen_to_be_invoked = (UnityEngine.Material)translator.FastGetCSObj(L, 1); try { { string tag = LuaAPI.lua_tostring(L, 2); string val = LuaAPI.lua_tostring(L, 3); __cl_gen_to_be_invoked.SetOverrideTag( tag, val ); return 0; } } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int Lerp(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); UnityEngine.Material __cl_gen_to_be_invoked = (UnityEngine.Material)translator.FastGetCSObj(L, 1); try { { UnityEngine.Material start = (UnityEngine.Material)translator.GetObject(L, 2, typeof(UnityEngine.Material)); UnityEngine.Material end = (UnityEngine.Material)translator.GetObject(L, 3, typeof(UnityEngine.Material)); float t = (float)LuaAPI.lua_tonumber(L, 4); __cl_gen_to_be_invoked.Lerp( start, end, t ); return 0; } } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int SetPass(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); UnityEngine.Material __cl_gen_to_be_invoked = (UnityEngine.Material)translator.FastGetCSObj(L, 1); try { { int pass = LuaAPI.xlua_tointeger(L, 2); bool __cl_gen_ret = __cl_gen_to_be_invoked.SetPass( pass ); LuaAPI.lua_pushboolean(L, __cl_gen_ret); return 1; } } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int CopyPropertiesFromMaterial(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); UnityEngine.Material __cl_gen_to_be_invoked = (UnityEngine.Material)translator.FastGetCSObj(L, 1); try { { UnityEngine.Material mat = (UnityEngine.Material)translator.GetObject(L, 2, typeof(UnityEngine.Material)); __cl_gen_to_be_invoked.CopyPropertiesFromMaterial( mat ); return 0; } } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int EnableKeyword(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); UnityEngine.Material __cl_gen_to_be_invoked = (UnityEngine.Material)translator.FastGetCSObj(L, 1); try { { string keyword = LuaAPI.lua_tostring(L, 2); __cl_gen_to_be_invoked.EnableKeyword( keyword ); return 0; } } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int DisableKeyword(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); UnityEngine.Material __cl_gen_to_be_invoked = (UnityEngine.Material)translator.FastGetCSObj(L, 1); try { { string keyword = LuaAPI.lua_tostring(L, 2); __cl_gen_to_be_invoked.DisableKeyword( keyword ); return 0; } } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int IsKeywordEnabled(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); UnityEngine.Material __cl_gen_to_be_invoked = (UnityEngine.Material)translator.FastGetCSObj(L, 1); try { { string keyword = LuaAPI.lua_tostring(L, 2); bool __cl_gen_ret = __cl_gen_to_be_invoked.IsKeywordEnabled( keyword ); LuaAPI.lua_pushboolean(L, __cl_gen_ret); return 1; } } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int get_shader(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UnityEngine.Material __cl_gen_to_be_invoked = (UnityEngine.Material)translator.FastGetCSObj(L, 1); translator.Push(L, __cl_gen_to_be_invoked.shader); } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 1; } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int get_color(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UnityEngine.Material __cl_gen_to_be_invoked = (UnityEngine.Material)translator.FastGetCSObj(L, 1); translator.PushUnityEngineColor(L, __cl_gen_to_be_invoked.color); } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 1; } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int get_mainTexture(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UnityEngine.Material __cl_gen_to_be_invoked = (UnityEngine.Material)translator.FastGetCSObj(L, 1); translator.Push(L, __cl_gen_to_be_invoked.mainTexture); } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 1; } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int get_mainTextureOffset(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UnityEngine.Material __cl_gen_to_be_invoked = (UnityEngine.Material)translator.FastGetCSObj(L, 1); translator.PushUnityEngineVector2(L, __cl_gen_to_be_invoked.mainTextureOffset); } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 1; } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int get_mainTextureScale(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UnityEngine.Material __cl_gen_to_be_invoked = (UnityEngine.Material)translator.FastGetCSObj(L, 1); translator.PushUnityEngineVector2(L, __cl_gen_to_be_invoked.mainTextureScale); } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 1; } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int get_passCount(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UnityEngine.Material __cl_gen_to_be_invoked = (UnityEngine.Material)translator.FastGetCSObj(L, 1); LuaAPI.xlua_pushinteger(L, __cl_gen_to_be_invoked.passCount); } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 1; } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int get_renderQueue(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UnityEngine.Material __cl_gen_to_be_invoked = (UnityEngine.Material)translator.FastGetCSObj(L, 1); LuaAPI.xlua_pushinteger(L, __cl_gen_to_be_invoked.renderQueue); } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 1; } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int get_shaderKeywords(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UnityEngine.Material __cl_gen_to_be_invoked = (UnityEngine.Material)translator.FastGetCSObj(L, 1); translator.Push(L, __cl_gen_to_be_invoked.shaderKeywords); } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 1; } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int get_globalIlluminationFlags(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UnityEngine.Material __cl_gen_to_be_invoked = (UnityEngine.Material)translator.FastGetCSObj(L, 1); translator.Push(L, __cl_gen_to_be_invoked.globalIlluminationFlags); } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 1; } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int set_shader(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UnityEngine.Material __cl_gen_to_be_invoked = (UnityEngine.Material)translator.FastGetCSObj(L, 1); __cl_gen_to_be_invoked.shader = (UnityEngine.Shader)translator.GetObject(L, 2, typeof(UnityEngine.Shader)); } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 0; } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int set_color(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UnityEngine.Material __cl_gen_to_be_invoked = (UnityEngine.Material)translator.FastGetCSObj(L, 1); UnityEngine.Color __cl_gen_value;translator.Get(L, 2, out __cl_gen_value); __cl_gen_to_be_invoked.color = __cl_gen_value; } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 0; } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int set_mainTexture(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UnityEngine.Material __cl_gen_to_be_invoked = (UnityEngine.Material)translator.FastGetCSObj(L, 1); __cl_gen_to_be_invoked.mainTexture = (UnityEngine.Texture)translator.GetObject(L, 2, typeof(UnityEngine.Texture)); } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 0; } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int set_mainTextureOffset(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UnityEngine.Material __cl_gen_to_be_invoked = (UnityEngine.Material)translator.FastGetCSObj(L, 1); UnityEngine.Vector2 __cl_gen_value;translator.Get(L, 2, out __cl_gen_value); __cl_gen_to_be_invoked.mainTextureOffset = __cl_gen_value; } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 0; } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int set_mainTextureScale(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UnityEngine.Material __cl_gen_to_be_invoked = (UnityEngine.Material)translator.FastGetCSObj(L, 1); UnityEngine.Vector2 __cl_gen_value;translator.Get(L, 2, out __cl_gen_value); __cl_gen_to_be_invoked.mainTextureScale = __cl_gen_value; } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 0; } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int set_renderQueue(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UnityEngine.Material __cl_gen_to_be_invoked = (UnityEngine.Material)translator.FastGetCSObj(L, 1); __cl_gen_to_be_invoked.renderQueue = LuaAPI.xlua_tointeger(L, 2); } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 0; } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int set_shaderKeywords(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UnityEngine.Material __cl_gen_to_be_invoked = (UnityEngine.Material)translator.FastGetCSObj(L, 1); __cl_gen_to_be_invoked.shaderKeywords = (string[])translator.GetObject(L, 2, typeof(string[])); } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 0; } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int set_globalIlluminationFlags(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UnityEngine.Material __cl_gen_to_be_invoked = (UnityEngine.Material)translator.FastGetCSObj(L, 1); UnityEngine.MaterialGlobalIlluminationFlags __cl_gen_value;translator.Get(L, 2, out __cl_gen_value); __cl_gen_to_be_invoked.globalIlluminationFlags = __cl_gen_value; } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 0; } } } 这个代码是Unity5.3.3f1版本的,现在升级到Unity2021.3.45f1版本怎么兼容?

#if USE_UNI_LUA using LuaAPI = UniLua.Lua; using RealStatePtr = UniLua.ILuaState; using LuaCSFunction = UniLua.CSharpFunctionDelegate; #else using LuaAPI = XLua.LuaDLL.Lua; using RealStatePtr = System.IntPtr; using LuaCSFunction = XLua.LuaDLL.lua_CSFunction; #endif using XLua; using System.Collections.Generic; namespace CSObjectWrap { public class UnityEngineMaterialWrap { // 此处可补充UnityEngine.Material的注册和方法实现 } public class UnityEngineAnimationClipWrap { public static void __Register(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); Utils.BeginObjectRegister(typeof(UnityEngine.AnimationClip), L, translator, 0, 5, 7, 5); Utils.RegisterFunc(L, Utils.METHOD_IDX, "SampleAnimation", SampleAnimation); Utils.RegisterFunc(L, Utils.METHOD_IDX, "SetCurve", SetCurve); Utils.RegisterFunc(L, Utils.METHOD_IDX, "EnsureQuaternionContinuity", EnsureQuaternionContinuity); Utils.RegisterFunc(L, Utils.METHOD_IDX, "ClearCurves", ClearCurves); Utils.RegisterFunc(L, Utils.METHOD_IDX, "AddEvent", AddEvent); Utils.RegisterFunc(L, Utils.GETTER_IDX, "length", get_length); Utils.RegisterFunc(L, Utils.GETTER_IDX, "frameRate", get_frameRate); Utils.RegisterFunc(L, Utils.GETTER_IDX, "wrapMode", get_wrapMode); Utils.RegisterFunc(L, Utils.GETTER_IDX, "localBounds", get_localBounds); Utils.RegisterFunc(L, Utils.GETTER_IDX, "legacy", get_legacy); Utils.RegisterFunc(L, Utils.GETTER_IDX, "humanMotion", get_humanMotion); Utils.RegisterFunc(L, Utils.GETTER_IDX, "events", get_events); Utils.RegisterFunc(L, Utils.SETTER_IDX, "frameRate", set_frameRate); Utils.RegisterFunc(L, Utils.SETTER_IDX, "wrapMode", set_wrapMode); Utils.RegisterFunc(L, Utils.SETTER_IDX, "localBounds", set_localBounds); Utils.RegisterFunc(L, Utils.SETTER_IDX, "legacy", set_legacy); Utils.RegisterFunc(L, Utils.SETTER_IDX, "events", set_events); Utils.EndObjectRegister(typeof(UnityEngine.AnimationClip), L, translator, null, null, null, null, null); Utils.BeginClassRegister(typeof(UnityEngine.AnimationClip), L, __CreateInstance, 1, 0, 0); Utils.RegisterObject(L, translator, Utils.CLS_IDX, "UnderlyingSystemType", typeof(UnityEngine.AnimationClip)); Utils.EndClassRegister(typeof(UnityEngine.AnimationClip), L, translator); } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int __CreateInstance(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { if (LuaAPI.lua_gettop(L) == 1) { UnityEngine.AnimationClip __cl_gen_ret = new UnityEngine.AnimationClip(); translator.Push(L, __cl_gen_ret); return 1; } } catch (System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return LuaAPI.luaL_error(L, "invalid arguments to UnityEngine.AnimationClip constructor!"); } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int SampleAnimation(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); UnityEngine.AnimationClip __cl_gen_to_be_invoked = (UnityEngine.AnimationClip)translator.FastGetCSObj(L, 1); try { { UnityEngine.GameObject go = (UnityEngine.GameObject)translator.GetObject(L, 2, typeof(UnityEngine.GameObject)); float time = (float)LuaAPI.lua_tonumber(L, 3); __cl_gen_to_be_invoked.SampleAnimation(go, time); return 0; } } catch (System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int SetCurve(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); UnityEngine.AnimationClip __cl_gen_to_be_invoked = (UnityEngine.AnimationClip)translator.FastGetCSObj(L, 1); try { { string relativePath = LuaAPI.lua_tostring(L, 2); System.Type type = (System.Type)translator.GetObject(L, 3, typeof(System.Type)); string propertyName = LuaAPI.lua_tostring(L, 4); UnityEngine.AnimationCurve curve = (UnityEngine.AnimationCurve)translator.GetObject(L, 5, typeof(UnityEngine.AnimationCurve)); __cl_gen_to_be_invoked.SetCurve(relativePath, type, propertyName, curve); return 0; } } catch (System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int EnsureQuaternionContinuity(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); UnityEngine.AnimationClip __cl_gen_to_be_invoked = (UnityEngine.AnimationClip)translator.FastGetCSObj(L, 1); try { { __cl_gen_to_be_invoked.EnsureQuaternionContinuity(); return 0; } } catch (System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int ClearCurves(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); UnityEngine.AnimationClip __cl_gen_to_be_invoked = (UnityEngine.AnimationClip)translator.FastGetCSObj(L, 1); try { { __cl_gen_to_be_invoked.ClearCurves(); return 0; } } catch (System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int AddEvent(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); UnityEngine.AnimationClip __cl_gen_to_be_invoked = (UnityEngine.AnimationClip)translator.FastGetCSObj(L, 1); try { { UnityEngine.AnimationEvent evt = (UnityEngine.AnimationEvent)translator.GetObject(L, 2, typeof(UnityEngine.AnimationEvent)); __cl_gen_to_be_invoked.AddEvent(evt); return 0; } } catch (System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int get_length(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UnityEngine.AnimationClip __cl_gen_to_be_invoked = (UnityEngine.AnimationClip)translator.FastGetCSObj(L, 1); LuaAPI.lua_pushnumber(L, __cl_gen_to_be_invoked.length); } catch (System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 1; } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int get_frameRate(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UnityEngine.AnimationClip __cl_gen_to_be_invoked = (UnityEngine.AnimationClip)translator.FastGetCSObj(L, 1); LuaAPI.lua_pushnumber(L, __cl_gen_to_be_invoked.frameRate); } catch (System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 1; } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int get_wrapMode(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UnityEngine.AnimationClip __cl_gen_to_be_invoked = (UnityEngine.AnimationClip)translator.FastGetCSObj(L, 1); translator.Push(L, __cl_gen_to_be_invoked.wrapMode); } catch (System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 1; } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int get_localBounds(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UnityEngine.AnimationClip __cl_gen_to_be_invoked = (UnityEngine.AnimationClip)translator.FastGetCSObj(L, 1); translator.PushUnityEngineBounds(L, __cl_gen_to_be_invoked.localBounds); } catch (System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 1; } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int get_legacy(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UnityEngine.AnimationClip __cl_gen_to_be_invoked = (UnityEngine.AnimationClip)translator.FastGetCSObj(L, 1); LuaAPI.lua_pushboolean(L, __cl_gen_to_be_invoked.legacy); } catch (System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 1; } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int get_humanMotion(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UnityEngine.AnimationClip __cl_gen_to_be_invoked = (UnityEngine.AnimationClip)translator.FastGetCSObj(L, 1); LuaAPI.lua_pushboolean(L, __cl_gen_to_be_invoked.humanMotion); } catch (System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 1; } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int get_events(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UnityEngine.AnimationClip __cl_gen_to_be_invoked = (UnityEngine.AnimationClip)translator.FastGetCSObj(L, 1); translator.Push(L, __cl_gen_to_be_invoked.events); } catch (System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 1; } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int set_frameRate(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UnityEngine.AnimationClip __cl_gen_to_be_invoked = (UnityEngine.AnimationClip)translator.FastGetCSObj(L, 1); __cl_gen_to_be_invoked.frameRate = (float)LuaAPI.lua_tonumber(L, 2); } catch (System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 0; } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int set_wrapMode(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UnityEngine.AnimationClip __cl_gen_to_be_invoked = (UnityEngine.AnimationClip)translator.FastGetCSObj(L, 1); UnityEngine.WrapMode __cl_gen_value; translator.Get(L, 2, out __cl_gen_value); __cl_gen_to_be_invoked.wrapMode = __cl_gen_value; } catch (System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 0; } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int set_localBounds(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UnityEngine.AnimationClip __cl_gen_to_be_invoked = (UnityEngine.AnimationClip)translator.FastGetCSObj(L, 1); UnityEngine.Bounds __cl_gen_value; translator.Get(L, 2, out __cl_gen_value); __cl_gen_to_be_invoked.localBounds = __cl_gen_value; } catch (System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 0; } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int set_legacy(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UnityEngine.AnimationClip __cl_gen_to_be_invoked = (UnityEngine.AnimationClip)translator.FastGetCSObj(L, 1); __cl_gen_to_be_invoked.legacy = LuaAPI.lua_toboolean(L, 2); } catch (System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 0; } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int set_events(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UnityEngine.AnimationClip __cl_gen_to_be_invoked = (UnityEngine.AnimationClip)translator.FastGetCSObj(L, 1); __cl_gen_to_be_invoked.events = (UnityEngine.AnimationEvent[])translator.GetObject(L, 2, typeof(UnityEngine.AnimationEvent[])); } catch (System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 0; } } }

#if USE_UNI_LUA using LuaAPI = UniLua.Lua; using RealStatePtr = UniLua.ILuaState; using LuaCSFunction = UniLua.CSharpFunctionDelegate; #else using LuaAPI = XLua.LuaDLL.Lua; using RealStatePtr = System.IntPtr; using LuaCSFunction = XLua.LuaDLL.lua_CSFunction; #endif using XLua; using System.Collections.Generic; namespace CSObjectWrap { public class UIButtonWrap { public static void __Register(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); Utils.BeginObjectRegister(typeof(UIButton), L, translator, 0, 2, 12, 12); Utils.RegisterFunc(L, Utils.METHOD_IDX, "SetState", SetState); Utils.RegisterFunc(L, Utils.METHOD_IDX, "setOnPressScaleEnable", setOnPressScaleEnable); Utils.RegisterFunc(L, Utils.GETTER_IDX, "isEnabled", get_isEnabled); Utils.RegisterFunc(L, Utils.GETTER_IDX, "normalSprite", get_normalSprite); Utils.RegisterFunc(L, Utils.GETTER_IDX, "normalSprite2D", get_normalSprite2D); Utils.RegisterFunc(L, Utils.GETTER_IDX, "dragHighlight", get_dragHighlight); Utils.RegisterFunc(L, Utils.GETTER_IDX, "hoverSprite", get_hoverSprite); Utils.RegisterFunc(L, Utils.GETTER_IDX, "pressedSprite", get_pressedSprite); Utils.RegisterFunc(L, Utils.GETTER_IDX, "disabledSprite", get_disabledSprite); Utils.RegisterFunc(L, Utils.GETTER_IDX, "hoverSprite2D", get_hoverSprite2D); Utils.RegisterFunc(L, Utils.GETTER_IDX, "pressedSprite2D", get_pressedSprite2D); Utils.RegisterFunc(L, Utils.GETTER_IDX, "disabledSprite2D", get_disabledSprite2D); Utils.RegisterFunc(L, Utils.GETTER_IDX, "pixelSnap", get_pixelSnap); Utils.RegisterFunc(L, Utils.GETTER_IDX, "onClick", get_onClick); Utils.RegisterFunc(L, Utils.SETTER_IDX, "isEnabled", set_isEnabled); Utils.RegisterFunc(L, Utils.SETTER_IDX, "normalSprite", set_normalSprite); Utils.RegisterFunc(L, Utils.SETTER_IDX, "normalSprite2D", set_normalSprite2D); Utils.RegisterFunc(L, Utils.SETTER_IDX, "dragHighlight", set_dragHighlight); Utils.RegisterFunc(L, Utils.SETTER_IDX, "hoverSprite", set_hoverSprite); Utils.RegisterFunc(L, Utils.SETTER_IDX, "pressedSprite", set_pressedSprite); Utils.RegisterFunc(L, Utils.SETTER_IDX, "disabledSprite", set_disabledSprite); Utils.RegisterFunc(L, Utils.SETTER_IDX, "hoverSprite2D", set_hoverSprite2D); Utils.RegisterFunc(L, Utils.SETTER_IDX, "pressedSprite2D", set_pressedSprite2D); Utils.RegisterFunc(L, Utils.SETTER_IDX, "disabledSprite2D", set_disabledSprite2D); Utils.RegisterFunc(L, Utils.SETTER_IDX, "pixelSnap", set_pixelSnap); Utils.RegisterFunc(L, Utils.SETTER_IDX, "onClick", set_onClick); Utils.EndObjectRegister(typeof(UIButton), L, translator, null, null, null, null, null); Utils.BeginClassRegister(typeof(UIButton), L, __CreateInstance, 1, 1, 1); Utils.RegisterObject(L, translator, Utils.CLS_IDX, "UnderlyingSystemType", typeof(UIButton)); Utils.RegisterFunc(L, Utils.CLS_GETTER_IDX, "current", get_current); Utils.RegisterFunc(L, Utils.CLS_SETTER_IDX, "current", set_current); Utils.EndClassRegister(typeof(UIButton), L, translator); } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int __CreateInstance(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { if(LuaAPI.lua_gettop(L) == 1) { UIButton __cl_gen_ret = new UIButton(); translator.Push(L, __cl_gen_ret); return 1; } } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return LuaAPI.luaL_error(L, "invalid arguments to UIButton constructor!"); } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int SetState(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); UIButton __cl_gen_to_be_invoked = (UIButton)translator.FastGetCSObj(L, 1); try { { UIButtonColor.State state;translator.Get(L, 2, out state); bool immediate = LuaAPI.lua_toboolean(L, 3); __cl_gen_to_be_invoked.SetState( state, immediate ); return 0; } } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int setOnPressScaleEnable(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); UIButton __cl_gen_to_be_invoked = (UIButton)translator.FastGetCSObj(L, 1); try { { bool enable = LuaAPI.lua_toboolean(L, 2); __cl_gen_to_be_invoked.setOnPressScaleEnable( enable ); return 0; } } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int get_isEnabled(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UIButton __cl_gen_to_be_invoked = (UIButton)translator.FastGetCSObj(L, 1); LuaAPI.lua_pushboolean(L, __cl_gen_to_be_invoked.isEnabled); } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 1; } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int get_normalSprite(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UIButton __cl_gen_to_be_invoked = (UIButton)translator.FastGetCSObj(L, 1); LuaAPI.lua_pushstring(L, __cl_gen_to_be_invoked.normalSprite); } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 1; } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int get_normalSprite2D(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UIButton __cl_gen_to_be_invoked = (UIButton)translator.FastGetCSObj(L, 1); translator.Push(L, __cl_gen_to_be_invoked.normalSprite2D); } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 1; } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int get_current(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { translator.Push(L, UIButton.current); } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 1; } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int get_dragHighlight(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UIButton __cl_gen_to_be_invoked = (UIButton)translator.FastGetCSObj(L, 1); LuaAPI.lua_pushboolean(L, __cl_gen_to_be_invoked.dragHighlight); } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 1; } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int get_hoverSprite(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UIButton __cl_gen_to_be_invoked = (UIButton)translator.FastGetCSObj(L, 1); LuaAPI.lua_pushstring(L, __cl_gen_to_be_invoked.hoverSprite); } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 1; } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int get_pressedSprite(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UIButton __cl_gen_to_be_invoked = (UIButton)translator.FastGetCSObj(L, 1); LuaAPI.lua_pushstring(L, __cl_gen_to_be_invoked.pressedSprite); } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 1; } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int get_disabledSprite(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UIButton __cl_gen_to_be_invoked = (UIButton)translator.FastGetCSObj(L, 1); LuaAPI.lua_pushstring(L, __cl_gen_to_be_invoked.disabledSprite); } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 1; } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int get_hoverSprite2D(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UIButton __cl_gen_to_be_invoked = (UIButton)translator.FastGetCSObj(L, 1); translator.Push(L, __cl_gen_to_be_invoked.hoverSprite2D); } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 1; } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int get_pressedSprite2D(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UIButton __cl_gen_to_be_invoked = (UIButton)translator.FastGetCSObj(L, 1); translator.Push(L, __cl_gen_to_be_invoked.pressedSprite2D); } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 1; } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int get_disabledSprite2D(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UIButton __cl_gen_to_be_invoked = (UIButton)translator.FastGetCSObj(L, 1); translator.Push(L, __cl_gen_to_be_invoked.disabledSprite2D); } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 1; } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int get_pixelSnap(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UIButton __cl_gen_to_be_invoked = (UIButton)translator.FastGetCSObj(L, 1); LuaAPI.lua_pushboolean(L, __cl_gen_to_be_invoked.pixelSnap); } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 1; } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int get_onClick(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UIButton __cl_gen_to_be_invoked = (UIButton)translator.FastGetCSObj(L, 1); translator.Push(L, __cl_gen_to_be_invoked.onClick); } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 1; } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int set_isEnabled(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UIButton __cl_gen_to_be_invoked = (UIButton)translator.FastGetCSObj(L, 1); __cl_gen_to_be_invoked.isEnabled = LuaAPI.lua_toboolean(L, 2); } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 0; } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int set_normalSprite(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UIButton __cl_gen_to_be_invoked = (UIButton)translator.FastGetCSObj(L, 1); __cl_gen_to_be_invoked.normalSprite = LuaAPI.lua_tostring(L, 2); } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 0; } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int set_normalSprite2D(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UIButton __cl_gen_to_be_invoked = (UIButton)translator.FastGetCSObj(L, 1); __cl_gen_to_be_invoked.normalSprite2D = (UnityEngine.Sprite)translator.GetObject(L, 2, typeof(UnityEngine.Sprite)); } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 0; } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int set_current(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UIButton.current = (UIButton)translator.GetObject(L, 1, typeof(UIButton)); } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 0; } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int set_dragHighlight(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UIButton __cl_gen_to_be_invoked = (UIButton)translator.FastGetCSObj(L, 1); __cl_gen_to_be_invoked.dragHighlight = LuaAPI.lua_toboolean(L, 2); } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 0; } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int set_hoverSprite(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UIButton __cl_gen_to_be_invoked = (UIButton)translator.FastGetCSObj(L, 1); __cl_gen_to_be_invoked.hoverSprite = LuaAPI.lua_tostring(L, 2); } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 0; } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int set_pressedSprite(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UIButton __cl_gen_to_be_invoked = (UIButton)translator.FastGetCSObj(L, 1); __cl_gen_to_be_invoked.pressedSprite = LuaAPI.lua_tostring(L, 2); } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 0; } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int set_disabledSprite(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UIButton __cl_gen_to_be_invoked = (UIButton)translator.FastGetCSObj(L, 1); __cl_gen_to_be_invoked.disabledSprite = LuaAPI.lua_tostring(L, 2); } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 0; } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int set_hoverSprite2D(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UIButton __cl_gen_to_be_invoked = (UIButton)translator.FastGetCSObj(L, 1); __cl_gen_to_be_invoked.hoverSprite2D = (UnityEngine.Sprite)translator.GetObject(L, 2, typeof(UnityEngine.Sprite)); } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 0; } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int set_pressedSprite2D(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UIButton __cl_gen_to_be_invoked = (UIButton)translator.FastGetCSObj(L, 1); __cl_gen_to_be_invoked.pressedSprite2D = (UnityEngine.Sprite)translator.GetObject(L, 2, typeof(UnityEngine.Sprite)); } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 0; } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int set_disabledSprite2D(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UIButton __cl_gen_to_be_invoked = (UIButton)translator.FastGetCSObj(L, 1); __cl_gen_to_be_invoked.disabledSprite2D = (UnityEngine.Sprite)translator.GetObject(L, 2, typeof(UnityEngine.Sprite)); } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 0; } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int set_pixelSnap(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UIButton __cl_gen_to_be_invoked = (UIButton)translator.FastGetCSObj(L, 1); __cl_gen_to_be_invoked.pixelSnap = LuaAPI.lua_toboolean(L, 2); } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 0; } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int set_onClick(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UIButton __cl_gen_to_be_invoked = (UIButton)translator.FastGetCSObj(L, 1); __cl_gen_to_be_invoked.onClick = (System.Collections.Generic.List<EventDelegate>)translator.GetObject(L, 2, typeof(System.Collections.Generic.List<EventDelegate>)); } catch(System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 0; } } } Assets/XLua/Gen/UIButtonWrap.cs(142,44): error CS1061: Type UIButton' does not contain a definition for setOnPressScaleEnable' and no extension method setOnPressScaleEnable' of type UIButton' could be found (are you missing a using directive or an assembly reference?)

最新推荐

recommend-type

langchain4j-anthropic-spring-boot-starter-0.31.0.jar中文文档.zip

1、压缩文件中包含: 中文文档、jar包下载地址、Maven依赖、Gradle依赖、源代码下载地址。 2、使用方法: 解压最外层zip,再解压其中的zip包,双击 【index.html】 文件,即可用浏览器打开、进行查看。 3、特殊说明: (1)本文档为人性化翻译,精心制作,请放心使用; (2)只翻译了该翻译的内容,如:注释、说明、描述、用法讲解 等; (3)不该翻译的内容保持原样,如:类名、方法名、包名、类型、关键字、代码 等。 4、温馨提示: (1)为了防止解压后路径太长导致浏览器无法打开,推荐在解压时选择“解压到当前文件夹”(放心,自带文件夹,文件不会散落一地); (2)有时,一套Java组件会有多个jar,所以在下载前,请仔细阅读本篇描述,以确保这就是你需要的文件。 5、本文件关键字: jar中文文档.zip,java,jar包,Maven,第三方jar包,组件,开源组件,第三方组件,Gradle,中文API文档,手册,开发手册,使用手册,参考手册。
recommend-type

TMS320F28335电机控制程序详解:BLDC、PMSM无感有感及异步VF源代码与开发资料

TMS320F28335这款高性能数字信号处理器(DSP)在电机控制领域的应用,涵盖了BLDC(无刷直流电机)、PMSM(永磁同步电机)的无感有感控制以及异步VF(变频调速)程序。文章不仅解释了各类型的电机控制原理,还提供了完整的开发资料,包括源代码、原理图和说明文档,帮助读者深入了解其工作原理和编程技巧。 适合人群:从事电机控制系统开发的技术人员,尤其是对TMS320F28335感兴趣的工程师。 使用场景及目标:适用于需要掌握TMS320F28335在不同电机控制应用场景下具体实现方法的专业人士,旨在提高他们对该微控制器的理解和实际操作能力。 其他说明:文中提供的开发资料为读者提供了从硬件到软件的全面支持,有助于加速项目开发进程并提升系统性能。
recommend-type

基于爬山搜索法的风力发电MPPT控制Simulink仿真:定步长与变步长算法性能对比 - 爬山搜索法 最新版

基于爬山搜索法的风力发电最大功率点追踪(MPPT)控制的Simulink仿真模型,重点比较了定步长和变步长算法在不同风速条件下的表现。文中展示了两种算法的具体实现方法及其优缺点。定步长算法虽然结构简单、计算量小,但在风速突变时响应较慢,存在明显的稳态振荡。相比之下,变步长算法能够根据功率变化动态调整步长,表现出更快的响应速度和更高的精度,尤其在风速突变时优势明显。实验数据显示,变步长算法在风速从8m/s突增至10m/s的情况下,仅用0.3秒即可稳定,功率波动范围仅为±15W,而定步长算法则需要0.8秒,功率波动达到±35W。 适合人群:从事风力发电研究的技术人员、对MPPT控制感兴趣的工程技术人员以及相关专业的高校师生。 使用场景及目标:适用于风力发电系统的设计与优化,特别是需要提高系统响应速度和精度的场合。目标是在不同风速条件下,选择合适的MPPT算法以最大化风能利用率。 其他说明:文章还讨论了定步长算法在风速平稳情况下的优势,提出了根据不同应用场景灵活选择或组合使用这两种算法的建议。
recommend-type

基于MatlabSimulink的风电场调频策略研究:虚拟惯性、超速减载与下垂控制的协调优化

内容概要:本文详细探讨了在Matlab/Simulink环境下,针对风电场调频的研究,尤其是双馈风机调频策略的应用及其与其他调频策略的协调工作。文中介绍了三种主要的调频策略——虚拟惯性、超速减载和下垂控制,并基于三机九节点系统进行了改进,模拟了四组风电机组的协同调频过程。研究指出,虚拟惯性的应用虽然可以提供短期频率支持,但也可能导致频率二次跌落的问题。因此,需要通过超速减载和下垂控制来进行补偿,以维持电网的稳定。此外,文章还展示了在变风速条件下,风电机组对电网频率支撑能力的显著提升,尤其是在高比例风电并网渗透的情况下,频率最低点提高了50%,验证了调频策略的有效性。 适合人群:从事电力系统、风电场运营管理和调频技术研发的专业人士,以及对风电调频感兴趣的科研人员和技术爱好者。 使用场景及目标:适用于希望深入理解风电场调频机制及其优化方法的人群。目标是掌握不同调频策略的工作原理及其协调工作的关键点,提高风电场的运行效率和稳定性。 其他说明:本文通过具体的案例研究和仿真数据,展示了调频策略的实际效果,强调了合理运用调频策略对于风电场稳定运行的重要意义。同时,也为未来的风电调频技术创新提供了理论依据和实践经验。
recommend-type

三菱QL系列PLC在3C-FPC组装机中的定位与伺服控制及触摸屏应用解析

三菱Q系列和L系列PLC在3C-FPC组装机中的具体应用,涵盖硬件架构、软件编程以及实际操作技巧。主要内容包括:使用QX42数字输入模块和QY42P晶体管输出模块进行高效信号处理;采用JE系列伺服控制系统实现高精度四轴联动;利用SFC(顺序功能图)和梯形图编程方法构建稳定可靠的控制系统;通过触摸屏实现多用户管理和权限控制;并分享了一些实用的调试和维护技巧,如流水线节拍控制和工程师模式进入方法。最终,该系统的设备综合效率(OEE)达到了92%以上。 适合人群:从事自动化控制领域的工程师和技术人员,尤其是对三菱PLC有初步了解并希望深入了解其高级应用的人群。 使用场景及目标:适用于需要高精度、高效能的工业生产设备控制场合,旨在帮助用户掌握三菱PLC及其相关组件的应用技能,提高生产效率和产品质量。 其他说明:文中提供了详细的编程实例和操作指南,有助于读者更好地理解和实践。同时提醒使用者在调试过程中应注意伺服刚性参数调整,避免不必要的机械损伤。
recommend-type

Visual C++.NET编程技术实战指南

根据提供的文件信息,可以生成以下知识点: ### Visual C++.NET编程技术体验 #### 第2章 定制窗口 - **设置窗口风格**:介绍了如何通过编程自定义窗口的外观和行为。包括改变窗口的标题栏、边框样式、大小和位置等。这通常涉及到Windows API中的`SetWindowLong`和`SetClassLong`函数。 - **创建六边形窗口**:展示了如何创建一个具有特殊形状边界的窗口,这类窗口不遵循标准的矩形形状。它需要使用`SetWindowRgn`函数设置窗口的区域。 - **创建异形窗口**:扩展了定制窗口的内容,提供了创建非标准形状窗口的方法。这可能需要创建一个不规则的窗口区域,并将其应用到窗口上。 #### 第3章 菜单和控制条高级应用 - **菜单编程**:讲解了如何创建和修改菜单项,处理用户与菜单的交互事件,以及动态地添加或删除菜单项。 - **工具栏编程**:阐述了如何使用工具栏,包括如何创建工具栏按钮、分配事件处理函数,并实现工具栏按钮的响应逻辑。 - **状态栏编程**:介绍了状态栏的创建、添加不同类型的指示器(如文本、进度条等)以及状态信息的显示更新。 - **为工具栏添加皮肤**:展示了如何为工具栏提供更加丰富的视觉效果,通常涉及到第三方的控件库或是自定义的绘图代码。 #### 第5章 系统编程 - **操作注册表**:解释了Windows注册表的结构和如何通过程序对其进行读写操作,这对于配置软件和管理软件设置非常关键。 - **系统托盘编程**:讲解了如何在系统托盘区域创建图标,并实现最小化到托盘、从托盘恢复窗口的功能。 - **鼠标钩子程序**:介绍了钩子(Hook)技术,特别是鼠标钩子,如何拦截和处理系统中的鼠标事件。 - **文件分割器**:提供了如何将文件分割成多个部分,并且能够重新组合文件的技术示例。 #### 第6章 多文档/多视图编程 - **单文档多视**:展示了如何在同一个文档中创建多个视图,这在文档编辑软件中非常常见。 #### 第7章 对话框高级应用 - **实现无模式对话框**:介绍了无模式对话框的概念及其应用场景,以及如何实现和管理无模式对话框。 - **使用模式属性表及向导属性表**:讲解了属性表的创建和使用方法,以及如何通过向导性质的对话框引导用户完成多步骤的任务。 - **鼠标敏感文字**:提供了如何实现点击文字触发特定事件的功能,这在阅读器和编辑器应用中很有用。 #### 第8章 GDI+图形编程 - **图像浏览器**:通过图像浏览器示例,展示了GDI+在图像处理和展示中的应用,包括图像的加载、显示以及基本的图像操作。 #### 第9章 多线程编程 - **使用全局变量通信**:介绍了在多线程环境下使用全局变量进行线程间通信的方法和注意事项。 - **使用Windows消息通信**:讲解了通过消息队列在不同线程间传递信息的技术,包括发送消息和处理消息。 - **使用CriticalSection对象**:阐述了如何使用临界区(CriticalSection)对象防止多个线程同时访问同一资源。 - **使用Mutex对象**:介绍了互斥锁(Mutex)的使用,用以同步线程对共享资源的访问,保证资源的安全。 - **使用Semaphore对象**:解释了信号量(Semaphore)对象的使用,它允许一个资源由指定数量的线程同时访问。 #### 第10章 DLL编程 - **创建和使用Win32 DLL**:介绍了如何创建和链接Win32动态链接库(DLL),以及如何在其他程序中使用这些DLL。 - **创建和使用MFC DLL**:详细说明了如何创建和使用基于MFC的动态链接库,适用于需要使用MFC类库的场景。 #### 第11章 ATL编程 - **简单的非属性化ATL项目**:讲解了ATL(Active Template Library)的基础使用方法,创建一个不使用属性化组件的简单项目。 - **使用ATL开发COM组件**:详细阐述了使用ATL开发COM组件的步骤,包括创建接口、实现类以及注册组件。 #### 第12章 STL编程 - **list编程**:介绍了STL(标准模板库)中的list容器的使用,讲解了如何使用list实现复杂数据结构的管理。 #### 第13章 网络编程 - **网上聊天应用程序**:提供了实现基本聊天功能的示例代码,包括客户端和服务器的通信逻辑。 - **简单的网页浏览器**:演示了如何创建一个简单的Web浏览器程序,涉及到网络通信和HTML解析。 - **ISAPI服务器扩展编程**:介绍了如何开发ISAPI(Internet Server API)服务器扩展来扩展IIS(Internet Information Services)的功能。 #### 第14章 数据库编程 - **ODBC数据库编程**:解释了ODBC(开放数据库互联)的概念,并提供了使用ODBC API进行数据库访问的示例。 - **ADO编程**:介绍了ADO(ActiveX Data Objects)技术,讲解了如何使用ADO进行数据库的增删改查等操作。 #### 第15章 HTML帮助系统编程 - **创建HTML帮助文件**:讲解了如何创建HTML帮助文件(.chm),这是微软帮助系统的一种形式。 - **区分上下文帮助**:提供了在应用程序中实现上下文敏感帮助的技术示例。 #### 第16章 安装和部署项目 - **用安装程序向导创建安装项目**:介绍了如何使用Visual Studio中的安装和部署项目向导,快速创建安装程序。 - **部署应用程序**:阐述了部署应用程序到目标系统的过程,以及如何确保应用程序的正确安装和运行。 以上内容涵盖了Visual C++.NET编程技术体验一书中涉及的各个技术点,并对每个章节中的示例做了详细的说明。这些知识点对于理解和掌握Visual C++.NET编程非常重要,并能够帮助读者在实际项目开发中应用这些技术。
recommend-type

HarmonyOS内核深度探秘:优化自由行旅游系统的策略

# 1. HarmonyOS内核概述与旅游系统需求分析 ## 1.1 HarmonyOS内核概述 HarmonyOS(鸿蒙操作系统)是由华为开发的一个分布式操作系统,旨在提供跨多种设备的无缝体验。其内核设计理念强调高效、安全和模块化,以微内核架构和分布式能力
recommend-type

tkinter模块所有控件

<think>好的,我现在需要回答用户关于Tkinter模块中所有控件列表的问题。首先,我需要回忆Tkinter的基础知识,确保自己了解各个控件的名称和用途。用户希望得到所有支持的控件列表,所以必须全面覆盖,不能遗漏。 首先,我应该从Tkinter的标准控件开始。常见的控件包括Label、Button、Entry这些基础部件。然后是Frame,用于布局,还有Canvas用于绘图。接下来是Checkbutton、Radiobutton,这些属于选择类控件。Listbox和Scrollbar通常一起使用,处理滚动内容。还有Scale(滑块)、Spinbox、Menu、Menubutton这些可能
recommend-type

局域网五子棋游戏:娱乐与聊天的完美结合

标题“网络五子棋”和描述“适合于局域网之间娱乐和聊天!”以及标签“五子棋 网络”所涉及的知识点主要围绕着五子棋游戏的网络版本及其在局域网中的应用。以下是详细的知识点: 1. 五子棋游戏概述: 五子棋是一种两人对弈的纯策略型棋类游戏,又称为连珠、五子连线等。游戏的目标是在一个15x15的棋盘上,通过先后放置黑白棋子,使得任意一方先形成连续五个同色棋子的一方获胜。五子棋的规则简单,但策略丰富,适合各年龄段的玩家。 2. 网络五子棋的意义: 网络五子棋是指可以在互联网或局域网中连接进行对弈的五子棋游戏版本。通过网络版本,玩家不必在同一地点即可进行游戏,突破了空间限制,满足了现代人们快节奏生活的需求,同时也为玩家们提供了与不同对手切磋交流的机会。 3. 局域网通信原理: 局域网(Local Area Network,LAN)是一种覆盖较小范围如家庭、学校、实验室或单一建筑内的计算机网络。它通过有线或无线的方式连接网络内的设备,允许用户共享资源如打印机和文件,以及进行游戏和通信。局域网内的计算机之间可以通过网络协议进行通信。 4. 网络五子棋的工作方式: 在局域网中玩五子棋,通常需要一个客户端程序(如五子棋.exe)和一个服务器程序。客户端负责显示游戏界面、接受用户输入、发送落子请求给服务器,而服务器负责维护游戏状态、处理玩家的游戏逻辑和落子请求。当一方玩家落子时,客户端将该信息发送到服务器,服务器确认无误后将更新后的棋盘状态传回给所有客户端,更新显示。 5. 五子棋.exe程序: 五子棋.exe是一个可执行程序,它使得用户可以在个人计算机上安装并运行五子棋游戏。该程序可能包含了游戏的图形界面、人工智能算法(如果支持单机对战AI的话)、网络通信模块以及游戏规则的实现。 6. put.wav文件: put.wav是一个声音文件,很可能用于在游戏进行时提供声音反馈,比如落子声。在网络环境中,声音文件可能被用于提升玩家的游戏体验,尤其是在局域网多人游戏场景中。当玩家落子时,系统会播放.wav文件中的声音,为游戏增添互动性和趣味性。 7. 网络五子棋的技术要求: 为了确保多人在线游戏的顺利进行,网络五子棋需要具备一些基本的技术要求,包括但不限于稳定的网络连接、高效的数据传输协议(如TCP/IP)、以及安全的数据加密措施(如果需要的话)。此外,还需要有一个良好的用户界面设计来提供直观和舒适的用户体验。 8. 社交与娱乐: 网络五子棋除了是一个娱乐游戏外,它还具有社交功能。玩家可以通过游戏内的聊天系统进行交流,分享经验和策略,甚至通过网络寻找新的朋友。这使得网络五子棋不仅是一个个人娱乐工具,同时也是一种社交活动。 总结来说,网络五子棋结合了五子棋游戏的传统魅力和现代网络技术,使得不同地区的玩家能够在局域网内进行娱乐和聊天,既丰富了人们的娱乐生活,又加强了人际交流。而实现这一切的基础在于客户端程序的设计、服务器端的稳定运行、局域网的高效通信,以及音效文件增强的游戏体验。
recommend-type

自由行旅游新篇章:HarmonyOS技术融合与系统架构深度解析

# 1. HarmonyOS技术概述 ## 1.1 HarmonyOS的起源与发展 HarmonyOS(鸿蒙操作系统)由华为公司开发,旨在构建全场景分布式OS,以应对不同设备间的互联问题。自从2019年首次发布以来,HarmonyOS迅速成长,并迅速应用于智能手机、平板、智能穿戴、车载设备等多种平台。该系