public Object Get(string a_name) { if (names.Contains(a_name)) { return(Get(names.IndexOf(a_name) + 1)); } GLog.LogError(a_name + " does not exists in UIRefrence namelist!:" + name); return(null); }
/// <summary> /// /// </summary> /// <param name="cacheType"></param> private void ReleaseBundle(XSheet.XCacheType cacheType) { float now = Time.time; for (int i = 0; i < allInfo.Count; i++) { XAssetBundleInfo info = allInfo[i]; if (info.isDone && info.Unused(now)) { if (info.pack.cacheType != cacheType && info.pack.cacheType != XSheet.XCacheType.None) { continue; } #if !RELEASE if (info.Ref() < 0) { GLog.LogError("XAssetManager.Unload bundle:{0} refCount({1}) incorrect!", info.pack.name, info.Ref()); } #endif info.ResetRef(); for (int depIndex = 0; depIndex < info.pack.dependencies.Length; depIndex++) { string dependence = info.pack.dependencies[depIndex]; XAssetBundleInfo dependenceInfo = GetAssetBundleInfo(dependence); if (dependenceInfo != null) { dependenceInfo.RemoveDepended(info.pack.name); } } } } for (int i = 0; i < allInfo.Count; i++) { XAssetBundleInfo info = allInfo[i]; if (info.isDone && info.Unused(now)) { if (info.pack.cacheType != cacheType && info.pack.cacheType != XSheet.XCacheType.None) { continue; } if (info.DependedCount() == 0) { info.bundle.Unload(false); info.bundle = null; info.isDone = false; GLog.Log("AssetManager.UnloadAssetBundle bundle:{0} unloaded ref:{1} cache type: {2}", info.pack.name, info.Ref(), info.pack.cacheType.ToString()); } } } }
// Update is called once per frame void Update() { if (lastHeartBeatTime == 0) { lastHeartBeatTime = Time.unscaledTime; } if (lastPongTime == 0) { lastPongTime = Time.unscaledTime; } // 检测网络状态 if ((Time.unscaledTime - lastPongTime) >= PONG_INTERVAL) { if (GLog.IsLogInfoEnabled) { GLog.LogInfo("SocketDispatch Update step 1 NETWORK_ERR"); } SocketManager.Instance.OnChanageSocketState(SocketState.NETWORK_ERR); lastPongTime = 0; } if ((Time.unscaledTime - lastHeartBeatTime >= HEART_BEAT_INTERVAL) && (ClientSocket.GetSocketConnectState())) { ClientSocket.Send(2, "{}"); lastHeartBeatTime = Time.unscaledTime; } #if UNITY_EDITOR if (lastCheckTime == 0) { lastCheckTime = Time.unscaledTime; } if (Time.unscaledTime - lastCheckTime >= Check_Time) { if (!ClientSocket.GetSocketConnectState()) { if (GLog.IsLogErrorEnabled) { GLog.LogError("SocketDispatch step 2 socket DisConnect !!!"); } } else { //if (GLog.IsLogInfoEnabled) GLog.LogInfo("SocketDispatch step 2 "); } lastCheckTime = Time.unscaledTime; } #endif ClientSocket.Update(); }
public Object Get(int a_index) { a_index -= 1; if (a_index < 0 || a_index >= monos.Count) { GLog.LogError("index out of Range! got null reference!:" + name); return(null); } return(monos[a_index]); }
public XBoxRect GetBulletWarningBox() { if (hitBox_ == null) { GLog.LogError("BULLET DO NOT HAVE A HIT BOX!"); return(null); } return(hitBox_.GetFixedWarningBox(_flip)); }
public static int ClrFuncPrintError(IntPtr l) { using (var lr = new LuaStateRecover(l)) { var obj = l.GetLua(1).UnwrapDynamic(); if (GLog.IsLogErrorEnabled) { GLog.LogError(obj); } } return(0); }
/// <summary> /// 叠加方式打开文件 /// </summary> /// <param name="path"></param> /// 海鸣不骑猪 2018.4.24 修改 /// <param name="isCheckAndCreateDir">是否检查文件目录结构是否存在 如果不存在则进行创建文件</param> /// <returns></returns> public static Stream OpenAppend(this string path, bool isCheckAndCreateDir = true) { try { FileStream stream = null; if (isCheckAndCreateDir) { CreateFolder(Path.GetDirectoryName(path)); stream = File.OpenWrite(path); } else ///如果是运行时不检查并创建文件夹 则需要做安全处理防止在运行过程中文件被销毁 { try { stream = File.OpenWrite(path); } catch (Exception e) { if (GLog.IsLogErrorEnabled) { GLog.LogException(e); } CreateFolder(Path.GetDirectoryName(path)); stream = File.OpenWrite(path); } } if (stream != null) { if (stream.CanSeek) { stream.Seek(0, SeekOrigin.End); } else { if (GLog.IsLogErrorEnabled) { GLog.LogError(path + " cannot append."); } } } return(stream); } catch (Exception e) { if (GLog.IsLogErrorEnabled) { GLog.LogException(e); } return(null); } }
public void Register(XBoxComponent hero) { if (hero == null) { GLog.LogError("REGISTER a null hero??"); return; } if (_heroes.Contains(hero)) { GLog.LogError("REGISTER a duplicate hero?? {0}", hero.gameObject.name); return; } _heroes.Add(hero); }
static void GenerateLightmapInfo(GameObject root, List <RendererInfo> newRendererInfos, List <Texture2D> newLightmapsLight, List <Texture2D> newLightmapsDir, LightmapsMode newLightmapsMode) { //BuglyAgent.PrintLog(LogSeverity.LogDebug, "GenerateLightmapInfo"); var renderers = FindObjectsOfType(typeof(MeshRenderer)); if (GLog.IsLogInfoEnabled) { GLog.LogInfo("stored info for " + renderers.Length + " meshrenderers"); } foreach (MeshRenderer renderer in renderers) { if (renderer.lightmapIndex != -1) { RendererInfo info = new RendererInfo(); info.renderer = renderer; info.lightmapOffsetScale = renderer.lightmapScaleOffset; if (renderer.lightmapIndex >= LightmapSettings.lightmaps.Length) { if (GLog.IsLogErrorEnabled) { GLog.LogError("Render Errror"); } continue; } Texture2D lightmaplight = LightmapSettings.lightmaps[renderer.lightmapIndex].lightmapColor; info.lightmapIndex = newLightmapsLight.IndexOf(lightmaplight); if (info.lightmapIndex == -1) { info.lightmapIndex = newLightmapsLight.Count; newLightmapsLight.Add(lightmaplight); } if (newLightmapsMode != LightmapsMode.NonDirectional) { Texture2D lightmapdir = LightmapSettings.lightmaps[renderer.lightmapIndex].lightmapDir; info.lightmapIndex = newLightmapsDir.IndexOf(lightmapdir); if (info.lightmapIndex == -1) { info.lightmapIndex = newLightmapsDir.Count; newLightmapsDir.Add(lightmapdir); } } newRendererInfos.Add(info); } } }
/// <summary> /// /// </summary> /// <param name="bundleInfo"></param> /// <param name="loadDependence"></param> /// <returns></returns> private IEnumerator LoadAssetBundleAsync(XAssetBundleInfo bundleInfo, bool loadDependence = true) { while (bundleInfo.isLoading) { yield return(null); } if (bundleInfo.isDone) { yield break; } GLog.Log("XBundleManager.LoadAssetBundleAsync {0}", bundleInfo.url); bundleInfo.isLoading = true; if (loadDependence) { yield return(XCoroutine.Run(LoadDependenciesAsync(bundleInfo.pack))); } string bundleName = bundleInfo.pack.name; AssetBundleCreateRequest loader = AssetBundle.LoadFromFileAsync(bundleInfo.url); yield return(loader); if (!loader.isDone) { bundleInfo.isLoading = false; GLog.LogError("XBundleManager.LoadAssetBundle can't async load bundle: {0} reason: {1}", bundleName, "NOT FOUND!"); } else { bundleInfo.isLoading = false; if (loader.assetBundle != null) { bundleInfo.bundle = loader.assetBundle; bundleInfo.isDone = true; GLog.Log("XBundleManager.LoadAssetBundle async load done bundle: {0}", bundleName); } else { GLog.LogError("AssetBundleManager.LoadAssetBundle can't async load bundle: {0}", bundleName); } } }
/// <summary> /// 插入一条数据到指定位置 /// </summary> /// <param name="data">要插入的数据</param> /// <param name="index">要插入数据的位置</param> /// <param name="scrollFlag">滚动flag true - 滚动到插入元素的位置; 默认false - 不滚动</param> /// <returns>如果插入的位置是正在显示中的位置元素,则返回这个元素</returns> public virtual ScrollElement InsertData(Object _data, int index, bool scrollFlag = false) { if (null == datas) { GLog.LogError("Can not insert data because scroll list has not called SetData!"); return(null); } datas.Insert(index, new ScrollDataElement() { data = _data }); CalculateSize(index); if (scrollFlag) { ScrollTo(index); } return(null); }
public void CallGlobalVoid(string funcname, params object[] args) { var l = L; using (var lr = new LuaStateRecover(l)) { if (!l.GetHierarchicalRaw(lua.LUA_GLOBALSINDEX, funcname)) { return; } if (l.PushArgsAndCallRaw(args) != 0) { if (GLog.IsLogErrorEnabled) { GLog.LogError(l.GetLua(-1).UnwrapDynamic()); } } } }
internal static byte[] DicToBytes(Object arg) { try { Type type = arg.GetType(); MethodInfo enumrator = type.GetMethod("GetEnumerator", BindingFlags.Instance | BindingFlags.Public); object objEnum = enumrator.Invoke(arg, null); MethodInfo moveNext = objEnum.GetType().GetMethod("MoveNext", BindingFlags.Instance | BindingFlags.Public); List <byte> list = new List <byte>(); bool gotNext = (bool)moveNext.Invoke(objEnum, null); while (true) { if (!gotNext) { break; } object current = objEnum.GetType().GetProperty("Current", BindingFlags.Instance | BindingFlags.Public).GetValue(objEnum, null); object key = current.GetType().GetProperty("Key", BindingFlags.Instance | BindingFlags.Public).GetValue(current, null); object value = current.GetType().GetProperty("Value", BindingFlags.Instance | BindingFlags.Public).GetValue(current, null); byte[] bufferKey = Serializer.GetBytes(key); byte[] bufferVal = Serializer.GetBytes(value); if (bufferKey == default(byte[]) || bufferVal == default(byte[])) { continue; } list.AddRange(bufferKey); list.AddRange(bufferVal); gotNext = (bool)moveNext.Invoke(objEnum, null); } list.InsertRange(0, list.Count.ToBytes()); return(list.ToArray()); } catch (Exception e) { GLog.LogError(e.ToString()); } return(default(byte[])); }
private void CreateItem(int index) { ScorllItemData itemData; if (unUsedItemQueue.Count > 0) { itemData = unUsedItemQueue.Dequeue(); ResetBaseItemData(index, itemData); } else { int adjustIndex = index; if (isLoop) { adjustIndex = adjustIndex % totalCount; if (adjustIndex < 0) { adjustIndex += totalCount; } } var obj = CreateItemLuaFunc(adjustIndex); if (obj == null) { if (GLog.IsLogErrorEnabled) { GLog.LogError("Expected to find obj of type gameObject,but found none" + obj); } } itemData = new ScorllItemData(); itemData.index = index; itemData.gameObject = obj; var rectTransf = itemData.gameObject.GetComponent <RectTransform>(); rectTransf.SetParent(contentTransform, false); rectTransf.anchorMin = new Vector2(0, 1); rectTransf.anchorMax = new Vector2(0, 1); rectTransf.pivot = new Vector2(0, 1); rectTransf.sizeDelta = cellSize; rectTransf.anchoredPosition = GetPosition(index); } itemList.Add(itemData); }
public IEnumerator PlayAudio(string path, float volume, bool loop = false) { ClipVolume = volume; var clip = ResManager.LoadRes(path, typeof(AudioClip)) as AudioClip; if (clip) { audioSource.clip = clip; ApplyVolume(); audioSource.Play(); audioSource.loop = loop; yield return(new AudioPlayEndYieldInstruction(audioSource)); } else { if (GLog.IsLogErrorEnabled) { GLog.LogError("Audio clip not found, path :" + path); } } }
bool EnsureDirectory(string path) { try { path.Replace("\\", "/"); if (path.Contains(".")) { path = path.Substring(0, path.LastIndexOf("/") + 1); } if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } return(true); } catch (Exception e) { GLog.LogError(e.ToString()); } return(false); }
protected internal object[] ResumeRaw(params object[] args) { if (_IsDone) { return(null); } if (args != null) { for (int i = 0; i < args.Length; ++i) { L.PushLua(args[i]); } } int status = L.resume(args == null ? 0 : args.Length); if (status == lua.LUA_YIELD || status == 0) { object[] rv = ObjectPool.GetReturnValueFromPool(L.gettop()); for (int i = 0; i < rv.Length; ++i) { rv[i] = L.GetLua(i + 1); } if (status == 0) { _IsDone = true; } return(rv); } else { L.pushcfunction(Capstones.LuaExt.LuaFramework.ClrDelErrorHandler); L.insert(-2); L.pcall(1, 1, 0); if (GLog.IsLogErrorEnabled) { GLog.LogError(L.GetLua(-1).UnwrapDynamic()); } } return(null); }
public void AddItem(int index) { if (isLoop) // 循环滚动增加容易造成数据混乱 { return; } if (index > totalCount) { if (GLog.IsLogErrorEnabled) { GLog.LogError("add error:" + index); } return; } totalCount += 1; AddItemIntoPanel(index); if (isShowLine) { AddLine(); } UpdateTotalWidthAndHeight(); }
private void CreateLine(int index) { ScorllItemData lineData; if (unUsedLineQueue.Count > 0) { lineData = unUsedLineQueue.Dequeue(); ResetBaseLineData(index, lineData); } else { var lineObject = CreateLineLuaFunc(index); if (lineObject == null) { if (GLog.IsLogErrorEnabled) { GLog.LogError("Expected to find obj of type gameObject,but found none" + lineObject); } } var rectTransf = lineObject.GetComponent <RectTransform>(); rectTransf.SetParent(contentTransform, false); rectTransf.anchorMin = new Vector2(0, 1); rectTransf.anchorMax = new Vector2(0, 1); rectTransf.pivot = GetVector2WithDirection(0.5f, 1.0f - directionAxisIndex); rectTransf.anchoredPosition = GetVector2WithDirection( directionSign[directionAxisIndex] * (cellSizeWithSpace[directionAxisIndex] * (index + 1) - (cellSpace[directionAxisIndex] + lineSpace) / 2), 0 ); rectTransf.sizeDelta = GetVector2WithDirection( lineSpace, GetComponent <RectTransform>().rect.size[otherDirectionAxisIndex] ); lineData = new ScorllItemData(); lineData.index = index; lineData.gameObject = lineObject; } lineList.Add(lineData); }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { // Rely on the default inspector GUI EditorGUI.BeginChangeCheck(); EditorGUI.PropertyField(position, property, label); // Update only when necessary SetPropertyAttribute setProperty = attribute as SetPropertyAttribute; if (EditorGUI.EndChangeCheck()) { // When a SerializedProperty is modified the actual field does not have the current value set (i.e. // FieldInfo.GetValue() will return the prior value that was set) until after this OnGUI call has completed. // Therefore, we need to mark this property as dirty, so that it can be updated with a subsequent OnGUI event // (e.g. Repaint) setProperty.IsDirty = true; } else if (setProperty.IsDirty) { // The propertyPath may reference something that is a child field of a field on this Object, so it is necessary // to find which object is the actual parent before attempting to set the property with the current value. object parent = GetParentObjectOfProperty(property.propertyPath, property.serializedObject.targetObject); Type type = parent.GetType(); PropertyInfo pi = type.GetProperty(setProperty.Name); if (pi == null) { GLog.LogError("Invalid property name: " + setProperty.Name + "\nCheck your [SetProperty] attribute"); } else { // Use FieldInfo instead of the SerializedProperty accessors as we'd have to deal with every // SerializedPropertyType and use the correct accessor pi.SetValue(parent, fieldInfo.GetValue(parent), null); } setProperty.IsDirty = false; } }
/// <summary> /// /// </summary> /// <param name="name"></param> public static void LoadScene(string name) { XBundleManager.Instance.ReleaseSceneCachedBundleOnSceneSwitch(); XSheet.XScene info = XSheet.Instance.GetScene(name); if (info != null) { XSheet.XPack packInfo = XSheet.Instance.GetPack(info.bundleName); switch (packInfo.locationType) { case XSheet.XLocationType.Resource: GLog.LogError("XRes.LoadScene can't load bundled scene {0} in resource!", name); break; default: GLog.LogError("[XRes] can't load scene in sync load {0}", name); break; } } else { SceneManager.LoadScene(name); } }
/// <summary> /// 添加一条数据至数据表结尾处 /// </summary> /// <param name="data">要添加的数据</param> /// <param name="scrollFlag">滚动flag true - 滚动到最后一个元素;默认是false - 不滚动</param> public virtual void AddData(Object _data, bool scrollFlag = false) { if (null != datas) { if (null == _data) { GLog.LogError("Can not add null data to scroll list!"); return; } datas.Add(new ScrollDataElement() { data = _data }); CalculateSize(datas.Count - 1); if (scrollFlag) { ScrollTo(datas.Count - 1); } } else { GLog.LogError("null datas can not add new data,use SetData instead!"); } }
public void CallGlobalSelfVoid(string objname, string funcname, params object[] args) { var l = L; using (var lr = new LuaStateRecover(l)) { if (!l.GetHierarchicalRaw(lua.LUA_GLOBALSINDEX, objname)) { return; } var _self = l.GetLuaOnStack(-1); if (!l.GetHierarchicalRaw(-1, funcname)) { return; } var paramCnt = 0; if (args != null) { paramCnt = args.Length; } var rargs = ObjectPool.GetParamsFromPool(paramCnt + 1); rargs[0] = _self; for (int i = 0; i < paramCnt; ++i) { rargs[i + 1] = args[i]; } if (l.PushArgsAndCallRaw(rargs) != 0) { if (GLog.IsLogErrorEnabled) { GLog.LogError(l.GetLua(-1).UnwrapDynamic()); } } ObjectPool.ReturnParamsToPool(rargs); } }
public void RemoveItem(int index) // 内部索引 会跟着item刷数据走,不是真实索引 { // 循环滚动删除容易造成数据混乱 if (isLoop) { return; } if (index < 0 || index > totalCount - 1) { if (GLog.IsLogErrorEnabled) { GLog.LogError("删除错误:" + index); } return; } totalCount = totalCount - 1; DelItemFromPanel(index); UpdateTotalWidthAndHeight(); if (isShowLine) { DeleteLine(); } }
public static void LogError(this object obj) { GLog.LogError(obj); }
public void StoreLightmapInfos(int index) { if (GLog.IsLogInfoEnabled) { GLog.LogInfo("Storing data for lighting scenario " + index); } if (UnityEditor.Lightmapping.giWorkflowMode != UnityEditor.Lightmapping.GIWorkflowMode.OnDemand) { if (GLog.IsLogErrorEnabled) { GLog.LogError("ExtractLightmapData requires that you have baked you lightmaps and Auto mode is disabled."); } return; } var newLightingScenarioData = new LightingScenarioData(); var newRendererInfos = new List <RendererInfo>(); var newLightmapsTextures = new List <Texture2D>(); var newLightmapsTexturesDir = new List <Texture2D>(); var newLightmapsMode = new LightmapsMode(); var newSphericalHarmonicsList = new List <SphericalHarmonics>(); newLightmapsMode = LightmapSettings.lightmapsMode; GenerateLightmapInfo(gameObject, newRendererInfos, newLightmapsTextures, newLightmapsTexturesDir, newLightmapsMode); newLightingScenarioData.lightmapsMode = newLightmapsMode; newLightingScenarioData.lightmaps = newLightmapsTextures.ToArray(); if (newLightmapsMode != LightmapsMode.NonDirectional) { newLightingScenarioData.lightmapsDir = newLightmapsTexturesDir.ToArray(); } newLightingScenarioData.rendererInfos = newRendererInfos.ToArray(); var scene_LightProbes = new SphericalHarmonicsL2[LightmapSettings.lightProbes.bakedProbes.Length]; scene_LightProbes = LightmapSettings.lightProbes.bakedProbes; for (int i = 0; i < scene_LightProbes.Length; i++) { var SHCoeff = new SphericalHarmonics(); // j is coefficient for (int j = 0; j < 3; j++) { //k is channel ( r g b ) for (int k = 0; k < 9; k++) { SHCoeff.coefficients[j * 9 + k] = scene_LightProbes[i][j, k]; } } newSphericalHarmonicsList.Add(SHCoeff); } newLightingScenarioData.lightProbes = newSphericalHarmonicsList.ToArray(); lightingScenariosData = newLightingScenarioData; if (lightingScenesNames == null || lightingScenesNames.Count < lightingScenariosCount) { lightingScenesNames = new List <string>(); while (lightingScenesNames.Count < lightingScenariosCount) { lightingScenesNames.Add(null); } } }
public static BaseLua BindBehav(this CapsUnityLuaBehav behav) { using (var lr = GlobalLua.CreateStackRecover()) { var l = GlobalLua.L; if (behav == null) { return(null); } if (string.IsNullOrEmpty(behav.InitLuaPath)) { return(CreateUserDataAndExpandExFields(behav)); } int oldtop = lr.Top; bool luaFileDone = false; l.pushcfunction(LuaFramework.ClrDelErrorHandler); l.GetGlobal("require"); l.PushString(behav.InitLuaPath); if (l.pcall(1, 1, -3) == 0) { if (l.gettop() > oldtop + 1 && l.istable(oldtop + 2)) { luaFileDone = true; } else { if (GLog.IsLogErrorEnabled) { GLog.LogError("Failed to init script by require " + behav.InitLuaPath + ". (Not a table.) Now Init it by file."); } } } else { if (GLog.IsLogErrorEnabled) { GLog.LogError(l.GetLua(-1).UnwrapDynamic() + "\nFailed to init script by require " + behav.InitLuaPath + ". Now Init it by file."); } } if (!luaFileDone) { if (GLog.IsLogInfoEnabled) { GLog.LogInfo("Init it by file. - Disabled"); } //string path = behav.InitLuaPath; //if (path.EndsWith(".lua")) //{ // path = path.Substring(0, path.Length - 4); //} //path = path.Replace('.', '/'); //path = path.Replace('\\', '/'); //if (!path.StartsWith("spt/")) //{ // path = "spt/" + path; //} //path += ".lua"; //path = ResManager.UpdatePath + "/" + path; //l.settop(oldtop); //if (l.dofile(path) == 0) //{ // if (l.gettop() > oldtop && l.istable(oldtop + 1)) // { // luaFileDone = true; // } // else // { // if (GLog.IsLogInfoEnabled) GLog.LogInfo("Failed to load script " + path + ". (Not a table.)"); // } //} //else //{ // if (GLog.IsLogInfoEnabled) GLog.LogInfo(l.GetLua(-1).UnwrapDynamic()); // if (GLog.IsLogInfoEnabled) GLog.LogInfo("Failed to load script " + path); //} } if (luaFileDone) { l.GetField(oldtop + 2, "attach"); if (l.isfunction(-1)) { var ud = CreateUserDataAndExpandExFields(behav); l.getref(ud.Refid); if (l.pcall(1, 0, oldtop + 1) == 0) { } else { if (GLog.IsLogErrorEnabled) { GLog.LogError(l.GetLua(-1).UnwrapDynamic()); } } return(ud); } } return(CreateUserDataAndExpandExFields(behav)); } }
public object GetFieldFor(object tar, object key) { if (_BindingType == null) { return(null); } tar = tar.UnwrapDynamic(); key = key.UnwrapDynamic(); var fields = _ExpandedFields; if (tar == null) { fields = _StaticFields; } object finfo = null; if (key is string) { finfo = GetFieldDescFor(tar, key as string); if (finfo is PropertyInfo) { var pmethod = ((PropertyInfo)finfo).GetGetMethod(); if (pmethod != null) { try { //return ((PropertyInfo)finfo).GetValue(tar, null).WrapDynamic(); var args = ObjectPool.GetParamsFromPool(0); var rv = pmethod.Invoke(tar, args); ObjectPool.ReturnParamsToPool(args); return(rv); } catch { if (GLog.IsLogErrorEnabled) { GLog.LogError("Unable to get property: " + key); } throw; } } else { return(null); } } else if (finfo is FieldInfo) { return(((FieldInfo)finfo).GetValue(tar)); } else if (finfo is ICallableCore) { var core = finfo as ICallableCore; var callable = ClrCallable.GetFromPool(core, tar); return(callable); } else if (finfo is EventInfo) { return(ClrEventWrapper.GetFromPool(finfo as EventInfo, tar)); } } if (finfo == null) { object indexmethod = null; if (fields.TryGetValue("get_Item", out indexmethod)) { if (indexmethod is ICallableCore) { var callable = ClrCallable.GetFromPool((ICallableCore)indexmethod, tar); var rv = callable.Call(key); callable.ReturnToPool(); if (rv != null && rv.Length > 0) { return(rv[0]); } } } else if (tar is IList) { // special treat to array. var ikey = key.ConvertType(typeof(int)); if (ikey != null) { try { var rv = ((IList)tar)[(int)ikey]; return(rv); } catch { } } } } return(finfo); }
/// <summary> /// Merge object right into left recursively /// </summary> /// <param name="left">The left (base) object</param> /// <param name="right">The right (new) object</param> static void MergeRecur(JSONObject left, JSONObject right) { if (left.type == Type.NULL) { left.Absorb(right); } else if (left.type == Type.OBJECT && right.type == Type.OBJECT) { for (int i = 0; i < right.list.Count; i++) { string key = right.keys[i]; if (right[i].isContainer) { if (left.HasField(key)) { MergeRecur(left[key], right[i]); } else { left.AddField(key, right[i]); } } else { if (left.HasField(key)) { left.SetField(key, right[i]); } else { left.AddField(key, right[i]); } } } } else if (left.type == Type.ARRAY && right.type == Type.ARRAY) { if (right.Count > left.Count) { if (GLog.IsLogErrorEnabled) { GLog.LogError("Cannot merge arrays when right object has more elements"); } return; } for (int i = 0; i < right.list.Count; i++) { if (left[i].type == right[i].type) //Only overwrite with the same type { if (left[i].isContainer) { MergeRecur(left[i], right[i]); } else { left[i] = right[i]; } } } } }
/// <summary> /// init 方法 /// </summary> public void Init() { if (_isInit) { return; } //视频组件在模拟器上面不进行播放 if (CheckPlayVideo()) { // if (GLog.IsLogInfoEnabled) GLog.LogInfo("VideoPlayerManager 最低不是最低处理机型 [" + QualityManager.GetLevel() + " ] [ " + MinimumAdaptation + " ]"); if (targetRawImage != null && targetRawImage.gameObject != null) { targetRawImage.enabled = false; } _isInit = false; return; } if (targetRawImage == null) { if (GLog.IsLogErrorEnabled) { GLog.LogError("VideoPlayerManager 中的渲染组件targetRawImage 不存在 "); } _isInit = false; return; } if (_targetRenderTexture == null) { var h = Application.isEditor ? MaxH : Math.Min(Screen.height, MaxH); int w = Application.isEditor ? MaxW : Mathf.FloorToInt(h * (MaxW * 1.0f / MaxH)); _targetRenderTexture = RenderTexture.GetTemporary(w, h, 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.sRGB); _targetRenderTexture.useMipMap = false; _targetRenderTexture.wrapMode = TextureWrapMode.Clamp; _targetRenderTexture.filterMode = FilterMode.Point; _targetRenderTexture.useMipMap = false; } else { RenderTexture.ReleaseTemporary(_targetRenderTexture); } if (videoPlayer == null) { videoPlayer = gameObject.AddComponent <VideoPlayer>(); videoPlayer.playOnAwake = true; videoPlayer.waitForFirstFrame = true; videoPlayer.isLooping = true; videoPlayer.playbackSpeed = 1; } videoPlayer.renderMode = VideoRenderMode.RenderTexture; videoPlayer.targetTexture = _targetRenderTexture; _targetRenderTexture.name = "VideoPlayerManager"; videoPlayer.prepareCompleted += PrepareCompleted; videoPlayer.errorReceived += ErrorReceived; videoPlayer.loopPointReached += LoopEnd; videoPlayer.url = Application.streamingAssetsPath + "/" + videoPath; targetRawImage.texture = _targetRenderTexture; _isInit = true; }