框架上传

This commit is contained in:
2025-03-31 11:16:52 +08:00
parent 7197b4c0d0
commit ffcdddbd2a
429 changed files with 19115 additions and 1579 deletions
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 218dd6b6c808431fbd852e29526cd2ae
timeCreated: 1624936510
@@ -0,0 +1,389 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Stary.Evo
{
/// <summary>
/// 架构
/// </summary>
/// <typeparam name="T"></typeparam>
public abstract class Architecture<T> : IArchitecture where T : Architecture<T>, new()
{
/// <summary>
/// 是否已经初始化完成
/// </summary>
private bool mInited = false;
/// <summary>
/// 用于初始化的 Datas 的缓存
/// </summary>
private List<IData> mDatas = new List<IData>();
/// <summary>
/// 用于初始化的 Systems 的缓存
/// </summary>
private List<ISystem> mSystems = new List<ISystem>();
/// <summary>
/// IOC
/// </summary>
private IOCContainer mContainer = new IOCContainer();
// 留给子类注册模块
protected abstract void Init();
#region 访
private static T mArchitecture = null;
public static IArchitecture Interface
{
get
{
if (mArchitecture == null)
{
MakeSureArchitecture();
}
return mArchitecture;
}
}
/// <summary>
/// 增加注册
/// </summary>
public static Action<T> OnRegisterPatch = architecture => { Debug.Log("调用了"); };
// 确保 Container 是有实例的
static void MakeSureArchitecture()
{
Debug.Log((mArchitecture == null) + "----mArchitecture是否为空");
if (mArchitecture == null)
{
mArchitecture = new T();
mArchitecture.Init();
mArchitecture.IOCInitClass();
// 调用
OnRegisterPatch?.Invoke(mArchitecture);
// 初始化 Data
for (int i = 0; i < mArchitecture.mDatas.Count; i++)
{
mArchitecture.mDatas[i].Init();
}
// 清空 Data
mArchitecture.mDatas.Clear();
// 初始化 System
for (int i = 0; i < mArchitecture.mSystems.Count; i++)
{
mArchitecture.mSystems[i].Init();
}
// 清空 System
mArchitecture.mSystems.Clear();
mArchitecture.mInited = true;
}
}
// // 提供一个释放模块的 API
public static void Dispose()
{
for (int i = 0; i < mArchitecture.mSystems.Count; i++)
{
mArchitecture.mSystems[i].Dispose();
}
for (int i = 0; i < mArchitecture.mDatas.Count; i++)
{
mArchitecture.mDatas[i].Dispose();
}
mArchitecture = null;
}
#endregion
#region
// 提供一个注册 System 的 API
public void RegisterSystem<TSystem>(TSystem system) where TSystem : ISystem
{
// 需要给 System 赋值一下
system.SetArchitecture(this);
mContainer.Register<TSystem>(system);
// 如果初始化过了
if (mInited)
{
system.Init();
}
else
{
// 添加到 System 缓存中,用于初始化
mSystems.Add(system);
}
}
// 提供一个注册 Data 的 API
public void RegisterData<TData>(TData data) where TData : IData
{
// 需要给 Data 赋值一下
data.SetArchitecture(this);
mContainer.Register<TData>(data);
// 如果初始化过了
if (mInited)
{
data.Init();
}
else
{
// 添加到 Data 缓存中,用于初始化
mDatas.Add(data);
}
}
// 提供一个注册工具模块的 API
public void RegisterUtility<TUtility>(TUtility utility) where TUtility : IUtility
{
mContainer.Register<TUtility>(utility);
}
// 提供一个获取 Data 的 API
public TData GetData<TData>() where TData : class, IData
{
return mContainer.Get<TData>();
}
#endregion
#region IOC容器注册
//IOC初始化注册
private void IOCInitClass()
{
}
// // 提供一个注册模块的 API
public static void RegisterIOC<TArchitecture>(TArchitecture instance)
{
mArchitecture = null;
MakeSureArchitecture();
mArchitecture.mContainer.Register<TArchitecture>(instance);
}
// 提供一个获取模块的 API
public static TArchitecture GetIOC<TArchitecture>() where TArchitecture : class
{
MakeSureArchitecture();
return mArchitecture.mContainer.Get<TArchitecture>();
}
// 提供一个获取模块的 API
public static void UnRegisterIOC<TArchitecture>() where TArchitecture : class
{
mArchitecture.mContainer.UnRegister<TArchitecture>();
}
#endregion
// 提供一个获取工具模块的 API
public TUtility GetUtility<TUtility>() where TUtility : class, IUtility
{
return mContainer.Get<TUtility>();
}
// 提供一个获取系统的 API
public TSystem GetSystem<TSystem>() where TSystem : class, ISystem
{
return mContainer.Get<TSystem>();
}
// 提供一个传递Command的 API(不经过对象池)
public void SendCommand<TCommand>() where TCommand : ICommand, new()
{
var command = new TCommand();
ExecuteCommand(command);
}
// 提供一个传递Command的 API
public void SendCommand<TCommand>(TCommand command) where TCommand : ICommand
{
ExecuteCommand(command);
}
protected virtual void ExecuteCommand(ICommand command)
{
command.SetArchitecture(this);
command.Execute();
}
private EnumEventSystem _mEnumEventSystem = new EnumEventSystem();
/// <summary>
/// 事件发送
/// </summary>
/// <typeparam name="T"></typeparam>
public void SendEvent<TEvent>(TEvent key) where TEvent : IConvertible
{
_mEnumEventSystem.Send<TEvent>(key);
}
/// <summary>
/// 事件发送
/// </summary>
/// <typeparam name="T"></typeparam>
public void SendEvent<TEvent, Tvalue1>(TEvent key, Tvalue1 value) where TEvent : IConvertible
{
_mEnumEventSystem.Send(key, value);
}
/// <summary>
/// 事件发送
/// </summary>
/// <typeparam name="T"></typeparam>
public void SendEvent<TEvent, Tvalue1, Tvalue2>(TEvent key, Tvalue1 value1, Tvalue2 value2)
where TEvent : IConvertible
{
_mEnumEventSystem.Send(key, value1, value2);
}
/// <summary>
/// 事件发送
/// </summary>
/// <typeparam name="T"></typeparam>
public void SendEvent<TEvent, Tvlue1, Tvlue2, Tvlue3>(TEvent key, Tvlue1 value1, Tvlue2 vlue2, Tvlue3 vlue3)
where TEvent : IConvertible
{
_mEnumEventSystem.Send(key, value1, vlue2, vlue3);
}
/// <summary>
/// 事件发送
/// </summary>
/// <typeparam name="T"></typeparam>
public void SendEvent<TEvent>(TEvent key, object[] values) where TEvent : IConvertible
{
_mEnumEventSystem.Send(key, values);
}
/// <summary>
/// 事件监听
/// </summary>
/// <param name="onEvent"></param>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
public IUnRegister RegisterEvent<TEvent>(TEvent key, Action onEvent) where TEvent : IConvertible
{
return _mEnumEventSystem.Register(key, onEvent);
}
/// <summary>
/// 事件监听
/// </summary>
/// <param name="onEvent"></param>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
public IUnRegister RegisterEvent<TEvent, Tvalue1>(TEvent key, Action<Tvalue1> onEvent)
where TEvent : IConvertible
{
return _mEnumEventSystem.Register(key, onEvent);
}
/// <summary>
/// 事件监听
/// </summary>
/// <param name="onEvent"></param>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
public IUnRegister RegisterEvent<TEvent, Tvalue1, Tvalue2>(TEvent key, Action<Tvalue1, Tvalue2> onEvent)
where TEvent : IConvertible
{
return _mEnumEventSystem.Register(key, onEvent);
}
/// <summary>
/// 事件监听
/// </summary>
/// <param name="onEvent"></param>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
public IUnRegister RegisterEvent<TEvent, Tvlue1, Tvlue2, Tvlue3>(TEvent key,
Action<Tvlue1, Tvlue2, Tvlue3> onEvent) where TEvent : IConvertible
{
return _mEnumEventSystem.Register(key, onEvent);
}
/// <summary>
/// 事件监听
/// </summary>
/// <param name="onEvent"></param>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
public IUnRegister RegisterEvent<TEvent>(TEvent key, Action<object[]> onEvent) where TEvent : IConvertible
{
return _mEnumEventSystem.Register(key, onEvent);
}
/// <summary>
/// 事件销毁
/// </summary>
/// <param name="onEvent"></param>
/// <typeparam name="T"></typeparam>
public void UnRegisterEvent<TEvent>(TEvent key, Action onEvent)where TEvent : IConvertible
{
_mEnumEventSystem.UnRegister(key,onEvent);
}
/// <summary>
/// 事件销毁
/// </summary>
/// <param name="onEvent"></param>
/// <typeparam name="T"></typeparam>
public void UnRegisterEvent<TEvent, Tvalue1>(TEvent key, Action< Tvalue1> onEvent)where TEvent : IConvertible
{
_mEnumEventSystem.UnRegister(key,onEvent);
}
/// <summary>
/// 事件销毁
/// </summary>
/// <param name="onEvent"></param>
/// <typeparam name="T"></typeparam>
public void UnRegisterEvent<TEvent, Tvalue1, Tvalue2>(TEvent key, Action<Tvalue1, Tvalue2> onEvent)where TEvent : IConvertible
{
_mEnumEventSystem.UnRegister(key,onEvent);
}
/// <summary>
/// 事件销毁
/// </summary>
/// <param name="onEvent"></param>
/// <typeparam name="T"></typeparam>
public void UnRegisterEvent<TEvent, Tvlue1, Tvlue2, Tvlue3>(TEvent key, Action<Tvlue1, Tvlue2, Tvlue3> onEvent)where TEvent : IConvertible
{
_mEnumEventSystem.UnRegister(key,onEvent);
}
/// <summary>
/// 事件销毁
/// </summary>
/// <param name="onEvent"></param>
/// <typeparam name="T"></typeparam>
public void UnRegisterEvent<TEvent>(TEvent key, Action<object[]> onEvent)where TEvent : IConvertible
{
_mEnumEventSystem.UnRegister(key,onEvent);
}
public TResult SendQuery<TResult>(IQuery<TResult> query)
{
return DoQuery<TResult>(query);
}
protected virtual TResult DoQuery<TResult>(IQuery<TResult> query)
{
query.SetArchitecture(this);
return query.Do();
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 0fb98abbb7c823c4bafea1f9b125736d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 75d4c33e7e46b5c478f8e068ed9be6c6
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,22 @@
/****************************************************************************
* Copyright (c) 2015 - 2022 liangxiegame UNDER MIT License
*
* http://qframework.cn
* https://github.com/liangxiegame/QFramework
* https://gitee.com/liangxiegame/QFramework
****************************************************************************/
using System;
namespace Stary.Evo
{
public class APIDescriptionCNAttribute : Attribute
{
public string Description { get; private set; }
public APIDescriptionCNAttribute(string description)
{
Description = description;
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 2c5538bb5e55498ba063f98c0c7a8800
timeCreated: 1647422088
@@ -0,0 +1,23 @@
/****************************************************************************
* Copyright (c) 2015 - 2022 liangxiegame UNDER MIT License
*
* http://qframework.cn
* https://github.com/liangxiegame/QFramework
* https://gitee.com/liangxiegame/QFramework
****************************************************************************/
using System;
namespace Stary.Evo
{
public class APIDescriptionENAttribute : Attribute
{
public string Description { get; private set; }
public APIDescriptionENAttribute(string description)
{
Description = description;
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 570b6aa696204dbc949fea41caf8fcae
timeCreated: 1647422110
@@ -0,0 +1,22 @@
/****************************************************************************
* Copyright (c) 2015 - 2022 liangxiegame UNDER MIT License
*
* http://qframework.cn
* https://github.com/liangxiegame/QFramework
* https://gitee.com/liangxiegame/QFramework
****************************************************************************/
using System;
namespace Stary.Evo
{
public class APIExampleCodeAttribute : Attribute
{
public string Code { get; private set; }
public APIExampleCodeAttribute(string code)
{
Code = code;
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: b48b349a950f405095cf304b9bde0338
timeCreated: 1647424574
@@ -0,0 +1,24 @@
using System;
namespace Stary.Evo
{
[AttributeUsage(AttributeTargets.Class)]
public class ClassAPIAttribute : Attribute
{
public string DisplayMenuName { get; private set; }
public string GroupName { get; private set; }
public int RenderOrder { get;private set; }
public string DisplayClassName { get; private set; }
public ClassAPIAttribute(string groupName, string displayMenuName,int renderOrder,string displayClassName = null)
{
GroupName = groupName;
DisplayMenuName = displayMenuName;
RenderOrder = renderOrder;
DisplayClassName = displayClassName;
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 72248ec1038f4ce58ad2861e9b02aa52
timeCreated: 1647404455
@@ -0,0 +1,18 @@
/****************************************************************************
* Copyright (c) 2015 - 2022 liangxiegame UNDER MIT License
*
* http://qframework.cn
* https://github.com/liangxiegame/QFramework
* https://gitee.com/liangxiegame/QFramework
****************************************************************************/
using System;
namespace Stary.Evo
{
[AttributeUsage(AttributeTargets.Method)]
public class MethodAPIAttribute : Attribute
{
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 5db430b6c4ac4de5a9836454125e0669
timeCreated: 1647428627
@@ -0,0 +1,18 @@
/****************************************************************************
* Copyright (c) 2015 - 2022 liangxiegame UNDER MIT License
*
* http://qframework.cn
* https://github.com/liangxiegame/QFramework
* https://gitee.com/liangxiegame/QFramework
****************************************************************************/
using System;
namespace Stary.Evo
{
[AttributeUsage(AttributeTargets.Property)]
public class PropertyAPIAttribute : Attribute
{
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: ab3c662f56b4401eaad6594ef6182e75
timeCreated: 1647515468
@@ -0,0 +1,173 @@
using System;
namespace Stary.Evo
{
public interface IArchitecture
{
/// <summary>
/// 注册 System
/// </summary>
void RegisterSystem<T>(T instance) where T : ISystem;
/// <summary>
/// 获取 System
/// </summary>
T GetSystem<T>() where T : class, ISystem;
/// <summary>
/// 注册 Data
/// </summary>
void RegisterData<T>(T instance) where T : IData;
/// <summary>
/// 获取 Data
/// </summary>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
T GetData<T>() where T : class, IData;
/// <summary>
/// 注册 Utility
/// </summary>
void RegisterUtility<T>(T instance) where T : IUtility;
/// <summary>
/// 获取 Utility
/// </summary>
T GetUtility<T>() where T : class, IUtility;
/// <summary>
/// 发送命令
/// </summary>
void SendCommand<T>() where T : ICommand, new();
/// <summary>
/// 发送命令
/// </summary>
void SendCommand<T>(T command) where T : ICommand;
/// <summary>
/// 事件发送
/// </summary>
/// <typeparam name="T"></typeparam>
public void SendEvent<TEvent>(TEvent key) where TEvent : IConvertible;
/// <summary>
/// 事件发送
/// </summary>
/// <typeparam name="T"></typeparam>
public void SendEvent<TEvent, Tvalue1>(TEvent key, Tvalue1 value) where TEvent : IConvertible;
/// <summary>
/// 事件发送
/// </summary>
/// <typeparam name="T"></typeparam>
public void SendEvent<TEvent, Tvalue1, Tvalue2>(TEvent key, Tvalue1 value1, Tvalue2 value2)
where TEvent : IConvertible;
/// <summary>
/// 事件发送
/// </summary>
/// <typeparam name="T"></typeparam>
public void SendEvent<TEvent, Tvlue1, Tvlue2, Tvlue3>(TEvent key, Tvlue1 value1, Tvlue2 vlue2, Tvlue3 vlue3)
where TEvent : IConvertible;
/// <summary>
/// 事件发送
/// </summary>
/// <typeparam name="T"></typeparam>
public void SendEvent<TEvent>(TEvent key, object[] values) where TEvent : IConvertible;
/// <summary>
/// 事件监听
/// </summary>
/// <param name="onEvent"></param>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
public IUnRegister RegisterEvent<TEvent>(TEvent key, Action onEvent) where TEvent : IConvertible;
/// <summary>
/// 事件监听
/// </summary>
/// <param name="onEvent"></param>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
public IUnRegister RegisterEvent<TEvent, Tvalue1>(TEvent key, Action<Tvalue1> onEvent)
where TEvent : IConvertible;
/// <summary>
/// 事件监听
/// </summary>
/// <param name="onEvent"></param>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
public IUnRegister RegisterEvent<TEvent, Tvalue1, Tvalue2>(TEvent key, Action<Tvalue1, Tvalue2> onEvent)
where TEvent : IConvertible;
/// <summary>
/// 事件监听
/// </summary>
/// <param name="onEvent"></param>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
public IUnRegister RegisterEvent<TEvent, Tvlue1, Tvlue2, Tvlue3>(TEvent key,
Action<Tvlue1, Tvlue2, Tvlue3> onEvent) where TEvent : IConvertible;
/// <summary>
/// 事件监听
/// </summary>
/// <param name="onEvent"></param>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
public IUnRegister RegisterEvent<TEvent>(TEvent key, Action<object[]> onEvent) where TEvent : IConvertible;
/// <summary>
/// 事件销毁
/// </summary>
/// <param name="onEvent"></param>
/// <typeparam name="T"></typeparam>
public void UnRegisterEvent<TEvent>(TEvent key, Action onEvent) where TEvent : IConvertible;
/// <summary>
/// 事件销毁
/// </summary>
/// <param name="onEvent"></param>
/// <typeparam name="T"></typeparam>
public void UnRegisterEvent<TEvent, Tvalue1>(TEvent key, Action<Tvalue1> onEvent) where TEvent : IConvertible;
/// <summary>
/// 事件销毁
/// </summary>
/// <param name="onEvent"></param>
/// <typeparam name="T"></typeparam>
public void UnRegisterEvent<TEvent, Tvalue1, Tvalue2>(TEvent key, Action<Tvalue1, Tvalue2> onEvent)
where TEvent : IConvertible;
/// <summary>
/// 事件销毁
/// </summary>
/// <param name="onEvent"></param>
/// <typeparam name="T"></typeparam>
/// <typeparam name="TEvent"></typeparam>
/// <typeparam name="TVlue1"></typeparam>
/// <typeparam name="Tvlue2"></typeparam>
/// <typeparam name="Tvlue3"></typeparam>
public void UnRegisterEvent<TEvent, Tvlue1, Tvlue2, Tvlue3>(TEvent key, Action<Tvlue1, Tvlue2, Tvlue3> onEvent)
where TEvent : IConvertible;
/// <summary>
/// 事件销毁
/// </summary>
/// <param name="key"></param>
/// <param name="onEvent"></param>
/// <typeparam name="T"></typeparam>
/// <typeparam name="TEvent"></typeparam>
public void UnRegisterEvent<TEvent>(TEvent key, Action<object[]> onEvent) where TEvent : IConvertible;
TResult SendQuery<TResult>(IQuery<TResult> query);
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 55418c02fe504af59375dddd017925f3
timeCreated: 1624954968
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 315d6f08092768e47a024d5c7d094717
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,109 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Stary.Evo
{
public interface IBindableProperty<T> : IReadonlyBindableProperty<T>
{
new T Value { get; set; }
void SetValueWithoutEvent(T newValue);
}
public interface IReadonlyBindableProperty<T>
{
T Value { get; }
IUnRegister RegisterWithInitValue(Action<T> action);
void UnRegister(Action<T> onValueChanged);
IUnRegister Register(Action<T> onValueChanged);
}
public class BindableProperty<T> : IBindableProperty<T>
{
public BindableProperty(T defaultValue = default)
{
mValue = defaultValue;
}
protected T mValue;
public T Value
{
get => GetValue();
set
{
if (value == null && mValue == null) return;
if (value != null && value.Equals(mValue)) return;
SetValue(value);
mOnValueChanged?.Invoke(value);
}
}
protected virtual void SetValue(T newValue)
{
mValue = newValue;
}
protected virtual T GetValue()
{
return mValue;
}
public void SetValueWithoutEvent(T newValue)
{
mValue = newValue;
}
private Action<T> mOnValueChanged = (v) => { };
public IUnRegister Register(Action<T> onValueChanged)
{
mOnValueChanged += onValueChanged;
return new BindablePropertyUnRegister<T>()
{
BindableProperty = this,
OnValueChanged = onValueChanged
};
}
public IUnRegister RegisterWithInitValue(Action<T> onValueChanged)
{
onValueChanged(mValue);
return Register(onValueChanged);
}
public static implicit operator T(BindableProperty<T> property)
{
return property.Value;
}
public override string ToString()
{
return Value.ToString();
}
public void UnRegister(Action<T> onValueChanged)
{
mOnValueChanged -= onValueChanged;
}
}
public class BindablePropertyUnRegister<T> : IUnRegister
{
public BindableProperty<T> BindableProperty { get; set; }
public Action<T> OnValueChanged { get; set; }
public void UnRegister()
{
BindableProperty.UnRegister(OnValueChanged);
BindableProperty = null;
OnValueChanged = null;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 57e121dc01fbf6b4f973d5170b1b7050
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+3
View File
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 5029af932e6e4085b9438be230c649b7
timeCreated: 1624956902
@@ -0,0 +1,34 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Stary.Evo
{
public interface ICommand : IBelongToArchitecture,ICanSetArchitecture,ICanGetSystem,ICanGetData,ICanGetUtility,ICanSendCommand,ICanSendEvent, ICanSendQuery
{
void Execute();
}
public abstract class AbstractCommand : ICommand
{
private IArchitecture mArchitecture;
IArchitecture IBelongToArchitecture.GetArchitecture()
{
return mArchitecture;
}
void ICanSetArchitecture.SetArchitecture(IArchitecture architecture)
{
mArchitecture = architecture;
}
void ICommand.Execute()
{
OnExecute();
}
protected abstract void OnExecute();
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 501ba9abd3ae8344c8f30f3d4a18b34b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,7 @@
namespace Stary.Evo
{
public interface IController:IBelongToArchitecture,ICanGetSystem,ICanGetData,ICanSendCommand,ICanRegisterEvent,ICanSendQuery, ICanGetUtility
{
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 485e552656f54b618a85271943a76c3d
timeCreated: 1625018098
@@ -0,0 +1,34 @@
namespace Stary.Evo
{
public interface IData: IBelongToArchitecture,ICanSetArchitecture,ICanGetUtility ,ICanSendEvent
{
void Init();
void Dispose();
}
public abstract class AbstractData : IData
{
private IArchitecture mArchitecture;
//接口阉割,子类重写无法用子类调用
IArchitecture IBelongToArchitecture.GetArchitecture()
{
return mArchitecture;
}
void ICanSetArchitecture.SetArchitecture(IArchitecture architecture)
{
mArchitecture = architecture;
}
void IData.Init()
{
OnInit();
}
public abstract void Dispose();
//数据初始化
protected abstract void OnInit();
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 2138d8e4edea4564b328a71f45aadfd7
timeCreated: 1624937508
@@ -0,0 +1,29 @@
namespace Stary.Evo
{
public interface IQuery<TResult> : IBelongToArchitecture,ICanSetArchitecture,ICanGetData,ICanGetSystem,ICanGetUtility
{
TResult Do();
}
public abstract class AbstractQuery<T> : IQuery<T>
{
public T Do()
{
return OnDo();
}
protected abstract T OnDo();
private IArchitecture mArchitecture;
IArchitecture IBelongToArchitecture.GetArchitecture()
{
return mArchitecture;
}
void ICanSetArchitecture.SetArchitecture(IArchitecture architecture)
{
mArchitecture = architecture;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f4fd5f513a09f6f47b1b0a27a2f0500e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,30 @@
namespace Stary.Evo
{
public interface ISystem: IBelongToArchitecture,ICanSetArchitecture,ICanGetData,ICanGetUtility ,ICanRegisterEvent,ICanSendEvent,ICanGetSystem
{
void Init();
void Dispose();
}
public abstract class AbstractSystem : ISystem
{
private IArchitecture mArchitecture;
IArchitecture IBelongToArchitecture.GetArchitecture()
{
return mArchitecture;
}
void ICanSetArchitecture.SetArchitecture(IArchitecture architecture)
{
mArchitecture = architecture;
}
void ISystem.Init()
{
OnInit();
}
public abstract void Dispose();
protected abstract void OnInit();
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 187938c258244d9ea6e81a5948033cf8
timeCreated: 1624954926
@@ -0,0 +1,7 @@
namespace Stary.Evo
{
public interface IUtility
{
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 55d0b44b52f841d4af6f7ebc0cad1abe
timeCreated: 1625038442
@@ -0,0 +1,111 @@
using System;
using System.Collections.Generic;
using UnityEngine;
namespace Stary.Evo
{
/// <summary>
/// 用于注销的接口(为了防止注册后忘记注销特实现此接口)
/// </summary>
public interface IUnRegister
{
void UnRegister();
}
public interface IUnRegisterList
{
List<IUnRegister> UnregisterList { get; }
}
public static class IUnRegisterListExtension
{
public static void AddToUnregisterList(this IUnRegister self, IUnRegisterList unRegisterList)
{
unRegisterList.UnregisterList.Add(self);
}
public static void UnRegisterAll(this IUnRegisterList self)
{
foreach (var unRegister in self.UnregisterList)
{
unRegister.UnRegister();
}
self.UnregisterList.Clear();
}
}
/// <summary>
/// 自定义可注销的类
/// </summary>
public struct CustomUnRegister : IUnRegister
{
/// <summary>
/// 委托对象
/// </summary>
private Action mOnUnRegister { get; set; }
/// <summary>
/// 带参构造函数
/// </summary>
/// <param name="onDispose"></param>
public CustomUnRegister(Action onUnRegsiter)
{
mOnUnRegister = onUnRegsiter;
}
/// <summary>
/// 资源释放
/// </summary>
public void UnRegister()
{
mOnUnRegister.Invoke();
mOnUnRegister = null;
}
}
/// <summary>
/// 注销的触发器
/// </summary>
public class UnRegisterOnDestroyTrigger : MonoBehaviour
{
private HashSet<IUnRegister> mUnRegisters = new HashSet<IUnRegister>();
public void AddUnRegister(IUnRegister unRegister)
{
mUnRegisters.Add(unRegister);
}
public void RemoveUnRegister(IUnRegister unRegister)
{
mUnRegisters.Remove(unRegister);
}
private void OnDestroy()
{
foreach (var unRegister in mUnRegisters)
{
unRegister.UnRegister();
}
mUnRegisters.Clear();
}
}
/// <summary>
/// 注销触发器的使用简化
/// </summary>
public static class UnRegisterExtension
{
public static IUnRegister UnRegisterWhenGameObjectDestroyed(this IUnRegister unRegister, GameObject gameObject)
{
var trigger = gameObject.GetComponent<UnRegisterOnDestroyTrigger>()??null;
if (!trigger)
{
trigger = gameObject.AddComponent<UnRegisterOnDestroyTrigger>();
}
trigger.AddUnRegister(unRegister);
return unRegister;
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 81fe5c4dfa304c2ab19ebf1cc876813e
timeCreated: 1730381395
+44
View File
@@ -0,0 +1,44 @@
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.Events;
namespace Stary.Evo
{
/// <summary>
/// 热更基类,应该继承的基类
/// </summary>
public class DomainBase : MonoBehaviour
{
/// <summary>
/// 触发Domain时,调用该方法
/// </summary>
/// <param name="param"></param>
public virtual void OnEnter(string param)
{
}
/// <summary>
/// Domain被关闭时,会调该方法
/// </summary>
/// <param name="param"></param>
public virtual void OnExit()
{
}
/// <summary>
/// 如果Domain主动退出,请触发此Action
/// </summary>
public UnityAction RequestExit;
public virtual async Task OnEnterAsync(string param)
{
await Task.Delay(1);
}
public virtual async Task OnExitAsync()
{
await Task.Delay(1);
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 8923efe3eb184e7f9283f71e2dc4ea10
timeCreated: 1742540500
+3
View File
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 36db59b1e91d4e6aa6155fd9cf38164e
timeCreated: 1624956940
@@ -0,0 +1,72 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Stary.Evo
{
public class IOCContainer
{
/// <summary>
/// 实例
/// </summary>
public Dictionary<Type, object> mInstances = new Dictionary<Type, object>();
/// <summary>
/// 注册
/// </summary>
/// <param name="instance"></param>
/// <typeparam name="T"></typeparam>
public void Register<T>(T instance)
{
var key = typeof(T);
if (mInstances.ContainsKey(key))
{
mInstances[key] = instance;
}
else
{
mInstances.Add(key, instance);
}
}
/// <summary>
/// 注销
/// </summary>
public void UnRegister<T>() where T : class
{
var key = typeof(T);
if (mInstances.TryGetValue(key, out var retObj))
{
retObj = null;
mInstances.Remove(key);
}
else
{
Debug.LogErrorFormat("IOC容器里不存在Key:--【{0}】--请用对应创建的key进行调用",key);
}
}
public T Get<T>() where T : class
{
var key = typeof(T);
if (mInstances.TryGetValue(key, out var retObj))
{
return retObj as T;
}
else
{
Debug.LogErrorFormat("IOC容器里不存在Key:--【{0}】--请用对应创建的key进行调用",key);
}
return null;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: efee404ec60bbfb4c86bce2914f6c7cb
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 74d74706ae6d4fada1c6284ad3d3fe71
timeCreated: 1739526557
@@ -0,0 +1,29 @@
using UnityEngine;
using UnityEngine.Serialization;
namespace Stary.Evo
{
[CreateAssetMenu(fileName = "DomainConfig", menuName = "Evo/Create DomainConfig")]
public class DomainConfig : ScriptableObject
{
/// <summary>
/// 域id
/// </summary>
public string domain;
/// <summary>
/// 入口预制体
/// </summary>
public string mainPrefab;
/// <summary>
/// 入口命名空间
/// </summary>
public string @namespace;
/// <summary>
/// 入口类
/// </summary>
public string className;
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 03dc1bf5b95446838cce6d0fefed81fe
timeCreated: 1739527373
@@ -0,0 +1,24 @@
using System;
using UnityEngine;
namespace Stary.Evo
{
[CreateAssetMenu(fileName = "HotfixMainResDomain", menuName = "Evo/Create HotfixMainResDomain")]
public class HotfixMainResDomain : ScriptableObject
{
public HotfixMainResDomainEntity hotfixMainResDomainEntity;
}
[Serializable]
public class HotfixMainResDomainEntity
{
public string domain;
public string ipconfig="http://192.168.31.100:5005/HotRefresh";
public string pathconfig;
public string packageVersion;
public string username="UnityHot";
public string password="Unity1234";
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 1a78aa2541a743f89b2646efe4073f01
timeCreated: 1741332398
+3
View File
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 4596f376175f453ebfb7d31c31b3e9bc
timeCreated: 1739759528
@@ -0,0 +1,203 @@
// using System;
// using System.Collections.Generic;
// using System.Linq;
// using System.Threading.Tasks;
// using UnityEngine;
// using UnityEngine.AddressableAssets;
// using UnityEngine.ResourceManagement.AsyncOperations;
// using UnityEngine.ResourceManagement.ResourceProviders;
// using UnityEngine.SceneManagement;
// using Stary.Evo;
//
// public class AddressableLoad : Singleton<AddressableLoad>
// {
// private Dictionary<string, AsyncOperationHandle> nameCaches = new Dictionary<string, AsyncOperationHandle>();
// private AsyncOperationHandle ScenesHandle; //当前场景的Addressable Handle
//
//
// /// <summary>
// ///异步读取指定的Addressable类型的数据
// /// </summary>
// /// <param name="addressName"></param>
// /// <param name="onComplete">执行成功的回调</param>
// /// <param name="onFailed">执行失败的回调</param>
// /// <param name="address">路径</param>
// public async Task<T> LoadAssetASync<T>(string addressName) where T : UnityEngine.Object
// {
// try
// {
// if (nameCaches.TryGetValue(addressName, out var existingHandle))
// {
// await existingHandle.Task;
// if (existingHandle.Status == AsyncOperationStatus.Succeeded)
// {
// var result = (T)existingHandle.Result;
// return result;
// }
// else
// {
// nameCaches.Remove(addressName);
// }
// }
//
// var handle = Addressables.LoadAssetAsync<T>(addressName);
// nameCaches.Add(addressName, handle);
// await handle.Task;
// return handle.Result;
// }
// catch (Exception e)
// {
// Debug.LogError($"加载资源失败: 【{addressName}】\n{e.Message}");
// return null;
// }
// }
//
// /// <summary>
// /// 同步读取指定的Addressable类型的数据
// /// </summary>
// /// <param name="addressName"></param>
// /// <param name="onComplete">执行成功的回调</param>
// /// <param name="onFailed">执行失败的回调</param>
// /// <param name="address">路径</param>
// public void LoadAssetSync<T>(string addressName, Action<T> onComplete, Action onFailed) where T : UnityEngine.Object
// {
// if (nameCaches.ContainsKey(addressName))
// {
// var handle = this.nameCaches[addressName];
// if (handle.IsDone)
// {
// if (onComplete != null)
// {
// onComplete(nameCaches[addressName].Result as T);
// }
// }
// else
// {
// HandleAddCompleted<T>(addressName, handle, onComplete, onFailed);
// }
// }
// else
// {
// var handle = Addressables.LoadAssetAsync<T>(addressName);
// HandleAddCompleted<T>(addressName, handle, onComplete, onFailed);
// nameCaches.Add(addressName, handle);
// }
// }
//
// /// <summary>
// /// 同步读取指定的Addressable类型的场景数据
// /// </summary>
// public async Task<SceneInstance> LoadSceneAsync(string sceneName, LoadSceneMode mode, Action completeCallBack = null,
// bool isActiveOnLoaded = true, int priority = 100)
// {
// var handle = Addressables.LoadSceneAsync(sceneName, mode, isActiveOnLoaded, priority);
//
// var res = await handle.Task;
//
// completeCallBack?.Invoke();
//
// return res;
// }
//
// /// <summary>
// /// 读取指定的Addressable类型的名字或标签数据的集合
// /// </summary>
// /// <param name="address">名字</param>
// /// <param name="onComplete">单个执行成功的回调</param>
// /// <param name="allOnComplete">全部执行成功的回调</param>
// /// <param name="onFailed">执行失败的回调</param>
// /// <typeparam name="T"></typeparam>
// public void LoadTagAsset<T>(string addressTag, Action<T> onComplete, Action<T> allOnComplete,
// Action onFailed = null) where T : UnityEngine.Object
// {
// if (nameCaches.ContainsKey(addressTag))
// {
// var handle = this.nameCaches[addressTag];
// if (handle.IsDone)
// {
// if (onComplete != null)
// {
// onComplete(nameCaches[addressTag].Result as T);
// }
// }
// else
// {
// HandleAddCompleted(addressTag, handle, allOnComplete, onFailed);
// }
// }
// else
// {
// var handle = Addressables.LoadAssetsAsync(addressTag, onComplete);
// AddTagCompleted(addressTag, handle, allOnComplete, onFailed);
// nameCaches.Add(addressTag, handle);
// }
// }
//
// private void AddTagCompleted<T>(string addressTag, AsyncOperationHandle handle, Action<T> allOnComplete,
// Action onFailed = null) where T : UnityEngine.Object
// {
// handle.Completed += (result) =>
// {
// if (result.Status == AsyncOperationStatus.Succeeded)
// {
// var obj = result.Result as T;
// if (allOnComplete != null)
// {
// allOnComplete(obj);
// }
// }
// else
// {
// if (onFailed != null)
// {
// onFailed();
// }
//
// Debug.LogErrorFormat("读取地址为-【{0}】-的ab包资源失败!", addressTag);
// }
// };
// }
//
// private void HandleAddCompleted<T>(string addressName, AsyncOperationHandle handle, Action<T> onComplete,
// Action onFailed = null) where T : UnityEngine.Object
// {
// handle.Completed += (result) =>
// {
// if (result.Status == AsyncOperationStatus.Succeeded)
// {
// var obj = result.Result as T;
// if (onComplete != null)
// {
// onComplete(obj);
// }
// }
// else
// {
// if (onFailed != null)
// {
// onFailed();
// }
//
// Debug.LogErrorFormat("读取地址为-【{0}】-的ab包资源失败!", addressName);
// }
// };
// }
//
// private void LoadRelease(string name)
// {
// if (nameCaches.ContainsKey(name))
// {
// Addressables.Release(nameCaches[name]);
// nameCaches.Remove(name);
// }
// }
//
// private void OnDestroy()
// {
// for (int i = 0; i < nameCaches.Count; i++)
// {
// KeyValuePair<string, AsyncOperationHandle> kv = nameCaches.ElementAt(i);
// LoadRelease(kv.Key);
// }
// }
// }
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f2a6c483194d4c64da7c4c43bb892873
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+3
View File
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 7923f15e799e4b51a9c5791d805c04cc
timeCreated: 1625107159
@@ -0,0 +1,7 @@
namespace Stary.Evo
{
public interface IBelongToArchitecture
{
IArchitecture GetArchitecture();
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 29267e7525d5442b8656b4c7e32d46db
timeCreated: 1624936941
@@ -0,0 +1,14 @@
namespace Stary.Evo
{
public interface ICanGetData: IBelongToArchitecture
{
}
public static class CanGetDataExtension
{
public static T GetData<T>(this ICanGetData self) where T : class, IData
{
return self.GetArchitecture().GetData<T>();
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 1a8db07c697b49dfb467b3adb719f864
timeCreated: 1625107407
@@ -0,0 +1,16 @@
using UnityEngine;
namespace Stary.Evo
{
public interface ICanGetSystem: IBelongToArchitecture
{
}
public static class CanGetSystemExtension
{
public static T GetSystem<T>(this ICanGetSystem self) where T : class, ISystem
{
return self.GetArchitecture().GetSystem<T>();
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 98fef7169f2540d883fef0f3b57e7597
timeCreated: 1625109288
@@ -0,0 +1,14 @@
namespace Stary.Evo
{
public interface ICanGetUtility: IBelongToArchitecture
{
}
public static class CanGetUtilityExtension
{
public static T GetUtility<T>(this ICanGetUtility self) where T : class, IUtility
{
return self.GetArchitecture().GetUtility<T>();
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: ac4506dbc33147408207becd4084b9e4
timeCreated: 1625107159
@@ -0,0 +1,67 @@
using System;
namespace Stary.Evo
{
public interface ICanRegisterEvent:IBelongToArchitecture
{
}
public static class CanRegisterEventExtension
{
public static IUnRegister RegisterEvent<T>(this ICanRegisterEvent self,T key,Action onEvent) where T : IConvertible
{
return self.GetArchitecture().RegisterEvent(key,onEvent);
}
public static IUnRegister RegisterEvent<T,T1>(this ICanRegisterEvent self,T key,Action<T1> onEvent) where T : IConvertible
{
return self.GetArchitecture().RegisterEvent(key,onEvent);
}
public static IUnRegister RegisterEvent<T,T1,T2>(this ICanRegisterEvent self,T key,Action<T1,T2> onEvent) where T : IConvertible
{
return self.GetArchitecture().RegisterEvent(key,onEvent);
}
public static IUnRegister RegisterEvent<T,T1,T2,T3>(this ICanRegisterEvent self,T key,Action<T1,T3> onEvent) where T : IConvertible
{
return self.GetArchitecture().RegisterEvent(key,onEvent);
}
public static IUnRegister RegisterEvent<T>(this ICanRegisterEvent self,T key,Action<object[]> onEvent) where T : IConvertible
{
return self.GetArchitecture().RegisterEvent(key,onEvent);
}
public static void UnRegisterEvent<T>(this ICanRegisterEvent self,T key,Action onEvent) where T : IConvertible
{
self.GetArchitecture().UnRegisterEvent(key,onEvent);
}
public static void UnRegisterEvent<T,T1>(this ICanRegisterEvent self,T key,Action<T1> onEvent) where T : IConvertible
{
self.GetArchitecture().UnRegisterEvent(key,onEvent);
}
public static void UnRegisterEvent<T,T1,T2>(this ICanRegisterEvent self,T key,Action<T1,T2> onEvent) where T : IConvertible
{
self.GetArchitecture().UnRegisterEvent(key,onEvent);
}
public static void UnRegisterEvent<T,T1,T2,T3>(this ICanRegisterEvent self,T key,Action<T1,T3> onEvent) where T : IConvertible
{
self.GetArchitecture().UnRegisterEvent(key,onEvent);
}
public static void UnRegisterEvent<T>(this ICanRegisterEvent self,T key,Action<object[]> onEvent) where T : IConvertible
{
self.GetArchitecture().UnRegisterEvent(key,onEvent);
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 3afca6ed153c4f35bfbe630644c9bdab
timeCreated: 1625124335
@@ -0,0 +1,21 @@
using UnityEngine;
namespace Stary.Evo
{
public interface ICanSendCommand: IBelongToArchitecture
{
}
public static class CanSendCommandExtension
{
public static void SendCommand<T>(this ICanSendCommand self) where T :class, ICommand, new()
{
self.GetArchitecture().SendCommand<T>();
}
public static void SendCommand<T>(this ICanSendCommand self,T command) where T : ICommand
{
self.GetArchitecture().SendCommand<T>(command);
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 7d4d286b9072404a9d1eed529797d37b
timeCreated: 1625109500
@@ -0,0 +1,39 @@
using System;
namespace Stary.Evo
{
public interface ICanSendEvent:IBelongToArchitecture
{
}
public static class CanSendEventExtension
{
public static void SendEvent<T>(this ICanSendEvent self,T key) where T : IConvertible
{
self.GetArchitecture().SendEvent(key);
}
public static void SendEvent<T,T1>(this ICanSendEvent self,T key,T1 value) where T : IConvertible
{
self.GetArchitecture().SendEvent(key,value);
}
public static void SendEvent<T,T1,T2>(this ICanSendEvent self,T key,T1 value1,T2 value2) where T : IConvertible
{
self.GetArchitecture().SendEvent(key,value1,value2);
}
public static void SendEvent<T,T1,T2,T3>(this ICanSendEvent self,T key,T1 value1,T2 value2,T3 value3) where T : IConvertible
{
self.GetArchitecture().SendEvent(key,value1,value2, value3);
}
public static void SendEvent<T>(this ICanSendEvent self,T key,object[] values) where T : IConvertible
{
self.GetArchitecture().SendEvent(key,values);
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 0d5b249bb8554780a126cbe5d7189165
timeCreated: 1625124323
@@ -0,0 +1,16 @@
namespace Stary.Evo
{
public interface ICanSendQuery : IBelongToArchitecture
{
}
public static class CanSendQueryExtension
{
public static T SendQuery<T>(this ICanSendQuery self, IQuery<T> query)
{
return self.GetArchitecture().SendQuery(query);
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 435afd9942e6ed5409bb08b235b4dc03
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,7 @@
namespace Stary.Evo
{
public interface ICanSetArchitecture
{
void SetArchitecture(IArchitecture architecture);
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 1d30432f9f834aab87ee534ecc6e3fa4
timeCreated: 1625018433
+85
View File
@@ -0,0 +1,85 @@
using System;
using System.Reflection;
using UnityEngine;
namespace Stary.Evo
{
public class Singleton<T> where T : class
{
public static T Instance
{
get
{
if (mInstance == null)
{
// 通过反射获取构造
var ctors = typeof(T).GetConstructors(BindingFlags.Instance | BindingFlags.NonPublic);
// 获取无参非 public 的构造
var ctor = Array.Find(ctors, c => c.GetParameters().Length == 0);
if (ctor == null)
{
throw new Exception("Non-Public Constructor() not found in " + typeof(T));
}
mInstance = ctor.Invoke(null) as T;
}
return mInstance;
}
}
private static T mInstance;
}
/// <summary>
/// 单例基类
/// </summary>
/// <typeparam name="T"></typeparam>
public class MonoSingleton<T>: MonoBehaviour where T: MonoBehaviour
{
private static T mInstance;
public static T Instance
{
get {
if (mInstance == null)
{
T t = GameObject.FindObjectOfType<T>();
if (t)
{
mInstance = t;
}
else
{
GameObject go = new GameObject(typeof(T).Name);
mInstance = go.AddComponent<T>();
}
return mInstance;
}
return mInstance;
}
}
}
public class DoNotDestroy : MonoBehaviour
{
public static DoNotDestroy Instance;
private void Awake()
{
if (Instance != null)
{
Destroy(gameObject);
return;
}
Instance = this;
DontDestroyOnLoad(gameObject);
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 87700e1e40089e843aa7c13dd28b0214
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 0d11726814f336347b8828f1029dfad5
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 0e595bb208aff00418dc5a646f5e5bae
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 9bc0ac15207240f695c4ba3f35865240
timeCreated: 1710224493
@@ -0,0 +1,24 @@
/****************************************************************************
* Copyright (c) 2015 - 2024 liangxiegame UNDER MIT License
*
* https://qStary.Evo.cn
* https://github.com/liangxiegame/QFramework
* https://gitee.com/liangxiegame/QFramework
****************************************************************************/
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.EventSystems;
namespace Stary.Evo
{
public class OnDeselectUnityEvent: MonoBehaviour, IDeselectHandler
{
public UnityEvent<BaseEventData> OnDeselectEvent;
public void OnDeselect(BaseEventData eventData)
{
OnDeselectEvent?.Invoke(eventData);
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 5edff8e50ab84809afe6b9894eef68ab
timeCreated: 1710224509
@@ -0,0 +1,24 @@
/****************************************************************************
* Copyright (c) 2016 - 2024 liangxiegame UNDER MIT License
*
* https://qStary.Evo.cn
* https://github.com/liangxiegame/QFramework
* https://gitee.com/liangxiegame/QFramework
****************************************************************************/
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.EventSystems;
namespace Stary.Evo
{
public class OnSelectUnityEvent : MonoBehaviour, ISelectHandler
{
public UnityEvent<BaseEventData> OnSelectEvent;
public void OnSelect(BaseEventData eventData)
{
OnSelectEvent?.Invoke(eventData);
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: b73c32a61ddd4b469f20ad0f287b2a9e
timeCreated: 1710224585
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 9a4d4fb049e264d7585467dc91a94f28
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,141 @@
using System;
using System.Collections.Generic;
namespace Stary.Evo
{
public interface IEasyEvent
{
}
public class EasyEvent : IEasyEvent
{
private Action mOnEvent = () => { };
public IUnRegister Register(Action onEvent)
{
mOnEvent += onEvent;
return new CustomUnRegister(() => { UnRegister(onEvent); });
}
public void UnRegister(Action onEvent)
{
mOnEvent -= onEvent;
}
public void Trigger()
{
mOnEvent?.Invoke();
}
}
public class EasyEvent<T> : IEasyEvent
{
private Action<T> mOnEvent = e => { };
public IUnRegister Register(Action<T> onEvent)
{
mOnEvent += onEvent;
return new CustomUnRegister(() => { UnRegister(onEvent); });
}
public void UnRegister(Action<T> onEvent)
{
mOnEvent -= onEvent;
}
public void Trigger(T t)
{
mOnEvent?.Invoke(t);
}
}
public class EasyEvent<T, K> : IEasyEvent
{
private Action<T, K> mOnEvent = (t, k) => { };
public IUnRegister Register(Action<T, K> onEvent)
{
mOnEvent += onEvent;
return new CustomUnRegister(() => { UnRegister(onEvent); });
}
public void UnRegister(Action<T, K> onEvent)
{
mOnEvent -= onEvent;
}
public void Trigger(T t, K k)
{
mOnEvent?.Invoke(t, k);
}
}
public class EasyEvent<T, K, S> : IEasyEvent
{
private Action<T, K, S> mOnEvent = (t, k, s) => { };
public IUnRegister Register(Action<T, K, S> onEvent)
{
mOnEvent += onEvent;
return new CustomUnRegister(() => { UnRegister(onEvent); });
}
public void UnRegister(Action<T, K, S> onEvent)
{
mOnEvent -= onEvent;
}
public void Trigger(T t, K k, S s)
{
mOnEvent?.Invoke(t, k, s);
}
}
public class EasyEventSystems
{
private static EasyEventSystems _mGlobalEventSystems = new EasyEventSystems();
public static T Get<T>() where T : IEasyEvent
{
return _mGlobalEventSystems.GetEvent<T>();
}
public static void Register<T>() where T : IEasyEvent, new()
{
_mGlobalEventSystems.AddEvent<T>();
}
private Dictionary<Type, IEasyEvent> mTypeEvents = new Dictionary<Type, IEasyEvent>();
public void AddEvent<T>() where T : IEasyEvent, new()
{
mTypeEvents.Add(typeof(T), new T());
}
public T GetEvent<T>() where T : IEasyEvent
{
IEasyEvent e;
if (mTypeEvents.TryGetValue(typeof(T), out e))
{
return (T) e;
}
return default;
}
public T GetOrAddEvent<T>() where T : IEasyEvent, new()
{
var eType = typeof(T);
if (mTypeEvents.TryGetValue(eType, out var e))
{
return (T) e;
}
var t = new T();
mTypeEvents.Add(eType, t);
return t;
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: e33d19dd11204fbe87eb16c6bc9b2621
timeCreated: 1658655004
@@ -0,0 +1,199 @@
using System;
using System.Collections.Generic;
namespace Stary.Evo
{
public class EnumEventSystem
{
public static readonly EnumEventSystem Global = new EnumEventSystem();
private readonly Dictionary<int, IEasyEvent> mEvents = new Dictionary<int, IEasyEvent>(50);
public EnumEventSystem(){}
#region
public IUnRegister Register<T>(T key, Action onEvent)where T : IConvertible
{
var kv = key.ToInt32(null);
if (mEvents.TryGetValue(kv, out var e))
{
var easyEvent = e.As<EasyEvent>();
return easyEvent.Register(onEvent);
}
else
{
var easyEvent = new EasyEvent();
mEvents.Add(kv,easyEvent);
return easyEvent.Register(onEvent);
}
}
public IUnRegister Register<T,T1>(T key, Action<T1> onEvent)where T : IConvertible
{
var kv = key.ToInt32(null);
if (mEvents.TryGetValue(kv, out var e))
{
var easyEvent = e.As<EasyEvent<T1>>();
return easyEvent.Register(onEvent);
}
else
{
var easyEvent = new EasyEvent<T1>();
mEvents.Add(kv,easyEvent);
return easyEvent.Register(onEvent);
}
}
public IUnRegister Register<T,T1,T2>(T key, Action<T1,T2> onEvent)where T : IConvertible
{
var kv = key.ToInt32(null);
if (mEvents.TryGetValue(kv, out var e))
{
var easyEvent = e.As<EasyEvent<T1,T2>>();
return easyEvent.Register(onEvent);
}
else
{
var easyEvent = new EasyEvent<T1,T2>();
mEvents.Add(kv,easyEvent);
return easyEvent.Register(onEvent);
}
}
public IUnRegister Register<T,T1,T2,T3>(T key, Action<T1,T2,T3> onEvent) where T : IConvertible
{
var kv = key.ToInt32(null);
if (mEvents.TryGetValue(kv, out var e))
{
var easyEvent = e.As<EasyEvent<T1,T2,T3>>();
return easyEvent.Register(onEvent);
}
else
{
var easyEvent = new EasyEvent<T1,T2,T3>();
mEvents.Add(kv, easyEvent);
return easyEvent.Register(onEvent);
}
}
public IUnRegister Register<T>(T key, Action<object[]> onEvent) where T : IConvertible
{
var kv = key.ToInt32(null);
if (mEvents.TryGetValue(kv, out var e))
{
var easyEvent = e.As<EasyEvent<object[]>>();
return easyEvent.Register(onEvent);
}
else
{
var easyEvent = new EasyEvent<object[]>();
mEvents.Add(kv, easyEvent);
return easyEvent.Register(onEvent);
}
}
public void UnRegister<T>(T key, Action onEvent) where T : IConvertible
{
var kv = key.ToInt32(null);
if (mEvents.TryGetValue(kv, out var e))
{
e.As<EasyEvent>()?.UnRegister(onEvent);
}
}
public void UnRegister<T,T1>(T key, Action<T1> onEvent) where T : IConvertible
{
var kv = key.ToInt32(null);
if (mEvents.TryGetValue(kv, out var e))
{
e.As<EasyEvent<T1>>()?.UnRegister(onEvent);
}
}
public void UnRegister<T,T1,T2>(T key, Action<T1,T2> onEvent) where T : IConvertible
{
var kv = key.ToInt32(null);
if (mEvents.TryGetValue(kv, out var e))
{
e.As<EasyEvent<T1,T2>>()?.UnRegister(onEvent);
}
}
public void UnRegister<T,T1,T2,T3>(T key, Action<T1,T2,T3> onEvent) where T : IConvertible
{
var kv = key.ToInt32(null);
if (mEvents.TryGetValue(kv, out var e))
{
e.As<EasyEvent<T1,T2,T3>>()?.UnRegister(onEvent);
}
}
public void UnRegister<T>(T key, Action<object[]> onEvent) where T : IConvertible
{
var kv = key.ToInt32(null);
if (mEvents.TryGetValue(kv, out var e))
{
e.As<EasyEvent<object[]>>()?.UnRegister(onEvent);
}
}
public void UnRegisterAll()
{
mEvents.Clear();
}
public void Send<T>(T key) where T : IConvertible
{
var kv = key.ToInt32(null);
if (mEvents.TryGetValue(kv, out var e))
{
e.As<EasyEvent>().Trigger();
}
}
public void Send<T,T1>(T key, T1 t1) where T : IConvertible
{
var kv = key.ToInt32(null);
if (mEvents.TryGetValue(kv, out var e))
{
e.As<EasyEvent<T1>>().Trigger(t1);
}
}
public void Send<T,T1,T2>(T key, T1 t1,T2 t2) where T : IConvertible
{
var kv = key.ToInt32(null);
if (mEvents.TryGetValue(kv, out var e))
{
e.As<EasyEvent<T1,T2>>().Trigger(t1,t2);
}
}
public void Send<T,T1,T2,T3>(T key, T1 t1,T2 t2 ,T3 t3) where T : IConvertible
{
var kv = key.ToInt32(null);
if (mEvents.TryGetValue(kv, out var e))
{
e.As<EasyEvent<T1,T2,T3>>().Trigger(t1,t2,t3);
}
}
public void Send<T>(T key, params object[] args) where T : IConvertible
{
var kv = key.ToInt32(null);
if (mEvents.TryGetValue(kv, out var e))
{
e.As<EasyEvent<int,object[]>>().Trigger(kv,args);
}
}
#endregion
public void Dispose()
{
mEvents.Clear();
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 0f9c387bd15b741b2a7451be23c992ae
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,58 @@
using System;
using System.Collections.Generic;
using UnityEngine;
namespace Stary.Evo
{
public class TypeEventSystem
{
private readonly EasyEventSystems _mEventSystems = new EasyEventSystems();
public static readonly TypeEventSystem Global = new TypeEventSystem();
public void Send<T>() where T : new()
{
_mEventSystems.GetEvent<EasyEvent<T>>()?.Trigger(new T());
}
public void Send<T>(T e)
{
_mEventSystems.GetEvent<EasyEvent<T>>()?.Trigger(e);
}
public IUnRegister Register<T>(Action<T> onEvent)
{
var e = _mEventSystems.GetOrAddEvent<EasyEvent<T>>();
return e.Register(onEvent);
}
public void UnRegister<T>(Action<T> onEvent)
{
var e = _mEventSystems.GetEvent<EasyEvent<T>>();
if (e != null)
{
e.UnRegister(onEvent);
}
}
}
public interface IOnEvent<T>
{
void OnEvent(T e);
}
public static class OnGlobalEventExtension
{
public static IUnRegister RegisterEvent<T>(this IOnEvent<T> self) where T : struct
{
return TypeEventSystem.Global.Register<T>(self.OnEvent);
}
public static void UnRegisterEvent<T>(this IOnEvent<T> self) where T : struct
{
TypeEventSystem.Global.UnRegister<T>(self.OnEvent);
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 228453eae0804759b0fd585f7169789c
timeCreated: 1625121334
@@ -0,0 +1,173 @@
using System;
using System.Collections.Generic;
namespace Stary.Evo
{
[Obsolete("推荐使用 EnumEventSystem",false)]
public class StringEventSystem
{
public static readonly StringEventSystem Global = new StringEventSystem();
private Dictionary<string, IEasyEvent> mEvents = new Dictionary<string, IEasyEvent>();
public IUnRegister Register(string key, Action onEvent)
{
if (mEvents.TryGetValue(key, out var e))
{
var easyEvent = e.As<EasyEvent>();
return easyEvent.Register(onEvent);
}
else
{
var easyEvent = new EasyEvent();
mEvents.Add(key,easyEvent);
return easyEvent.Register(onEvent);
}
}
public IUnRegister Register<T>(string key, Action<T> onEvent)
{
if (mEvents.TryGetValue(key, out var e))
{
var easyEvent = e.As<EasyEvent<T>>();
return easyEvent.Register(onEvent);
}
else
{
var easyEvent = new EasyEvent<T>();
mEvents.Add(key,easyEvent);
return easyEvent.Register(onEvent);
}
}
public IUnRegister Register<T1,T2>(string key, Action<T1,T2> onEvent)
{
if (mEvents.TryGetValue(key, out var e))
{
var easyEvent = e.As<EasyEvent<T1,T2>>();
return easyEvent.Register(onEvent);
}
else
{
var easyEvent = new EasyEvent<T1,T2>();
mEvents.Add(key,easyEvent);
return easyEvent.Register(onEvent);
}
}
public IUnRegister Register<T1,T2,T3>(string key, Action<T1,T2,T3> onEvent)
{
if (mEvents.TryGetValue(key, out var e))
{
var easyEvent = e.As<EasyEvent<T1,T2,T3>>();
return easyEvent.Register(onEvent);
}
else
{
var easyEvent = new EasyEvent<T1,T2,T3>();
mEvents.Add(key,easyEvent);
return easyEvent.Register(onEvent);
}
}
public IUnRegister Register(string key, Action<object[]> onEvent)
{
if (mEvents.TryGetValue(key, out var e))
{
var easyEvent = e.As<EasyEvent<object[]> >();
return easyEvent.Register(onEvent);
}
else
{
var easyEvent = new EasyEvent<object[]> ();
mEvents.Add(key,easyEvent);
return easyEvent.Register(onEvent);
}
}
public void UnRegister(string key, Action onEvent)
{
if (mEvents.TryGetValue(key, out var e))
{
var easyEvent = e.As<EasyEvent>();
easyEvent?.UnRegister(onEvent);
}
}
public void UnRegister<T>(string key, Action<T> onEvent)
{
if (mEvents.TryGetValue(key, out var e))
{
var easyEvent = e.As<EasyEvent<T>>();
easyEvent?.UnRegister(onEvent);
}
}
public void UnRegister<T1,T2>(string key, Action<T1,T2> onEvent)
{
if (mEvents.TryGetValue(key, out var e))
{
var easyEvent = e.As<EasyEvent<T1,T2>>();
easyEvent?.UnRegister(onEvent);
}
}
public void UnRegister<T1,T2,T3>(string key, Action<T1,T2,T3> onEvent)
{
if (mEvents.TryGetValue(key, out var e))
{
var easyEvent = e.As<EasyEvent<T1,T2,T3>>();
easyEvent?.UnRegister(onEvent);
}
}
public void UnRegister(string key, Action<object[]> onEvent)
{
if (mEvents.TryGetValue(key, out var e))
{
var easyEvent = e.As<EasyEvent<object[]>>();
easyEvent?.UnRegister(onEvent);
}
}
public void Send(string key)
{
if (mEvents.TryGetValue(key, out var e))
{
var easyEvent = e.As<EasyEvent>();
easyEvent?.Trigger();
}
}
public void Send<T>(string key, T data)
{
if (mEvents.TryGetValue(key, out var e))
{
var easyEvent = e.As<EasyEvent<T>>();
easyEvent?.Trigger(data);
}
}
public void Send<T1,T2>(string key, T1 data1, T2 data2)
{
if (mEvents.TryGetValue(key, out var e))
{
var easyEvent = e.As<EasyEvent<T1,T2>>();
easyEvent?.Trigger(data1,data2);
}
}
public void Send<T1,T2,T3>(string key, T1 data1, T2 data2, T3 data3)
{
if (mEvents.TryGetValue(key, out var e))
{
var easyEvent = e.As<EasyEvent<T1,T2,T3>>();
easyEvent?.Trigger(data1,data2,data3);
}
}
public void Send(string key, object[] data)
{
if (mEvents.TryGetValue(key, out var e))
{
var easyEvent = e.As<EasyEvent<object[]>>();
easyEvent?.Trigger(data);
}
}
public void Dispose()
{
mEvents.Clear();
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 8502c9eab24d488c950d3eacbfc584b1
timeCreated: 1649307359
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 64db9a81348a42b8947c551059b8606e
timeCreated: 1658665668
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 0989f6c357dd66c4e99d135d7f605367
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,32 @@
using System;
using UnityEngine;
using Stary.Evo;
namespace Stary.Evo
{
public class OnBecameInvisibleEventTrigger : MonoBehaviour
{
public readonly EasyEvent OnBecameInvisibleEvent = new EasyEvent();
private void OnBecameInvisible()
{
OnBecameInvisibleEvent.Trigger();
}
}
public static class OnBecameInvisibleEventTriggerExtension
{
public static IUnRegister OnBecameInvisibleEvent<T>(this T self, Action onBecameInvisible)
where T : Component
{
return self.GetOrAddComponent<OnBecameInvisibleEventTrigger>().OnBecameInvisibleEvent
.Register(onBecameInvisible);
}
public static IUnRegister OnBecameInvisibleEvent(this GameObject self, Action onBecameInvisible)
{
return self.GetOrAddComponent<OnBecameInvisibleEventTrigger>().OnBecameInvisibleEvent
.Register(onBecameInvisible);
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 82df3683f4d240e48bbb63f36a0eaf10
timeCreated: 1693460492
@@ -0,0 +1,31 @@
using System;
using UnityEngine;
namespace Stary.Evo
{
public class OnBecameVisibleEventTrigger : MonoBehaviour
{
public readonly EasyEvent OnBecameVisibleEvent = new EasyEvent();
private void OnBecameVisible()
{
OnBecameVisibleEvent.Trigger();
}
}
public static class OnBecameVisibleEventTriggerExtension
{
public static IUnRegister OnBecameVisibleEvent<T>(this T self, Action onBecameVisible)
where T : Component
{
return self.GetOrAddComponent<OnBecameVisibleEventTrigger>().OnBecameVisibleEvent
.Register(onBecameVisible);
}
public static IUnRegister OnBecameVisibleEvent(this GameObject self, Action onBecameVisible)
{
return self.GetOrAddComponent<OnBecameVisibleEventTrigger>().OnBecameVisibleEvent
.Register(onBecameVisible);
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: d66e5459cb1f420c81fbe74291ee9f24
timeCreated: 1693460551
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 8977daa3a9c64e25a157230677908ea9
timeCreated: 1684917953
@@ -0,0 +1,31 @@
using System;
using UnityEngine;
namespace Stary.Evo
{
public class OnCollisionEnter2DEventTrigger : MonoBehaviour
{
public readonly EasyEvent<Collision2D> OnCollisionEnter2DEvent = new EasyEvent<Collision2D>();
private void OnCollisionEnter2D(Collision2D col)
{
OnCollisionEnter2DEvent.Trigger(col);
}
}
public static class OnCollisionEnter2DEventTriggerExtension
{
public static IUnRegister OnCollisionEnter2DEvent<T>(this T self, Action<Collision2D> onCollisionEnter2D)
where T : Component
{
return self.GetOrAddComponent<OnCollisionEnter2DEventTrigger>().OnCollisionEnter2DEvent
.Register(onCollisionEnter2D);
}
public static IUnRegister OnCollisionEnter2DEvent(this GameObject self, Action<Collision2D> onCollisionEnter2D)
{
return self.GetOrAddComponent<OnCollisionEnter2DEventTrigger>().OnCollisionEnter2DEvent
.Register(onCollisionEnter2D);
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: edcab69f84914ba59bef80b1bedf8c47
timeCreated: 1671428212
@@ -0,0 +1,31 @@
using System;
using UnityEngine;
namespace Stary.Evo
{
public class OnCollisionEnterEventTrigger : MonoBehaviour
{
public readonly EasyEvent<Collision> OnCollisionEnterEvent = new EasyEvent<Collision>();
private void OnCollisionEnter(Collision col)
{
OnCollisionEnterEvent.Trigger(col);
}
}
public static class OnCollisionEnterEventTriggerExtension
{
public static IUnRegister OnCollisionEnterEvent<T>(this T self, Action<Collision> onCollisionEnter)
where T : Component
{
return self.GetOrAddComponent<OnCollisionEnterEventTrigger>().OnCollisionEnterEvent
.Register(onCollisionEnter);
}
public static IUnRegister OnCollisionEnterEvent(this GameObject self, Action<Collision> onCollisionEnter)
{
return self.GetOrAddComponent<OnCollisionEnterEventTrigger>().OnCollisionEnterEvent
.Register(onCollisionEnter);
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 82d00be1a2cb39144b87de1036c4e048
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,31 @@
using System;
using UnityEngine;
namespace Stary.Evo
{
public class OnCollisionExit2DEventTrigger : MonoBehaviour
{
public readonly EasyEvent<Collision2D> OnCollisionExit2DEvent = new EasyEvent<Collision2D>();
private void OnCollisionExit2D(Collision2D col)
{
OnCollisionExit2DEvent.Trigger(col);
}
}
public static class OnCollisionExit2DEventTriggerExtension
{
public static IUnRegister OnCollisionExit2DEvent<T>(this T self, Action<Collision2D> onCollisionExit2D)
where T : Component
{
return self.GetOrAddComponent<OnCollisionExit2DEventTrigger>().OnCollisionExit2DEvent
.Register(onCollisionExit2D);
}
public static IUnRegister OnCollisionExit2DEvent(this GameObject self, Action<Collision2D> onCollisionExit2D)
{
return self.GetOrAddComponent<OnCollisionExit2DEventTrigger>().OnCollisionExit2DEvent
.Register(onCollisionExit2D);
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 8928ffac271742d0a2b772430abd4dd3
timeCreated: 1671428509
@@ -0,0 +1,31 @@
using System;
using UnityEngine;
namespace Stary.Evo
{
public class OnCollisionExitEventTrigger : MonoBehaviour
{
public readonly EasyEvent<Collision> OnCollisionExitEvent = new EasyEvent<Collision>();
private void OnCollisionExit(Collision col)
{
OnCollisionExitEvent.Trigger(col);
}
}
public static class OnCollisionExitEventTriggerExtension
{
public static IUnRegister OnCollisionExitEvent<T>(this T self, Action<Collision> onCollisionExit)
where T : Component
{
return self.GetOrAddComponent<OnCollisionExitEventTrigger>().OnCollisionExitEvent
.Register(onCollisionExit);
}
public static IUnRegister OnCollisionExitEvent(this GameObject self, Action<Collision> onCollisionExit)
{
return self.GetOrAddComponent<OnCollisionExitEventTrigger>().OnCollisionExitEvent
.Register(onCollisionExit);
}
}
}

Some files were not shown because too many files have changed in this diff Show More