//清空所有子节点 protected virtual bool OnClearChild() { Debuger.LogError("没有实现"); return(false); }
//======================================================================= //设置FSP参数 public void SetFrameInterval(int serverFrameInterval, int clientFrameRateMultiple) //MS { Debuger.Log("serverFrameInterval:{0}, clientFrameRateMultiple:{1}", serverFrameInterval, clientFrameRateMultiple); m_param.serverFrameInterval = serverFrameInterval; m_param.clientFrameRateMultiple = clientFrameRateMultiple; }
//增加一个子节点 protected virtual bool OnAddChild(string key, ISerializableObject item) { Debuger.LogError("没有实现"); return(false); }
//删除一个子节点 protected virtual bool OnRemoveChild(int idx) { Debuger.LogError("没有实现"); return(false); }
//--------------------------------------------------------- /// <summary> /// 处理来自客户端的 Cmd /// 对其中的关键VKey进行处理 /// 并且收集业务VKey /// </summary> /// <param name="player"></param> /// <param name="cmd"></param> protected virtual void HandleClientCmd(FSPPlayer player, FSPVKey cmd) { uint playerId = player.Id; //处理鉴权 if (!player.HasAuth) { Debuger.Log(LOG_TAG, "HandleClientCmd() hasAuth = false! Wait AUTH!"); if (cmd.vkey == FSPVKeyBase.AUTH) { Debuger.Log(LOG_TAG, "HandleClientCmd() AUTH, playerId={0}", playerId); player.SetAuth(cmd.args[0]); } return; } switch (cmd.vkey) { case FSPVKeyBase.GAME_BEGIN: { Debuger.Log(LOG_TAG, "HandleClientCmd() GAME_BEGIN, playerId = {0}, cmd = {1}", playerId, cmd); SetFlag(playerId, ref m_GameBeginFlag, "m_GameBeginFlag"); break; } case FSPVKeyBase.ROUND_BEGIN: { Debuger.Log(LOG_TAG, "HandleClientCmd() ROUND_BEGIN, playerId = {0}, cmd = {1}", playerId, cmd); SetFlag(playerId, ref m_RoundBeginFlag, "m_RoundBeginFlag"); break; } case FSPVKeyBase.CONTROL_START: { Debuger.Log(LOG_TAG, "HandleClientCmd() CONTROL_START, playerId = {0}, cmd = {1}", playerId, cmd); SetFlag(playerId, ref m_ControlStartFlag, "m_ControlStartFlag"); break; } case FSPVKeyBase.ROUND_END: { Debuger.Log(LOG_TAG, "HandleClientCmd() ROUND_END, playerId = {0}, cmd = {1}", playerId, cmd); SetFlag(playerId, ref m_RoundEndFlag, "m_RoundEndFlag"); break; } case FSPVKeyBase.GAME_END: { Debuger.Log(LOG_TAG, "HandleClientCmd() GAME_END, playerId = {0}, cmd = {1}", playerId, cmd); SetFlag(playerId, ref m_GameEndFlag, "m_GameEndFlag"); break; } case FSPVKeyBase.GAME_EXIT: { Debuger.Log(LOG_TAG, "HandleClientCmd() GAME_EXIT, playerId = {0}, cmd = {1}", playerId, cmd); HandleGameExit(playerId, cmd); break; } default: { Debuger.Log(LOG_TAG, "HandleClientCmd() playerId = {0}, cmd = {1}", playerId, cmd); AddCmdToCurrentFrame(playerId, cmd); break; } } }
public override void OnDestroy() { Debuger.Info(base.GetType().get_Name() + " OnDestroy", new object[0]); }
protected virtual void HandleClientCmd(FSPPlayer player, FSPMessage msg) { uint playerId = player.id; //处理鉴权 if (!player.HasAuthed) { if (msg.cmd == FSPBasicCmd.AUTH) { player.SetAuth(msg.args[0]); } else { Debuger.LogWarning("当前Player未鉴权,无法处理该Cmd:{0}", msg.cmd); } return; } switch (msg.cmd) { case FSPBasicCmd.GAME_BEGIN: { Debuger.Log("GAME_BEGIN, playerId = {0}, cmd = {1}", playerId, msg); SetFlag(playerId, ref m_GameBeginFlag, "m_GameBeginFlag"); break; } case FSPBasicCmd.ROUND_BEGIN: { Debuger.Log("ROUND_BEGIN, playerId = {0}, cmd = {1}", playerId, msg); SetFlag(playerId, ref m_RoundBeginFlag, "m_RoundBeginFlag"); break; } case FSPBasicCmd.CONTROL_START: { Debuger.Log("CONTROL_START, playerId = {0}, cmd = {1}", playerId, msg); SetFlag(playerId, ref m_ControlStartFlag, "m_ControlStartFlag"); break; } case FSPBasicCmd.ROUND_END: { Debuger.Log("ROUND_END, playerId = {0}, cmd = {1}", playerId, msg); SetFlag(playerId, ref m_RoundEndFlag, "m_RoundEndFlag"); break; } case FSPBasicCmd.GAME_END: { Debuger.Log("GAME_END, playerId = {0}, cmd = {1}", playerId, msg); SetFlag(playerId, ref m_GameEndFlag, "m_GameEndFlag"); break; } case FSPBasicCmd.GAME_EXIT: { Debuger.Log("GAME_EXIT, playerId = {0}, cmd = {1}", playerId, msg); HandleGameExit(playerId, msg); break; } default: { Debuger.Log("playerId = {0}, cmd = {1}", playerId, msg); AddCmdToCurrentFrame(playerId, msg); break; } } }
public static void LogError(string log) { Debuger.LogError(log); }
static public void AddAniToRolePrefab() { GameObject model = Selection.activeGameObject; if (model == null) { Debuger.LogError("请先选中一个模型"); return; } string name = model.name; int postfix = name.IndexOf("@"); if (postfix != -1) { name = name.Substring(0, postfix); } Debuger.Log("要找的模型名:{0}", name); //拿之前的预制体和创建一个临时的对象(这里不支持覆盖,因为可能会导致绑定在动作上的特效的骨骼点丢失) string path = string.Format("Assets/FBX/Resources/{0}.prefab", name); GameObject prefab = AssetDatabase.LoadAssetAtPath <GameObject>(path); if (prefab == null) { EditorUtility.DisplayDialog("", string.Format("{0}不存在不能添加动作", path), "确定"); return; } string modelPath = AssetDatabase.GetAssetPath(model); Transform mod = prefab.transform.Find("model"); Animation ani = mod.GetComponent <Animation>(); UnityEngine.Object.DestroyImmediate(ani, true);//删除老的animation ani = mod.gameObject.AddComponent <Animation>(); ////删除掉所有老动作 //SerializedObject so = new SerializedObject(ani); //so.Update(); //SerializedProperty serializedProperty = so.FindProperty("m_Animation"); //serializedProperty.objectReferenceValue=null; //SerializedProperty serializedProperty2 = so.FindProperty("m_Animations"); //serializedProperty2.ClearArray(); //so.ApplyModifiedProperties(); //UnityEditor.AssetDatabase.Refresh(); //UnityEditor.AssetDatabase.SaveAssets(); //找到所有动作并加到临时对象的模型上 string dir = System.IO.Path.GetDirectoryName(modelPath); string filter = "t:AnimationClip";//string.Format("n:{0}@", model.name); string[] guids = AssetDatabase.FindAssets(filter, new string[] { dir }); foreach (string guid in guids) { string aniPath = AssetDatabase.GUIDToAssetPath(guid); GameObject aniPrefab = AssetDatabase.LoadAssetAtPath <GameObject>(aniPath); if (aniPrefab == null) { Debuger.LogError("不能从{0}获取动作信息", aniPath); continue; } Animation a = aniPrefab.GetComponent <Animation>(); if (a == null) { Debuger.LogError("逻辑异常,获取不到animation2,可能设置有问题"); continue; } foreach (AnimationState st in a) { if (ani[st.name] != null) { continue; } ani.AddClip(st.clip, st.name); } } UnityEditor.EditorUtility.SetDirty(prefab); UnityEditor.AssetDatabase.Refresh(); UnityEditor.AssetDatabase.SaveAssets(); EditorUtility.DisplayDialog("", "完成", "确定"); }
static public void CorrectUILayer() { DirectoryInfo dir = new DirectoryInfo(System.IO.Path.Combine(Application.dataPath, "UI/Resources")); var uiLayer = LayerMask.NameToLayer("UI"); var uiHightLayer = LayerMask.NameToLayer("UIHight"); var extension = ".prefab"; var excluded = new HashSet <string> { "UIResMgr", "UIRoot" }; var errStrs = new List <string>(); foreach (var file in dir.GetFiles()) { if (!file.Extension.Equals(extension, StringComparison.OrdinalIgnoreCase)) { continue; } if (excluded.Contains(System.IO.Path.GetFileNameWithoutExtension(file.Name))) { continue; } GameObject panelGo = AssetDatabase.LoadAssetAtPath <GameObject>(System.IO.Path.Combine("Assets/UI/Resources", file.Name)); var panelLayer = panelGo.layer; var panelLayerStr = LayerMask.LayerToName(panelLayer); if (panelLayer != uiLayer && panelLayer != uiHightLayer) { errStrs.Add(string.Format("发现Panel层不对,名字:{0},层次:{1},由于是Panel,不自动校正,请手动校正后再执行本命令\r\n", panelGo.name, panelLayerStr)); continue; } var changed = false; var childrens = panelGo.GetComponentsInChildren <Transform>(true); foreach (var child in childrens) { var childLayer = child.gameObject.layer; var childLayerStr = LayerMask.LayerToName(childLayer); if (childLayer != panelLayer) { changed = true; child.gameObject.layer = panelLayer; errStrs.Add(string.Format("发现UI子控件不跟Panel同层,Panel名字:{0},控件路径:{1},Panel层次:{2},控件层次:{3},已校正\r\n", panelGo.name, Util.GetGameObjectPath(child.gameObject), panelLayerStr, childLayerStr)); } } if (changed) { UnityEditor.EditorUtility.SetDirty(panelGo); } } UnityEditor.AssetDatabase.Refresh(); UnityEditor.AssetDatabase.SaveAssets(); if (errStrs.Count > 0) { var temp = ""; for (var i = 0; i < errStrs.Count; ++i) { var str = errStrs[i]; temp += str; if ((i + 1) % 30 == 0) { Debuger.Log(temp); temp = ""; } } if (temp.Length > 0) { Debuger.Log(temp); } } else { Debuger.Log("没有检查出问题"); } }
/// <summary> /// 当UI不可用时调用 /// </summary> protected override void OnDisable() { Debuger.Log(); RemoveUIClickListeners(m_btnClose); }
/// <summary> /// 当UI可用时调用 /// </summary> protected override void OnEnable() { Debuger.Log(); AddUIClickListener(m_btnClose, OnBtnClose); }
//其他线程要打印信息的时候 public static void SafeLogError(string format, params object[] args) { Debuger.LogError(string.Format(format, args)); }
public void ExecCreateAssetBunldes() { //取得在 Project 视图中选择的资源(包含子目录中的资源) Object[] SelectedAsset = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets); if (SelectedAsset == null) { EditorUtility.DisplayDialog("AssetBunlde", "Nothing is Selected", "Close"); return; } foreach (Object obj in SelectedAsset) { if (ABTools.MissingMono(obj)) { continue; } #if UNITY_IPHONE string targetPath = ABConfig.OutputFolderIPhone + obj.name + ABConfig.extensionName; #elif UNITY_STANDALONE_WIN string targetPath = ABConfig.OutputFolderWindows32 + obj.name + ABConfig.extensionName; #elif UNITY_ANDROID string targetPath = ABConfig.OutputFolderAndroid + obj.name + ABConfig.extensionName; #else string targetPath = ABConfig.OutputFolderWindows32 + obj.name + ABConfig.extensionName; #endif // UNITY_STANDALONE_WIN if (File.Exists(targetPath)) { File.Delete(targetPath); } #if UNITY_IPHONE //建立 AssetBundle if (BuildPipeline.BuildAssetBundle(obj, null, targetPath, BuildAssetBundleOptions.CollectDependencies, // | BuildAssetBundleOptions.CompleteAssets, BuildTarget.iPhone)) { Debuger.Log(targetPath + "建立完成"); } else { Debuger.LogError(obj.name + "建立失败"); } #elif UNITY_STANDALONE_WIN //建立 AssetBundle if (BuildPipeline.BuildAssetBundle(obj, null, targetPath, BuildAssetBundleOptions.CollectDependencies, // | BuildAssetBundleOptions.CompleteAssets, BuildTarget.StandaloneWindows)) { Debuger.Log(targetPath + "建立完成"); } else { Debuger.LogError(obj.name + "建立失败"); } #elif UNITY_ANDROID //建立 AssetBundle if (BuildPipeline.BuildAssetBundle(obj, null, targetPath, BuildAssetBundleOptions.CollectDependencies, // | BuildAssetBundleOptions.CompleteAssets, BuildTarget.Android)) { Debuger.Log(targetPath + "建立完成"); } else { Debuger.LogError(obj.name + "建立失败"); } #endif // UNITY_STANDALONE_WIN AssetDatabase.Refresh(); } EditorUtility.DisplayDialog("AssetBunlde", "BuildTarget.StandaloneWindows Over", "Close"); }
//==================================================================== //鉴权相关逻辑 public void SetAuth(int authId) { Debuger.Log(authId); //这里暂时不做真正的鉴权,只是让流程完整 m_hasAuthed = m_authId == authId; }
public static void LogWarning(string log) { Debuger.LogWarning(log); }
//==================================================================== public void ClearRound() { Debuger.Log(); m_FrameCache.Clear(); m_LastAddFrameId = 0; }
public void OnCGAnimStop() { Debuger.LogError("OnCGAnimStop"); CurrentState = NONE; }
protected override UIBaseWindow ReadyToShowBaseWindow(WindowID id, ShowWindowData showData = null) { // Check the window control state if (!this.IsWindowInControl(id)) { Debuger.Log("## UIManager has no control power of " + id.ToString()); return(null); } // If the window in shown list just return if (dicShownWindows.ContainsKey((int)id)) { return(null); } UIBaseWindow baseWindow = GetGameWindow(id); // If window not in scene start Instantiate new window to scene bool newAdded = false; if (!baseWindow) { newAdded = true; if (UIResourceDefine.windowPrefabPath.ContainsKey((int)id)) { string prefabPath = UIResourceDefine.UIPrefabPath + UIResourceDefine.windowPrefabPath[(int)id]; GameObject prefab = Resources.Load <GameObject>(prefabPath); if (prefab != null) { GameObject uiObject = (GameObject)GameObject.Instantiate(prefab); NGUITools.SetActive(uiObject, true); // NOTE: You can add component to the window in the inspector // Or just AddComponent<UIxxxxWindow>() to the target baseWindow = uiObject.GetComponent <UIBaseWindow>(); if (baseWindow.ID != id) { Debuger.LogError(string.Format("<color=cyan>[BaseWindowId :{0} != shownWindowId :{1}]</color>", baseWindow.ID, id)); return(null); } // Get the window target root parent Transform targetRoot = GetTargetRoot(baseWindow.windowData.windowType); GameUtility.AddChildToTarget(targetRoot, baseWindow.gameObject.transform); dicAllWindows[(int)id] = baseWindow; } } } if (baseWindow == null) { Debuger.LogError("[window instance is null.]" + id.ToString()); } // Call reset window when first load new window // Or get forceResetWindow param if (newAdded || (showData != null && showData.forceResetWindow)) { baseWindow.ResetWindow(); } if (showData == null || (showData != null && showData.executeNavLogic)) { // refresh the navigation data ExecuteNavigationLogic(baseWindow, showData); } // Adjust the window depth AdjustBaseWindowDepth(baseWindow); // Add common background collider to window AddColliderBgForWindow(baseWindow); return(baseWindow); }
//-------------------------------------------------------------------- #region Player 状态标志工具函数 private void SetFlag(uint playerId, ref int flag, string flagname) { flag |= (0x01 << ((int)playerId - 1)); Debuger.Log(LOG_TAG, "SetFlag() player = {0}, flag = {1}", playerId, flagname); }
public void SetReceiveListener(Action <FSPDataC2S> listener) { Debuger.Log(); m_listener = listener; }
public override void OnCreate() { Debuger.Info(base.GetType().get_Name() + " OnCreate", new object[0]); }
static public void Log(string str, string color) { str = String.Format("<color=#{0}> {1} </color>", color, str); Debuger.Log(str); }
//修改一个子节点 protected virtual bool OnChangeChild(ISerializableObject item) { Debuger.LogError("没有实现"); return(false); }
static public void LogWarning(string str) { Debuger.LogWarning(str); }
//删除一个子节点 protected virtual bool OnRemoveChild(string key) { Debuger.LogError("没有实现"); return(false); }
static public void LogError(string str) { Debuger.LogError(str); }
public void Clean() { Debuger.Log(); m_mapGame.Clear(); }
static public void LogFormat(string str, params object[] args) { Debuger.Log(string.Format(str, args)); }
/// <summary> /// 加载csv为obj实例 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="csvFileName"></param> private static void LoadCsv <T>(string csvFileName) where T : CsvBase { Debuger.Log("Parse file... : " + csvFileName); Type _type = typeof(T); // 创建字典 IDictionary innerDic = null; if (!dic.TryGetValue(_type, out innerDic)) { innerDic = new Dictionary <int, T>(); dic.Add(_type, innerDic); } else { Debuger.Log("csv repeate ! type = " + _type.Name + " csv file = " + csvFileName); return; } FileInfo csvFile = new FileInfo(csvFolder + "\\" + csvFileName); // 读取 List <string> csvList = new List <string>(); using (StreamReader sr = new StreamReader(csvFile.Open(FileMode.Open, FileAccess.Read, FileShare.ReadWrite))) { while (sr.Peek() > 0) { csvList.Add(sr.ReadLine()); } } // 匹配字段顺序 string[] keyList = csvList[2].Split(','); FieldInfo[] fieldInfos = new FieldInfo[keyList.Length]; for (int i = 0; i < fieldInfos.Length; i++) { fieldInfos[i] = _type.GetField(keyList[i]); } // 生成实例 for (int i = 3; i < csvList.Count; i++) { string[] fileValues = csvList[i].Split(','); T obj = Activator.CreateInstance <T>(); obj.ID = int.Parse(fileValues[0]); for (int j = 1; j < fieldInfos.Length; j++) { SetField(fieldInfos[j], obj, fileValues[j]); } if (innerDic.Contains(obj.ID)) { Debuger.Log("配置表ID重复! csv文件:" + csvFileName + " ID : " + obj.ID); } innerDic.Add(obj.ID, obj); } }
void Awake() { debuger = this; }