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();
}
}
}
}这个是UNITY5.3版本LUA代码,运行时的报错的日志文件在下面,请帮我检查一下代码并修改,但是不要影响到别的文件调用,-----CompilerOutput:-stderr----------
Assets/Scripts/Manager/ResourceManager.cs(16,49): error CS1519: Unexpected symbol `=>' in class, struct, or interface member declaration
Assets/Scripts/Manager/ResourceManager.cs(16,62): error CS1519: Unexpected symbol `?' in class, struct, or interface member declaration
Assets/Scripts/Manager/ResourceManager.cs(16,98): error CS1519: Unexpected symbol `(' in class, struct, or interface member declaration
Assets/Scripts/Manager/ResourceManager.cs(46,60): error CS1519: Unexpected symbol `=>' in class, struct, or interface member declaration
Assets/Scripts/Manager/ResourceManager.cs(46,74): error CS1519: Unexpected symbol `=' in class, struct, or interface member declaration
Assets/Scripts/Manager/ResourceManager.cs(46,80): error CS1519: Unexpected symbol `;' in class, struct, or interface member declaration
Assets/Scripts/Manager/ResourceManager.cs(47,56): error CS1519: Unexpected symbol `=>' in class, struct, or interface member declaration
Assets/Scripts/Manager/ResourceManager.cs(47,70): error CS1519: Unexpected symbol `=' in class, struct, or interface member declaration
Assets/Scripts/Manager/ResourceManager.cs(47,76): error CS1519: Unexpected symbol `;' in class, struct, or interface member declaration
Assets/Scripts/Manager/ResourceManager.cs(48,57): error CS1519: Unexpected symbol `=>' in class, struct, or interface member declaration
Assets/Scripts/Manager/ResourceManager.cs(48,68): error CS1519: Unexpected symbol `=' in class, struct, or interface member declaration
Assets/Scripts/Manager/ResourceManager.cs(48,74): error CS1519: Unexpected symbol `;' in class, struct, or interface member declaration
Assets/Scripts/Manager/ResourceManager.cs(64,27): error CS1525: Unexpected symbol `<internal>'
Assets/Scripts/Manager/ResourceManager.cs(73,27): error CS1525: Unexpected symbol `<internal>'
Assets/Scripts/Manager/ResourceManager.cs(82,42): error CS1525: Unexpected symbol `<internal>'
Assets/Scripts/Manager/ResourceManager.cs(82,13): warning CS0642: Possible mistaken empty statement
Assets/Scripts/Manager/ResourceManager.cs(105,29): error CS1525: Unexpected symbol `.', expecting `[', or `identifier'
Assets/Scripts/Manager/ResourceManager.cs(106,29): error CS1525: Unexpected symbol `.', expecting `[', or `identifier'
Assets/Scripts/Manager/ResourceManager.cs(110,35): error CS1525: Unexpected symbol `<internal>'
Assets/Scripts/Manager/ResourceManager.cs(112,29): error CS1525: Unexpected symbol `.', expecting `[', or `identifier'
Assets/Scripts/Manager/ResourceManager.cs(113,26): error CS1525: Unexpected symbol `.', expecting `[', or `identifier'
Assets/Scripts/Manager/ResourceManager.cs(127,29): error CS1525: Unexpected symbol `.', expecting `[', or `identifier'
Assets/Scripts/Manager/ResourceManager.cs(140,31): error CS1525: Unexpected symbol `<internal>'
Assets/Scripts/Manager/ResourceManager.cs(145,95): error CS1525: Unexpected symbol `<internal>'
Assets/Scripts/Manager/ResourceManager.cs(151,33): error CS1525: Unexpected symbol `.', expecting `[', or `identifier'
Assets/Scripts/Manager/ResourceManager.cs(181,14): error CS1519: Unexpected symbol `if' in class, struct, or interface member declaration
Assets/Scripts/Manager/ResourceManager.cs(181,25): error CS1519: Unexpected symbol `!=' in class, struct, or interface member declaration
Assets/Scripts/Manager/ResourceManager.cs(184,28): error CS1519: Unexpected symbol `return' in class, struct, or interface member declaration
Assets/Scripts/Manager/ResourceManager.cs(184,42): error CS1519: Unexpected symbol `;' in class, struct, or interface member declaration
Assets/Scripts/Manager/ResourceManager.cs(186,39): error CS1041: Identifier expected
Assets/Scripts/Manager/ResourceManager.cs(187,55): error CS1018: Keyword `this' or `base' expected
Assets/Scripts/Manager/ResourceManager.cs(186,17): error CS1520: Class, struct, or interface method must have a return type
Assets/Scripts/Manager/ResourceManager.cs(189,30): error CS1519: Unexpected symbol `(' in class, struct, or interface member declaration
Assets/Scripts/Manager/ResourceManager.cs(191,16): error CS1518: Expected `class', `delegate', `enum', `interface', or `struct'
Assets/Scripts/Manager/ResourceManager.cs(197,29): error CS0116: A namespace can only contain types and namespace declarations
Assets/Scripts/Manager/ResourceManager.cs(230,27): error CS1525: Unexpected symbol `<internal>'
Assets/Scripts/Manager/ResourceManager.cs(229,13): warning CS0642: Possible mistaken empty statement
Assets/Scripts/Manager/ResourceManager.cs(221,22): error CS0116: A namespace can only contain types and namespace declarations
Assets/Scripts/Manager/ResourceManager.cs(236,21): error CS0116: A namespace can only contain types and namespace declarations
Assets/Scripts/Manager/ResourceManager.cs(253,14): error CS0116: A namespace can only contain types and namespace declarations
Assets/Scripts/Manager/ResourceManager.cs(259,5): error CS8025: Parsing error
最新发布