提交 6df0a3bb 编写于 作者: L linxinfa

更新tolua iOS库

......@@ -3,4 +3,4 @@ Logs
Temp
Bin
Assets/StreamingAssets/res
Assets/output_log.txt
\ No newline at end of file
gamelog
\ No newline at end of file
此差异已折叠。
此差异已折叠。
......@@ -89,21 +89,27 @@ public class PrefabBinderEditor : EditorWindow
void OnGUI()
{
BeginBox(new Rect(0, 0, 3 * Screen.width / 7f, Screen.height));
float offset = 0;
float width = 3 * Screen.width / 10f;
BeginBox(new Rect(offset, 0, width, Screen.height));
DrawSearchBtn();
DrawSearchItemList();
EndBox();
offset += width;
BeginBox(new Rect(3 * Screen.width / 7f + 2, 0, 2 * Screen.width / 7f, Screen.height));
width = 2 * Screen.width / 10f;
BeginBox(new Rect(offset, 0, width, Screen.height));
DrawLockBtn();
GUILayout.Space(2);
DrawComponentList();
EndBox();
offset += width;
BeginBox(new Rect(5 * Screen.width / 7f + 4, 0, 2 * Screen.width / 7f - 4, Screen.height));
width = 3 * Screen.width / 10f;
BeginBox(new Rect(offset, 0, width, Screen.height));
DrawPrefabBinderField();
GUILayout.Space(2);
DrawItemField();
DrawItemField(width);
EndBox();
}
......@@ -178,17 +184,17 @@ public class PrefabBinderEditor : EditorWindow
EditorGUILayout.EndScrollView();
}
private void DrawItemField()
private void DrawItemField(float width)
{
EditorGUILayout.BeginVertical();
GUILayout.Label(string.IsNullOrEmpty(m_componentStr) ? "null" : m_componentStr);
m_itemName = EditorGUILayout.TextField(m_itemName);
if (GUILayout.Button(new GUIContent("Add Item", "添加item"), GUILayout.Height(80)))
if (GUILayout.Button("Add Item", GUILayout.Width(width), GUILayout.Height(80)))
{
ComponentOperation(m_slot, ItemOption.AddItem);
}
if (GUILayout.Button(new GUIContent("Delete Item", "删除指定的item")))
if (GUILayout.Button("Delete Item", GUILayout.Width(width)))
{
if (m_prefabBinderObj != null)
{
......@@ -198,7 +204,7 @@ public class PrefabBinderEditor : EditorWindow
ComponentOperation(m_slot, ItemOption.RemoveItem);
}
}
if (GUILayout.Button(new GUIContent("Refresh", "刷新")))
if (GUILayout.Button("Refresh", GUILayout.Width(width)))
{
OnRefreshBtnClicked();
}
......
......@@ -31,7 +31,7 @@ public class ResConfigEditor : EditorWindow
static void Init()
{
ResConfigEditor window = (ResConfigEditor)EditorWindow.GetWindow(typeof(ResConfigEditor));
window.minSize = new Vector2(500f, 600f);
//window.minSize = new Vector2(500f, 600f);
window.Show();
s_manager = new ResConfigManager();
}
......
<?xml version="1.0" encoding="utf-8"?>
<items>
<item id="1" editorPath="BaseRes/HotUpdatePanel.prefab" version="2021/10/15" desc="热更新界面" />
<item id="2" editorPath="3D/Cube.prefab" version="2021/10/15" desc="3D正方体,测试用" />
<item id="3" editorPath="UIPrefabs/Login/LoginPanel.prefab" version="2021/10/15" desc="登录界面" />
<item id="4" editorPath="Effects/Particle System.prefab" version="2021/10/15" desc="粒子,测试用" />
<item id="5" editorPath="Atlas/CommonUI.spriteatlas" version="2021/10/15" desc="图集" />
<item id="6" editorPath="Audios/bg.wav" version="2021/10/15" desc="背景音乐" />
<item id="8" editorPath="BaseRes/TestPanel.prefab" version="2021/10/15" desc="测试界面" />
<item id="9" editorPath="UIPrefabs/Common/FlyTips.prefab" version="2021/11/4" desc="冒提示语" />
<item id="10" editorPath="UIPrefabs/GameHall/GameHallPanel.prefab" version="2021/11/4" desc="大厅界面" />
<item id="11" editorPath="UIPrefabs/Common/GuideMask.prefab" version="2021/11/5" desc="新手引导遮罩" />
<item id="12" editorPath="UIPrefabs/Common/TipsDlg.prefab" version="2021/11/5" desc="提示框" />
<item id="13" editorPath="UIPrefabs/Common/WaitBoard.prefab" version="2021/11/5" desc="请稍等挡板" />
<item id="14" editorPath="UIPrefabs/Backpack/BackpackPanel.prefab" version="2021/11/6" desc="背包界面" />
<item id="1" editorPath="BaseRes/HotUpdatePanel.prefab" version="2021/11/10" desc="热更新界面" />
<item id="2" editorPath="3D/Cube.prefab" version="2021/11/10" desc="3D正方体,测试用" />
<item id="3" editorPath="UIPrefabs/Login/LoginPanel.prefab" version="2021/11/10" desc="登录界面" />
<item id="4" editorPath="Effects/Particle System.prefab" version="2021/11/10" desc="粒子,测试用" />
<item id="5" editorPath="Atlas/CommonUI.spriteatlas" version="2021/11/10" desc="图集" />
<item id="6" editorPath="Audios/bg.wav" version="2021/11/10" desc="背景音乐" />
<item id="8" editorPath="BaseRes/TestPanel.prefab" version="2021/11/10" desc="测试界面" />
<item id="9" editorPath="UIPrefabs/Common/FlyTips.prefab" version="2021/11/10" desc="冒提示语" />
<item id="10" editorPath="UIPrefabs/GameHall/GameHallPanel.prefab" version="2021/11/10" desc="大厅界面" />
<item id="11" editorPath="UIPrefabs/Common/GuideMask.prefab" version="2021/11/10" desc="新手引导遮罩" />
<item id="12" editorPath="UIPrefabs/Common/TipsDlg.prefab" version="2021/11/10" desc="提示框" />
<item id="13" editorPath="UIPrefabs/Common/WaitBoard.prefab" version="2021/11/10" desc="请稍等挡板" />
<item id="14" editorPath="UIPrefabs/Backpack/BackpackPanel.prefab" version="2021/11/10" desc="背包界面" />
</items>
\ No newline at end of file
fileFormatVersion: 2
guid: 95f00163ba722334cb5544b9c44e18d2
folderAsset: yes
timeCreated: 1476450638
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
--region *.lua
--Date
--此文件由[BabeLua]插件自动生成
--纯lua的事件处理器
--TODO:
--纯lua的事件处理 与 调用Unity里面封装的EventDispatcher效率相差多少? 有待测试
--如果只需要在lua里面用 纯lua 的效率肯定是高
LuaEventDispatcher = LuaEventDispatcher or {}
--key:事件名称,value:事件处理方法表handles
LuaEventDispatcher.listeners = {}
local listeners = LuaEventDispatcher.listeners
--注册事件处理
function LuaEventDispatcher.RegistEvent(eventName, handle)
local handles = listeners[eventName]
if handles == nil then
handles = {}
listeners[eventName] = handles
end
table.insert(handles, handle)
end
--注销事件处理
function LuaEventDispatcher.UnRegistEvent(eventName, handle)
local handles = listeners[eventName]
if handles ~= nil then
for k, v in pairs(handles) do
if v == handle then
handles[k] = nil
return k
end
end
end
end
--触发事件
function LuaEventDispatcher.FireEvent(eventName, ...)
local handles = listeners[eventName]
if handles ~= nil then
for k, v in pairs(handles) do
v(...)
end
end
end
--endregion
fileFormatVersion: 2
guid: bd4ae9b5d48ae6f4989614ec2dc811f3
timeCreated: 1476450638
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
Utility/LuaUtil.lua
Common/LuaUtil.lua
Common/define.lua
Common/functions.lua
Common/protocal.lua
Common/const.lua
Common/UITool.lua
Common/EventNameDef.lua
-- 入口脚本
Logic/Main.lua
......
fileFormatVersion: 2
guid: 22a026ab84777d94bbf98b62277fabf8
folderAsset: yes
timeCreated: 1476447806
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
......@@ -79,8 +79,6 @@ function LoginPanel:SetUi(binder)
LanguageMgr:ChangeLanguageType(v)
end)
language.value = LanguageMgr.languageIndex
end
function LoginPanel:OnHide()
......
......@@ -69,7 +69,7 @@ Material:
- _Mode: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _Silder: 83.82081
- _Silder: 85.56396
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
......@@ -82,7 +82,7 @@ Material:
- _UseUIAlphaClip: 0
- _ZWrite: 1
m_Colors:
- _Center: {r: 508.19995, g: 277.80994, b: 0, a: 0}
- _Center: {r: 0, g: -221.89998, b: 0, a: 0}
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
m_BuildTextureStacks: []
......@@ -21,6 +21,10 @@ public class AudioMgr
UpdateMusicVolume(m_musicVolumeFactor);
}
/// <summary>
/// 播放音效
/// </summary>
/// <param name="audioName">声音名字,需要带后缀</param>
public void PlaySound(string audioName)
{
var clip = m_cache.GetAudioClip(audioName);
......@@ -28,6 +32,12 @@ public class AudioMgr
m_channalMgr.PlaySound(clip);
}
/// <summary>
/// 播放音效
/// </summary>
/// <param name="audioName">声音名字,需要带后缀</param>
/// <param name="loop">是否循环</param>
/// <param name="fadeIn">是否渐入</param>
public void PlaySoundEx(string audioName, bool loop, bool fadeIn)
{
var clip = m_cache.GetAudioClip(audioName);
......@@ -35,6 +45,13 @@ public class AudioMgr
m_channalMgr.PlaySound(clip, loop, fadeIn);
}
/// <summary>
/// 播放音乐,比如背景音乐
/// </summary>
/// <param name="audioName">声音名字,需要带后缀</param>
/// <param name="loop">是否循环</param>
/// <param name="fadeIn">是否渐入</param>
/// <param name="pauseOther">是否停止其他背景音乐</param>
public void PlayMusic(string audioName, bool loop, bool fadeIn, bool pauseOther)
{
var cfgItem = m_cfg.GetAudioCfg(audioName);
......@@ -73,6 +90,10 @@ public class AudioMgr
return m_cfg.GetAudioCfg(audioName);
}
/// <summary>
/// 调节音效音量
/// </summary>
/// <param name="factor">0到1</param>
public void UpdateSoundVolume(float factor)
{
m_soundVolumeFactor = factor;
......@@ -81,6 +102,10 @@ public class AudioMgr
}
/// <summary>
/// 调节音乐音量
/// </summary>
/// <param name="factor">0到1</param>
public void UpdateMusicVolume(float factor)
{
m_musicVolumeFactor = factor;
......
......@@ -22,10 +22,10 @@ public class LogCat : MonoBehaviour
void Update()
{
#if UNITY_EDITOR
#if UNITY_EDITOR || UNITY_STANDALONE
if (Input.GetKeyDown(KeyCode.F4))
#else
if (Input.GetMouseButtonDown(0) && Input.touchCount >= 3)
if (Input.GetMouseButtonDown(0) && Input.touchCount == 4)
#endif
{
m_showLog = !m_showLog;
......
using System.IO;
using UnityEngine;
using System.Text;
/// <summary>
/// 日志输出
/// </summary>
public class Logger
{
public void Init()
{
m_needUpload = false;
#if UNITY_ANDROID || UNITY_IOS
//var fullSavePath = "mnt/sdcard/output_log.txt";
var fullSavePath = string.Format("{0}/{1}", Application.persistentDataPath, "output_log.txt");
#elif UNITY_STANDALONE_WIN
var fullSavePath = string.Format("{0}/{1}", Application.dataPath, "output_log.txt");
#endif
InitLogger(fullSavePath);
}
void InitLogger(string fullSavePath)
{
m_fullSavePath = fullSavePath;
if (File.Exists(fullSavePath))
{
FileInfo file = new FileInfo(fullSavePath);
if (file.Length > MaxFileSize_1)
{
File.Delete(fullSavePath);
}
}
if (!Directory.Exists(fullSavePath.Replace("/output_log.txt", "")))
{
fullSavePath = string.Format("{0}/{1}", Application.persistentDataPath, "output_log.txt");
if (File.Exists(fullSavePath))
{
FileInfo file = new FileInfo(fullSavePath);
if (file.Length > MaxFileSize)
{
File.Delete(m_fullSavePath);
}
}
}
if (Directory.Exists(fullSavePath.Replace("/output_log.txt", "")))
{
try
{
if (!File.Exists(fullSavePath))
{
FileStream fs = File.Create(fullSavePath);
fs.Close();
}
Application.logMessageReceivedThreaded += logCallBack;
GameLogger.Log("Logger Start");
}
catch (System.Exception ex)
{
GameLogger.Log("error can not open." + ex.StackTrace.ToString() + ex.Message);
}
}
else
{
GameLogger.Log("error not found the log output path.");
}
}
public void Flush()
{
if (m_logBuilder.Length > 0)
{
if (enable && File.Exists(m_fullSavePath))
{
using (StreamWriter sw = File.AppendText(m_fullSavePath))
{
sw.WriteLine(m_logBuilder.ToString());
m_logBuilder.Remove(0, m_logBuilder.Length);
}
}
}
}
private void logCallBack(string condition, string stackTrace, LogType type)
{
lock (m_locker)
{
if ((type == LogType.Error || type == LogType.Exception))
{
m_needUpload = true;
}
string log = string.Format("{0} {1}\n", System.DateTime.Now.ToString("MM-dd HH:mm:ss"), condition);
m_logBuilder.Append(log);
m_logBuilder.Append(stackTrace);
m_logBuilder.Append("\n");
Flush();
}
}
/// <summary>
///复制一份log,用来查找bug
/// </summary>
public void CopyOutPutLog()
{
try
{
//Debug.LogError("CopyOutPutLog");
if (File.Exists(m_fullSavePath))
{
string file = File.ReadAllText(m_fullSavePath);
if (file.Length > 0)
{
string copyFile = m_fullSavePath;//m_fullSavePath.Replace("/output_log.txt", "")
copyFile = copyFile.Replace("/output_log.txt", "/output_log_1.txt");
if (File.Exists(copyFile))
{
FileInfo targetFile = new FileInfo(copyFile);
if (targetFile.Length > MaxFileSize_1)
{
File.Delete(copyFile);
}
}
File.AppendAllText(copyFile, file);
}
}
}
catch (System.Exception e)
{
GameLogger.LogError(e);
}
}
private Logger()
{
m_logBuilder = new StringBuilder();
m_needUpload = false;
enable = true;
m_locker = new System.Object();
}
public static Logger instance
{
get
{
if (s_instance == null) s_instance = new Logger();
return s_instance;
}
}
public bool needUpload
{
get { return m_needUpload; }
}
public bool enable;
private bool m_needUpload;
private string m_fullSavePath = string.Empty;
private StringBuilder m_logBuilder;
private System.Object m_locker;
private static Logger s_instance;
private const long MaxFileSize = 0;
private const long MaxFileSize_1 = 5 * 1024 * 1024;
}
fileFormatVersion: 2
guid: 4f56ae0b96d16f04ea1c8502c64e197e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
......@@ -10,39 +10,54 @@ public delegate void MyEventHandler(params object[] objs);
public class EventDispatcher
{
public void Regist(string type, MyEventHandler handler)
/// <summary>
/// 注册事件
/// </summary>
/// <param name="evt">事件名</param>
/// <param name="handler">响应函数</param>
public void Regist(string evt, MyEventHandler handler)
{
if (handler == null)
return;
if (listeners.ContainsKey(type))
if (listeners.ContainsKey(evt))
{
//这里涉及到Dispath过程中反注册问题,必须使用listeners[type]+=..
listeners[type] += handler;
listeners[evt] += handler;
}
else
{
listeners.Add(type, handler);
listeners.Add(evt, handler);
}
}
public void UnRegist(string type, MyEventHandler handler)
/// <summary>
/// 注销事件
/// </summary>
/// <param name="evt">事件名</param>
/// <param name="handler">响应函数</param>
public void UnRegist(string evt, MyEventHandler handler)
{
if (handler == null)
return;
if (listeners.ContainsKey(type))
if (listeners.ContainsKey(evt))
{
//这里涉及到Dispath过程中反注册问题,必须使用listeners[type]-=..
listeners[type] -= handler;
if (listeners[type] == null)
listeners[evt] -= handler;
if (listeners[evt] == null)
{
//已经没有监听者了,移除.
listeners.Remove(type);
listeners.Remove(evt);
}
}
}
/// <summary>
/// 抛出事件
/// </summary>
/// <param name="evt">事件名</param>
/// <param name="objs">参数</param>
public void DispatchEvent(string evt, params object[] objs)
{
try
......
......@@ -2,7 +2,7 @@
public class EventNameDef
{
/// <summary>
/// 语言切换
/// 语言切换事件
/// </summary>
public const string LANGUAGE_TYPE_CHANGED = "LANGUAGE_TYPE_CHANGED";
}
......@@ -15,7 +15,7 @@ public class LanguageMgr
/// <summary>
/// 切换语言
/// </summary>
/// <param name="index"></param>
/// <param name="index">语言索引,参见LanguageType枚举</param>
public void ChangeLanguageType(int index)
{
language = (LanguageType)index;
......
......@@ -4,7 +4,7 @@ using LuaInterface;
/// <summary>
/// Panel基础脚本
/// </summary>
public class BasePanel : MonoBehaviour
public class BasePanel : MonoBehaviour
{
/// <summary>
/// Lua写的Panel脚本由BasePanel来调度,通过luaObj来绑定调度的方法
......
......@@ -22,6 +22,13 @@ public class PanelMgr
return panel;
}
/// <summary>
/// 显示界面(供lua层调用)
/// </summary>
/// <param name="panelId">界面ID</param>
/// <param name="luaObj">lua界面脚本对象,是一个lua table</param>
/// <param name="parent">父节点</param>
/// <returns></returns>
public BasePanel ShowPanel(int panelId, LuaInterface.LuaTable luaObj, Transform parent)
{
var panel = GetPanelById(panelId);
......@@ -42,7 +49,13 @@ public class PanelMgr
return panel;
}
/// <summary>
/// 显示界面(供C#层调用)
/// </summary>
/// <param name="panelId">界面ID</param>
/// <param name="parent">父节点</param>
/// <typeparam name="T">界面类</typeparam>
/// <returns></returns>
public T ShowPanel<T>(int panelId, Transform parent) where T : BasePanel
{
var panel = GetPanelById(panelId);
......@@ -62,6 +75,10 @@ public class PanelMgr
return (T)panel;
}
/// <summary>
/// 关闭界面
/// </summary>
/// <param name="panelId">界面ID</param>
public void HidePanel(int panelId)
{
var panel = GetPanelById(panelId);
......
......@@ -5,6 +5,13 @@
/// </summary>
public class ParticleManager
{
/// <summary>
/// 播放粒子特效
/// </summary>
/// <param name="resId">资源ID</param>
/// <param name="duration">持续事件</param>
/// <param name="cache">是否缓存到对象池中</param>
/// <returns></returns>
public GameObject PlayParticle(int resId, float duration, bool cache)
{
// 取缓存
......
......@@ -26,6 +26,11 @@ public class SpriteManager
return atlas.GetSprite(spriteName);
}
/// <summary>
/// 给Image设置精灵图
/// </summary>
/// <param name="image">Image对象</param>
/// <param name="spriteName">精灵图名称</param>
public void SetSprite(Image image, string spriteName)
{
image.sprite = GetSprite(spriteName);
......
......@@ -16,12 +16,16 @@ public class GuideMaskBhv : MonoBehaviour
Vector3[] corners = new Vector3[4];
float yVelocity = 0f;
/// <summary>
/// 执行引导
/// </summary>
/// <param name="target">模板对象</param>
public void DoGuide(GameObject target)
{
if(null != target)
this.target = target;
// 设置事件透传对象
gameObject.GetComponent<EventPermeate>().target = this.target.gameObject;
gameObject.GetComponent<EventPermeate>().target = this.target;
var canvas = GlobalObjs.s_canvas;
target.GetComponent<RectTransform>().GetWorldCorners(corners);
......
......@@ -11,7 +11,7 @@ public class StartUp : MonoBehaviour
// 热更新之前初始化一些模块
InitBeforeHotUpdate();
// 热更新
HotUpdatePanel.Create(() =>
HotUpdatePanel.Show(() =>
{
// 热更新后初始化一些模块
InitAfterHotUpdate();
......@@ -47,7 +47,7 @@ public class StartUp : MonoBehaviour
Application.runInBackground = true;
// 日志
Logger.instance.Init();
GameLogger.Init();
LogCat.Init();
// 网络消息注册
m_networkMsgEventRegister.RegistNetworkMsgEvent();
......
......@@ -57,7 +57,7 @@ public class HotUpdatePanel : BasePanel
/// </summary>
private Action m_cb;
public static void Create(Action cb)
public static void Show(Action cb)
{
#if ENABLE_HOT_UPDATE
var panel = PanelMgr.instance.ShowPanel<HotUpdatePanel>(1, GlobalObjs.s_topPanel);
......@@ -201,7 +201,7 @@ public class HotUpdatePanel : BasePanel
private void Finish()
{
Destroy(gameObject);
PanelMgr.instance.HidePanel(1);
m_cb?.Invoke();
}
......
{
"dependencies": {
"com.unity.2d.sprite": "1.0.0",
"com.unity.collab-proxy": "1.5.7",
"com.unity.ide.rider": "3.0.6",
"com.unity.ide.visualstudio": "2.0.8",
......
{
"dependencies": {
"com.unity.2d.sprite": {
"version": "1.0.0",
"depth": 0,
"source": "builtin",
"dependencies": {}
},
"com.unity.collab-proxy": {
"version": "1.5.7",
"depth": 0,
......
m_EditorVersion: 2021.1.9f1c1
m_EditorVersionWithRevision: 2021.1.9f1c1 (a9c352b271d7)
m_EditorVersion: 2021.1.7f1c1
m_EditorVersionWithRevision: 2021.1.7f1c1 (4e944ebb9621)
......@@ -6,4 +6,4 @@
配套的服务端使用skynet框架
### 使用说明
待写
参见我的这边博客:https://linxinfa.blog.csdn.net/article/details/121244430
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册