初始化
This commit is contained in:
15
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Plugins/YIUIBase/Helper/IDHelper.cs
vendored
Normal file
15
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Plugins/YIUIBase/Helper/IDHelper.cs
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
|
||||
namespace YIUIFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// ID 助手 生成唯一ID
|
||||
/// </summary>
|
||||
public static class IDHelper
|
||||
{
|
||||
public static int GetGuid()
|
||||
{
|
||||
return Guid.NewGuid().GetHashCode();
|
||||
}
|
||||
}
|
||||
}
|
||||
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Plugins/YIUIBase/Helper/IDHelper.cs.meta
vendored
Normal file
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Plugins/YIUIBase/Helper/IDHelper.cs.meta
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e3f727fdf4894a82b6d58cbc84ea6cb2
|
||||
timeCreated: 1689078504
|
||||
74
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Plugins/YIUIBase/Helper/UILogger.cs
vendored
Normal file
74
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Plugins/YIUIBase/Helper/UILogger.cs
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
using UnityEngine;
|
||||
using Object = UnityEngine.Object;
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
#endif
|
||||
|
||||
namespace YIUIFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// 日志封装@l
|
||||
/// </summary>
|
||||
public static class Logger
|
||||
{
|
||||
public static void Log(object message)
|
||||
{
|
||||
Debug.Log(message);
|
||||
}
|
||||
|
||||
public static void Log(string format, params object[] args)
|
||||
{
|
||||
Debug.LogFormat(format, args);
|
||||
}
|
||||
|
||||
public static void LogWarning(object message)
|
||||
{
|
||||
Debug.LogWarning(message);
|
||||
}
|
||||
|
||||
public static void LogWarning(string format, params object[] args)
|
||||
{
|
||||
Debug.LogWarningFormat(format, args);
|
||||
}
|
||||
|
||||
public static void LogError(object message)
|
||||
{
|
||||
Debug.LogError(message);
|
||||
}
|
||||
|
||||
public static void LogError(string format, params object[] args)
|
||||
{
|
||||
Debug.LogErrorFormat(format, args);
|
||||
}
|
||||
|
||||
public static void LogErrorContext(Object context, object message)
|
||||
{
|
||||
Debug.LogError(message, context);
|
||||
}
|
||||
|
||||
public static void LogWarningContext(Object context, object message)
|
||||
{
|
||||
Debug.LogWarning(message, context);
|
||||
}
|
||||
|
||||
public static void LogErrorContextFormat(Object context, string format, params object[] args)
|
||||
{
|
||||
Debug.LogErrorFormat(context, format, args);
|
||||
}
|
||||
|
||||
public static void LogError(Object obj, object message)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
SelectObj(obj);
|
||||
#endif
|
||||
Debug.LogError(message);
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
public static void SelectObj(Object obj)
|
||||
{
|
||||
Selection.activeObject = obj;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Plugins/YIUIBase/Helper/UILogger.cs.meta
vendored
Normal file
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Plugins/YIUIBase/Helper/UILogger.cs.meta
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6d48c96345004f669f57a59fc73f8a3b
|
||||
timeCreated: 1679038968
|
||||
127
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Plugins/YIUIBase/Helper/UIOperationHelper.cs
vendored
Normal file
127
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Plugins/YIUIBase/Helper/UIOperationHelper.cs
vendored
Normal file
@@ -0,0 +1,127 @@
|
||||
using UnityEngine;
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
#endif
|
||||
|
||||
namespace YIUIFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// 检查是否可以进行UI操作
|
||||
/// </summary>
|
||||
public static class UIOperationHelper
|
||||
{
|
||||
public static bool IsPlaying()
|
||||
{
|
||||
if (Application.isPlaying)
|
||||
{
|
||||
//编辑时点结束的一瞬间 还是在运行中的 所以要判断是否正在退出
|
||||
//如果正在退出 算非运行
|
||||
if (SingletonMgr.IsQuitting)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
//编辑器时 点开始的一瞬间是不算正在运行的 在我这里算运行中
|
||||
return EditorApplication.isPlayingOrWillChangePlaymode;
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool RunTimeCheckIsPlaying(bool log = true)
|
||||
{
|
||||
if (IsPlaying())
|
||||
{
|
||||
if (log)
|
||||
Debug.LogError($"当前正在运行时 请不要在运行时使用");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
|
||||
//UI通用判断 运行时是否可显示
|
||||
//通过切换宏可以在运行时提供可修改
|
||||
public static bool CommonShowIf()
|
||||
{
|
||||
#if YIUIMACRO_BIND_RUNTIME_EDITOR
|
||||
return true;
|
||||
#endif
|
||||
|
||||
if (IsPlaying())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//运行时不可用
|
||||
public static bool CheckUIOperation(bool log = true)
|
||||
{
|
||||
if (IsPlaying())
|
||||
{
|
||||
if (log)
|
||||
UnityTipsHelper.ShowError($"当前正在运行时 请不要在运行时使用");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool CheckUIOperation(Object obj, bool log = true)
|
||||
{
|
||||
if (IsPlaying())
|
||||
{
|
||||
if (log)
|
||||
UnityTipsHelper.ShowErrorContext(obj, $"当前正在运行时 请不要在运行时使用");
|
||||
return false;
|
||||
}
|
||||
|
||||
var checkInstance = PrefabUtility.IsPartOfPrefabInstance(obj);
|
||||
if (checkInstance)
|
||||
{
|
||||
if (log)
|
||||
UnityTipsHelper.ShowErrorContext(obj, $"不能对实体进行操作 必须进入预制体编辑!!!");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool CheckUIOperationAll(Object obj, bool log = true)
|
||||
{
|
||||
if (IsPlaying())
|
||||
{
|
||||
if (log)
|
||||
UnityTipsHelper.ShowErrorContext(obj, $"当前正在运行时 请不要在运行时使用");
|
||||
return false;
|
||||
}
|
||||
|
||||
var checkInstance = PrefabUtility.IsPartOfPrefabInstance(obj);
|
||||
if (checkInstance)
|
||||
{
|
||||
if (log)
|
||||
UnityTipsHelper.ShowErrorContext(obj, $"不能对实体进行操作 必须进入预制体编辑!!!");
|
||||
return false;
|
||||
}
|
||||
|
||||
var checkAsset = PrefabUtility.IsPartOfPrefabAsset(obj);
|
||||
if (!checkAsset)
|
||||
{
|
||||
if (log)
|
||||
UnityTipsHelper.ShowErrorContext(obj, $"1: 必须是预制体 2: 不能在Hierarchy面板中使用 必须在Project面板下的预制体原件才能使用使用 ");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f4be78be90914636ba403ff49dcd9c36
|
||||
timeCreated: 1682408026
|
||||
138
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Plugins/YIUIBase/Helper/UnityTipsHelper.cs
vendored
Normal file
138
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Plugins/YIUIBase/Helper/UnityTipsHelper.cs
vendored
Normal file
@@ -0,0 +1,138 @@
|
||||
using System;
|
||||
using Object = UnityEngine.Object;
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
#endif
|
||||
|
||||
namespace YIUIFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// Unity提示框@sy
|
||||
/// </summary>
|
||||
public static class UnityTipsHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// 展示提示
|
||||
/// </summary>
|
||||
/// <param name="content"></param>
|
||||
public static void Show(string content)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
EditorUtility.DisplayDialog("提示", content, "确认");
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 提示 同时error 报错
|
||||
/// </summary>
|
||||
public static void ShowError(string message)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
Show(message);
|
||||
Logger.LogError(message);
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 提示 同时error 报错
|
||||
/// </summary>
|
||||
public static void ShowError(object message)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
Show(message.ToString());
|
||||
Logger.LogError(message);
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 提示 同时error 报错
|
||||
/// </summary>
|
||||
public static void ShowErrorContext(Object context, string message)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
Show(message);
|
||||
Logger.LogErrorContext(context, message);
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 提示 同时error 报错
|
||||
/// </summary>
|
||||
public static void ShowErrorContext(Object context, object message)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
Show(message.ToString());
|
||||
Logger.LogErrorContext(context, message);
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 确定 取消 回调的提示框
|
||||
/// </summary>
|
||||
public static void CallBack(string content, Action okCallBack, Action cancelCallBack = null)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
var selectIndex = EditorUtility.DisplayDialogComplex("提示", content, "确认", "取消", null);
|
||||
if (selectIndex == 0) //确定
|
||||
{
|
||||
try
|
||||
{
|
||||
okCallBack?.Invoke();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
cancelCallBack?.Invoke();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 只有确定的提示框
|
||||
/// </summary>
|
||||
public static void CallBackOk(string content, Action okCallBack, Action cancelCallBack = null)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
var result = EditorUtility.DisplayDialog("提示", content, "确认");
|
||||
if (result) //确定
|
||||
{
|
||||
try
|
||||
{
|
||||
okCallBack?.Invoke();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
cancelCallBack?.Invoke();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2c4b46307b99428f931c06158c6bc800
|
||||
timeCreated: 1679022167
|
||||
Reference in New Issue
Block a user