private void BuildShaderList(GameObject shaderListObj) { _ShaderMap.Clear(); if (shaderListObj != null) { ShaderList compShaderList = shaderListObj.GetComponent <ShaderList>(); if (compShaderList != null && compShaderList.Shaders != null) { try { int nCount = compShaderList.Shaders.Length; HobaDebuger.LogFormat("ShaderManager.Init, Shaders Count: {0}", nCount); for (int i = 0; i < nCount; ++i) { Shader shader = compShaderList.Shaders[i]; if (shader != null && !_ShaderMap.ContainsKey(shader.name)) { _ShaderMap.Add(shader.name, shader); //HobaDebuger.LogFormat("ShaderManager.Init, Load Shader: {0}", shader.name); } else { HobaDebuger.LogWarning(HobaText.Format("ShaderManager.Init, Shader {0} is missing!", i)); } } } catch (ArgumentException ae) { HobaDebuger.LogError(ae.Message); } } } }
public void ChangeArmorEmbroidery(string path) { if (!_EmbroiderySetting.IsValid) { HobaDebuger.LogWarning("Current Armor does not support ChangeEmbroidery"); return; } var bodyRender = GetSkinnedMeshRenderer(OutwardPart.Body); if (bodyRender == null) { HobaDebuger.LogWarningFormat("Current Armor named {0} has no Body Render", gameObject.name); return; } Material mat = new Material(bodyRender.sharedMaterial); if (string.IsNullOrEmpty(path)) { ChangeArmorEmbroidery(mat, false, null, null, null, Vector4.zero); bodyRender.sharedMaterial = mat; var man = transform.GetComponent <EntityEffectComponent>(); if (null != man) { man.OnMaterialChanged(bodyRender); } } else { Vector4 rect = new Vector4(_EmbroiderySetting.XMin, _EmbroiderySetting.YMin, _EmbroiderySetting.XMax, _EmbroiderySetting.YMax); Action <UnityEngine.Object> callback = (asset) => { GameObject go = asset as GameObject; if (go != null) { var imgset = go.GetComponent <EmbroideryImg>(); if (imgset != null) { ChangeArmorEmbroidery(mat, true, imgset.DiffuseTex as Texture2D, imgset.NormalTex as Texture2D, imgset.SpecularTex as Texture2D, rect); bodyRender.sharedMaterial = mat; var man = transform.GetComponent <EntityEffectComponent>(); if (null != man) { man.OnMaterialChanged(bodyRender); } } } else { HobaDebuger.LogWarningFormat("Resource named {0} is null", path); } }; CAssetBundleManager.AsyncLoadResource(path, callback, false, "outward"); } }
private void SetSmrPropertyByFashionInfo(OutwardPart part, SkinnedMeshRenderer smr, FashionOutward fashionInfo) { if (smr == null) { return; } smr.sharedMesh = fashionInfo.Mesh; smr.sharedMaterial = fashionInfo.Material; if (fashionInfo.BoneInfos == null) { HobaDebuger.LogWarning("Bones info is null"); return; } var boneCount = fashionInfo.BoneInfos.Length; Transform[] bones = new Transform[boneCount]; for (int i = 0; i < boneCount; i++) { var info = fashionInfo.BoneInfos[i]; Transform newAddedRoot = null; bones[i] = FindBone(info.Bones, info.Position, info.Rotation, info.Scale, true, out newAddedRoot); if (newAddedRoot != null) { _ExtraTransDic[(int)part].Add(newAddedRoot); } } smr.bones = bones; }
private static int DoScaleFrom(IntPtr L) { int count = LuaDLL.lua_gettop(L); const int nRet = 0; if (count == 5 && LuaScriptMgr.CheckTypes(L, 1, typeof(GameObject), typeof(LuaTable), typeof(float), typeof(int), typeof(LuaFunction))) { GameObject obj = LuaScriptMgr.GetUnityObject <GameObject>(L, 1); if (obj == null) { HobaDebuger.LogError("GameUtil :: DoScaleFrom -> the GameObject is null."); return(CheckReturnNum(L, count, nRet)); } DoTweenComponent doTween = obj.GetComponent <DoTweenComponent>(); if (doTween == null) { doTween = obj.AddComponent <DoTweenComponent>(); } Vector3 fromScale = LuaScriptMgr.GetVector3(L, 2); float interval = (float)LuaScriptMgr.GetNumber(L, 3); Ease easeType = (Ease)LuaScriptMgr.GetNumber(L, 4); LuaFunction callbackRef = LuaScriptMgr.GetLuaFunction(L, 5); doTween.DoScaleFrom(fromScale, interval, easeType, callbackRef); } else { LogParamError("DoScaleFrom", count); } return(CheckReturnNum(L, count, nRet)); }
public bool Init() { int ret = 0; string AppID = EntryPoint.Instance.GameCustomConfigParams.GCloud_AppID; string AppKey = EntryPoint.Instance.GameCustomConfigParams.GCloud_AppKey; if (m_voiceengine == null) { m_voiceengine = gcloud_voice.GCloudVoice.GetEngine(); System.TimeSpan ts = System.DateTime.UtcNow - new System.DateTime(1970, 1, 1, 0, 0, 0, 0); string strTime = System.Convert.ToInt64(ts.TotalSeconds).ToString(); ret = m_voiceengine.SetAppInfo(AppID, AppKey, strTime); if (ret != 0) { m_voiceengine = null; HobaDebuger.LogError(HobaText.Format("IGCloudVoice SetAppInfo Failed! ret: {0}", ret)); } else { ret = m_voiceengine.Init(); if (ret != 0) { m_voiceengine = null; HobaDebuger.LogError(HobaText.Format("IGCloudVoice Init Failed! ret: {0}", ret)); } } } return(ret == 0); }
private static int DoLocalMove(IntPtr L) { int count = LuaDLL.lua_gettop(L); const int nRet = 0; if (count == 5 && LuaScriptMgr.CheckTypes(L, 1, typeof(GameObject), typeof(LuaTable), typeof(float), typeof(int), typeof(LuaFunction))) { GameObject obj = LuaScriptMgr.GetUnityObject <GameObject>(L, 1); if (obj == null) { //LuaScriptMgr.Instance.CallOnTraceBack(); HobaDebuger.LogError("GameUtil :: DoLocalMove -> the GameObject is null."); return(CheckReturnNum(L, count, nRet)); } DoTweenComponent doTween = obj.GetComponent <DoTweenComponent>(); if (doTween == null) { doTween = obj.AddComponent <DoTweenComponent>(); } var toPos = LuaScriptMgr.GetVector3(L, 2); float interval = (float)LuaScriptMgr.GetNumber(L, 3); Ease easeType = (Ease)LuaScriptMgr.GetNumber(L, 4); LuaFunction callbackRef = LuaScriptMgr.GetLuaFunction(L, 5); //Debug.Log("DoLocalMove " + obj.name+" to "+ toPos); doTween.DoLocalMove(toPos, interval, easeType, callbackRef); } else { LogParamError("DoLocalMove", count); } return(CheckReturnNum(L, count, nRet)); }
private static int DoAlpha(IntPtr L) { int count = LuaDLL.lua_gettop(L); const int nRet = 0; if (count == 4 && LuaScriptMgr.CheckTypes(L, 1, typeof(GameObject), typeof(float), typeof(float), typeof(LuaFunction))) { GameObject obj = LuaScriptMgr.GetUnityObject <GameObject>(L, 1); if (obj == null) { HobaDebuger.LogError("GameUtil :: DoAlpha -> the GameObject is null."); return(CheckReturnNum(L, count, nRet)); } DoTweenComponent doTween = obj.GetComponent <DoTweenComponent>(); if (doTween == null) { doTween = obj.AddComponent <DoTweenComponent>(); } float endValue = (float)LuaScriptMgr.GetNumber(L, 2); float interval = (float)LuaScriptMgr.GetNumber(L, 3); LuaFunction callbackRef = LuaScriptMgr.GetLuaFunction(L, 4); doTween.DoAlpha(endValue, interval, callbackRef); } else { LogParamError("DoAlpha", count); } return(CheckReturnNum(L, count, nRet)); }
public string GetResPath(string key) { string val = string.Empty; IntPtr L = GetL(); if (L != IntPtr.Zero) { int oldTop = LuaDLL.lua_gettop(L); LuaDLL.lua_getglobal(L, "GetResPath"); if (!LuaDLL.lua_isnil(L, -1)) { LuaDLL.lua_pushstring(L, key); if (LuaDLL.lua_pcall(L, 1, 1, 0) != 0) { HobaDebuger.LogLuaError(LuaDLL.lua_tostring(L, -1)); } else { val = LuaDLL.lua_tostring(L, -1); } } LuaDLL.lua_settop(L, oldTop); } return(val); }
public void Destroy() { SafeUnRef(ref enumMetaRef); SafeUnRef(ref typeMetaRef); SafeUnRef(ref delegateMetaRef); SafeUnRef(ref iterMetaRef); SafeUnRef(ref arrayMetaRef); SafeRelease(ref packRaycastHit); SafeRelease(ref packTouch); LuaDLL.clear_luastate(); LuaDLL.lua_gc(_lua.L, LuaGCOptions.LUA_GCCOLLECT, 0); foreach (KeyValuePair <string, LuaBase> kv in _dict) { kv.Value.Dispose(); } _dict.Clear(); _fileList.Clear(); _lua.Close(); _lua.Dispose(); _lua = null; ClearInstance(); //clear instance HobaDebuger.Log("Lua module destroy"); }
public void GetDesignWidthAndHeight(ref int width, ref int height) { width = 0; height = 0; IntPtr L = GetL(); if (L != IntPtr.Zero) { int oldTop = LuaDLL.lua_gettop(L); LuaDLL.lua_getglobal(L, "GetDesignWidthAndHeight"); if (!LuaDLL.lua_isnil(L, -1)) { if (LuaDLL.lua_pcall(L, 0, 2, 0) != 0) { HobaDebuger.LogLuaError(LuaDLL.lua_tostring(L, -1)); } else { height = (int)LuaDLL.lua_tonumber(L, -1); width = (int)LuaDLL.lua_tonumber(L, -2); } } LuaDLL.lua_settop(L, oldTop); } }
public int PrintRegistryTable() { var size = 0; var L = GetL(); if (L != IntPtr.Zero) { var oldTop = LuaDLL.lua_gettop(L); LuaDLL.lua_getglobal(L, "__PrintTable"); if (!LuaDLL.lua_isnil(L, -1)) { LuaDLL.lua_pushvalue(L, LuaIndexes.LUA_REGISTRYINDEX); if (LuaDLL.lua_pcall(L, 1, 1, 0) != 0) { HobaDebuger.LogLuaError(LuaDLL.lua_tostring(L, -1)); } else { size = (int)LuaDLL.lua_tonumber(L, -1); } } LuaDLL.lua_settop(L, oldTop); } return(size); }
public void CallLuaOnWeatherEventFunc2(int type, int EntityId, Vector3 CurrentPosition, Vector3 CurrentOrientation, int MoveType, Vector3 MoveDirection, float MoveSpeed, int TimeInterval, Vector3 DstPosition, bool IsDestPosition) { IntPtr L = GetL(); if (L != IntPtr.Zero) { int oldTop = LuaDLL.lua_gettop(L); LuaDLL.lua_getglobal(L, "ChangeCurrentWeather2"); if (!LuaDLL.lua_isnil(L, -1)) { Push(L, type); Push(L, EntityId); Push(L, CurrentPosition); Push(L, CurrentOrientation); Push(L, MoveType); Push(L, MoveDirection); Push(L, MoveSpeed); Push(L, TimeInterval); Push(L, DstPosition); Push(L, IsDestPosition); if (LuaDLL.lua_pcall(L, 10, 0, 0) != 0) { HobaDebuger.LogLuaError(LuaDLL.lua_tostring(L, -1)); } } LuaDLL.lua_settop(L, oldTop); } }
public string GetDebugLineInfo(int stack) { string info = string.Empty; IntPtr L = GetL(); if (L != IntPtr.Zero) { int oldTop = LuaDLL.lua_gettop(L); LuaDLL.lua_getglobal(L, "GetDebugLineInfo"); if (!LuaDLL.lua_isnil(L, -1)) { Push(L, stack); if (LuaDLL.lua_pcall(L, 1, 1, 0) != 0) { HobaDebuger.LogLuaError(LuaDLL.lua_tostring(L, -1)); } else { info = LuaDLL.lua_tostring(L, -1); } } LuaDLL.lua_settop(L, oldTop); } return(info); }
public static void DumpStack(IntPtr L) { int top = LuaDLL.lua_gettop(L); for (int i = 1; i <= top; i++) { LuaTypes t = LuaDLL.lua_type(L, i); switch (t) { case LuaTypes.LUA_TSTRING: HobaDebuger.LogFormat("<String>: {0}", LuaDLL.lua_tostring(L, i)); break; case LuaTypes.LUA_TBOOLEAN: HobaDebuger.LogFormat("<Boolean>: {0}", LuaDLL.lua_toboolean(L, i).ToString()); break; case LuaTypes.LUA_TNUMBER: HobaDebuger.LogFormat("<Number>: {0}", LuaDLL.lua_tonumber(L, i).ToString()); break; case LuaTypes.LUA_TTABLE: HobaDebuger.Log("<Table>: "); break; default: HobaDebuger.LogFormat("{0}: {1}", t.GetType().ToString(), LuaDLL.lua_tostring(L, i)); break; } } }
private static int SetCurLayerVisible(IntPtr L) { Camera cam = Main.Main3DCamera; if (cam == null) { return(0); } int count = LuaDLL.lua_gettop(L); const int nRet = 0; if ((count == 2 && LuaScriptMgr.CheckTypes(L, 1, typeof(int), typeof(bool)))) { var layer = (int)LuaScriptMgr.GetNumber(L, 1); if (layer < 0) { HobaDebuger.LogWarning("SetCurLayerVisible: Layer can not be a negative number"); return(CheckReturnNum(L, count, nRet)); } var isOn = LuaScriptMgr.GetBoolean(L, 2); var curMask = cam.cullingMask; var layerMask = 1 << layer; var newMask = isOn ? (curMask | layerMask) : (curMask & (~layerMask)); cam.cullingMask = newMask; } else { LogParamError("SetCurLayerVisible", count); } return(CheckReturnNum(L, count, nRet)); }
public void ClearAllBanks() { foreach (var kv in _DicBankLoad) { string bankName = kv.Key; CBankEntry entry = kv.Value; if (entry.InMemoryBankPtr != IntPtr.Zero) { AKRESULT result = AkSoundEngine.UnloadBank(entry.BankID, entry.InMemoryBankPtr); if (result == AKRESULT.AK_Success) { entry.PinnedArray.Free(); } else { HobaDebuger.LogWarningFormat("UnloadBank Failed: {0} {1}", bankName, result); } entry.InMemoryBankPtr = IntPtr.Zero; } else { AkSoundEngine.UnloadBank(entry.BankID, IntPtr.Zero, null, null); } GameObject.Destroy(entry.GameObject); } _DicBankLoad.Clear(); }
private static int SetLayerRecursively(IntPtr L) { int count = LuaDLL.lua_gettop(L); const int nRet = 0; if ((count == 2 && LuaScriptMgr.CheckTypes(L, 1, typeof(GameObject), typeof(int)))) { GameObject obj = LuaScriptMgr.GetUnityObject <GameObject>(L, 1); if (obj == null) { LuaScriptMgr.Instance.CallOnTraceBack(); HobaDebuger.LogError("SetLayerRecursively: param 1 must be GameObject"); return(CheckReturnNum(L, count, nRet)); } int layer = (int)LuaScriptMgr.GetNumber(L, 2); Util.SetLayerRecursively(obj, layer); } else { LogParamError("SetLayerRecursively", count); } return(CheckReturnNum(L, count, nRet)); }
public void UnloadBank(string inBankFilename) { CBankEntry entry; if (!_DicBankLoad.TryGetValue(inBankFilename.ToLower(), out entry)) { return; } if (entry.InMemoryBankPtr != IntPtr.Zero) { AKRESULT result = AkSoundEngine.UnloadBank(entry.BankID, entry.InMemoryBankPtr); if (result == AKRESULT.AK_Success) { entry.PinnedArray.Free(); } else { HobaDebuger.LogWarningFormat("UnloadBank Failed: {0} {1}", inBankFilename, result); } entry.InMemoryBankPtr = IntPtr.Zero; } else { AkSoundEngine.UnloadBank(entry.BankID, IntPtr.Zero, null, null); } if (entry.GameObject != null) { GameObject.Destroy(entry.GameObject); } _DicBankLoad.Remove(inBankFilename.ToLower()); }
private static int DoLoopRotate(IntPtr L) { int count = LuaDLL.lua_gettop(L); const int nRet = 0; if (count == 3 && LuaScriptMgr.CheckTypes(L, 1, typeof(GameObject), typeof(LuaTable), typeof(float))) { GameObject obj = LuaScriptMgr.GetUnityObject <GameObject>(L, 1); if (obj == null) { HobaDebuger.LogError("GameUtil :: DoRotation -> the GameObject is null."); return(CheckReturnNum(L, count, nRet)); } DoTweenComponent doTween = obj.GetComponent <DoTweenComponent>(); if (doTween == null) { doTween = obj.AddComponent <DoTweenComponent>(); } var endValue = LuaScriptMgr.GetVector3(L, 2); float interval = (float)LuaScriptMgr.GetNumber(L, 3); doTween.DoLoopRotate(endValue, interval); } else { LogParamError("DoLoopRotate", count); } return(CheckReturnNum(L, count, nRet)); }
private void SendMessageLoop() { try { while (true) { byte[] socketSyncBytes = null; _CachedSendMessageQueue.TryDequeue(out socketSyncBytes); if (socketSyncBytes != null && _ServiceSocket != null) { int len = socketSyncBytes.Length; int sendLen = _ServiceSocket.Send(socketSyncBytes, len); if (len != sendLen) { HobaDebuger.Log("SendMessageLoop Failed: len != sendLen "); } } else { Thread.Sleep(DO_MESSAGE_INTERVAL); } } } catch (ThreadAbortException e) { HobaDebuger.LogFormat("SendMessageLoop Failed bcz {0}", e.ToString()); } }
private static int DoKill(IntPtr L) { int count = LuaDLL.lua_gettop(L); const int nRet = 0; if (count == 1 && LuaScriptMgr.CheckTypes(L, 1, typeof(GameObject))) { GameObject obj = LuaScriptMgr.GetUnityObject <GameObject>(L, 1); if (obj == null) { HobaDebuger.LogError("GameUtil :: DoKill -> the GameObject is null."); return(CheckReturnNum(L, count, nRet)); } //Debug.Log("Kill " + obj.name); DoTweenComponent doTween = obj.GetComponent <DoTweenComponent>(); if (doTween != null) { doTween.KillAll(); } DOTween.Kill(obj); } else { LogParamError("DoKill", count); } return(CheckReturnNum(L, count, nRet)); }
//可以判断本navmesh以外的navmesh public bool IsValidPositionStrict(string strGameResPath, string strNavMeshPath, Vector3 pos, bool adjustHeight = true, float fDistanceLimit = 0.0f) { if (strNavMeshPath == _NavMeshName && !string.IsNullOrEmpty(_NavMeshName)) return IsValidPositionStrict(_NavQuery, pos, adjustHeight, fDistanceLimit); string fullName = Path.Combine(strGameResPath, "Maps/") + strNavMeshPath; try { var navmesh_data = File.ReadAllBytes(fullName); Common.SCounters.Instance.Increase(EnumCountType.LoadNavMeshFromMemory); IntPtr navMesh = LuaDLL.NM_LoadNavMeshFromMemory(navmesh_data, navmesh_data.GetLength(0)); if (navMesh == IntPtr.Zero) return false; Common.SCounters.Instance.Increase(EnumCountType.CreateNavQuery); IntPtr navQuery = LuaDLL.NM_CreateNavQuery(navMesh, MAX_NODES); if (navQuery == IntPtr.Zero) return false; bool ret = IsValidPositionStrict(navQuery, pos, adjustHeight, fDistanceLimit); Common.SCounters.Instance.Increase(EnumCountType.ClearNavMesh); Common.SCounters.Instance.Increase(EnumCountType.ClearNavQuery); LuaDLL.NM_ClearNavQuery(navQuery); LuaDLL.NM_ClearNavMesh(navMesh); return ret; } catch (Exception e) { #if !SERVER_USE HobaDebuger.LogWarningFormat("raise Exception {1} when ReadAllBytes {0}", fullName, e); #endif return false; } }
private static int IsGameObjectInCamera(IntPtr L) { int count = LuaDLL.lua_gettop(L); const int nRet = 1; if (count == 2 && LuaScriptMgr.CheckTypes(L, 1, typeof(GameObject), typeof(LuaTable))) { GameObject obj = LuaScriptMgr.GetUnityObject <GameObject>(L, 1); if (obj == null) { HobaDebuger.LogError("IsGameObjectInCamera: param 1 must be GameObject"); LuaScriptMgr.Push(L, false); return(CheckReturnNum(L, count, nRet)); } Vector3 size = LuaScriptMgr.GetVector3(L, 2); bool isIn = CCamCtrlMan.Instance.IsGameObjectInCamera(obj.transform, size); LuaScriptMgr.Push(L, isIn); return(CheckReturnNum(L, count, nRet)); } else { LogParamError("IsGameObjectInCamera", count); LuaScriptMgr.Push(L, false); return(CheckReturnNum(L, count, nRet)); } }
public static int loader(IntPtr L) { string fileName = String.Empty; fileName = LuaDLL.lua_tostring(L, 1); fileName = fileName.Replace('.', '/'); fileName += ".lua"; byte[] text = Load(fileName); if (text == null) { LuaDLL.lua_pushstring(L, "loader failed to read file with path: " + fileName); LuaDLL.lua_error(L); return(0); } // 0: no errors; // LUA_ERRSYNTAX: syntax error during pre-compilation; // LUA_ERRMEM: memory allocation error. if (LuaDLL.luaL_loadbuffer(L, text, text.Length, fileName) != 0) { // loadbuffer会在栈顶压入错误信息,弹出错误信息所在的最上层栈 //LuaDLL.lua_pop(L, 1); LuaDLL.lua_error(L); HobaDebuger.LogErrorFormat("Failed to call luaL_loadbuffer, file: {0}", fileName); return(0); } return(1); }
public static int ResetTimer(IntPtr L) { int count = LuaDLL.lua_gettop(L); const int nRet = 0; if (count == 2 && LuaScriptMgr.CheckTypes(L, 1, typeof(GameObject), typeof(int))) { GameObject obj = LuaScriptMgr.GetUnityObject <GameObject>(L, 1); if (obj == null) { HobaDebuger.LogError("ResetTimer: param 1 must be GameObject"); return(GameUtilWrap.CheckReturnNum(L, count, nRet)); } ObjectBehaviour comp = obj.GetComponent <ObjectBehaviour>(); if (comp == null) { HobaDebuger.LogError("ResetTimer: param 1 must have ObjectBehaviour"); return(GameUtilWrap.CheckReturnNum(L, count, nRet)); } int id = (int)LuaScriptMgr.GetNumber(L, 2); comp.ResetTimer(id); return(GameUtilWrap.CheckReturnNum(L, count, nRet)); } else { LogParamError("ResetTimer", count); return(GameUtilWrap.CheckReturnNum(L, count, nRet)); } }
private static int GetUnicodeStrLength(IntPtr L) { int count = LuaDLL.lua_gettop(L); const int nRet = 1; if (count == 1 && LuaScriptMgr.CheckTypes(L, 1, typeof(string))) { string str = LuaScriptMgr.GetString(L, 1); if (string.IsNullOrEmpty(str)) { HobaDebuger.LogWarningFormat("GetUnicodeStrLength string is null or empty"); LuaScriptMgr.Push(L, 0); return(CheckReturnNum(L, count, nRet)); } int length = str.Length; LuaScriptMgr.Push(L, length); return(CheckReturnNum(L, count, nRet)); } else { LogParamError("GetUnicodeStrLength", count); LuaScriptMgr.Push(L, 0); return(CheckReturnNum(L, count, nRet)); } }
private bool UpdateFashionInfo(SkinnedMeshRenderer smr, OutwardPart part, GameObject prefab, string assetPath) { var fashionOutInfo = prefab.GetComponent <FashionOutwardInfo>(); if (fashionOutInfo == null) { return(false); } CleanupExtraInfo(part); string partName = PartNames[(int)part]; var info1 = GetFashionOutward(partName, fashionOutInfo.FashionOutwardArray); if (null == info1) { HobaDebuger.LogWarningFormat("fashion info is null"); return(true); } SaveDefaultOutward(part, smr); SetSmrPropertyByFashionInfo(part, smr, info1); // body时装可能用到两套材质球 if (part == OutwardPart.Body) { var bodyRoot = smr.gameObject; var extraInfo = GetFashionOutward(ExtraBodyNames, fashionOutInfo.FashionOutwardArray); if (null != extraInfo) { var extrabodyTrans = transform.Find(ExtraBodyNames); if (extrabodyTrans == null) { var extrabody = GameObject.Instantiate(bodyRoot, transform); extrabody.name = ExtraBodyNames; extrabodyTrans = extrabody.transform; _ExtraTransDic[(int)part].Add(extrabodyTrans); } var extraSmr = extrabodyTrans.GetComponent <SkinnedMeshRenderer>(); if (null != extraSmr) { extraSmr.rootBone = transform.Find(extraInfo.RootBonesPath); SetSmrPropertyByFashionInfo(part, extraSmr, extraInfo); } } } //加载特效信息 var outwardSfx = prefab.GetComponent <OutwardSfx>(); if (null != outwardSfx) { LoadOutwardGfx(part, outwardSfx, assetPath); } //UpdateDynamicBoneInfo(part, prefab); UpdateDynamicBoneInfo(part, fashionOutInfo.DynamicBoneInfoArray); return(true); }
public static int GetScenePath(IntPtr L) { int count = LuaDLL.lua_gettop(L); const int nRet = 1; if (count == 1 && (LuaScriptMgr.CheckTypes(L, 1, typeof(GameObject)))) { var go = LuaScriptMgr.GetUnityObject <GameObject>(L, 1); if (go == null) { HobaDebuger.LogError("GetScenePath: GameObject got null"); LuaDLL.lua_pushstring(L, string.Empty); return(CheckReturnNum(L, count, nRet)); } Transform trans = go.transform; string s = ""; while (trans != null) { s = trans.name + "/" + s; trans = trans.parent; } LuaDLL.lua_pushstring(L, s); } else { LuaDLL.lua_pushstring(L, string.Empty); LogParamError("GetScenePath", count); } return(CheckReturnNum(L, count, nRet)); }
private void SetSmrPropertyByOutwardInfo(SkinnedMeshRenderer smr, OutwardInfo outwardInfo) { if (smr == null) { return; } smr.sharedMesh = outwardInfo.Mesh; smr.sharedMaterial = outwardInfo.Material; if (outwardInfo.Bones == null) { HobaDebuger.LogWarning("Bones info is null"); return; } var boneCount = outwardInfo.Bones.Length; Transform[] bones = new Transform[boneCount]; Transform newAddedRoot = null; for (int i = 0; i < boneCount; i++) { bones[i] = FindBone(outwardInfo.Bones[i], Vector3.zero, Vector3.zero, Vector3.one, false, out newAddedRoot); } smr.bones = bones; }
private void OnDownloadRecordFileComplete(bool success, string filePath, string fileId, AudioFormat audioFormat) { FileIdDownloadingSet.Remove(fileId); int code = success ? 0 : 1; //call lua IntPtr L = LuaScriptMgr.Instance.GetL(); if (L != IntPtr.Zero) { int oldTop = LuaDLL.lua_gettop(L); LuaDLL.lua_getglobal(L, "Voice_OnDownloadRecordFileComplete"); if (!LuaDLL.lua_isnil(L, -1)) { LuaDLL.lua_pushinteger(L, code); LuaDLL.lua_pushstring(L, filePath); LuaDLL.lua_pushstring(L, fileId); if (LuaDLL.lua_pcall(L, 3, 0, 0) != 0) { HobaDebuger.LogLuaError(LuaDLL.lua_tostring(L, -1)); } } LuaDLL.lua_settop(L, oldTop); } }