更改文件架构

This commit is contained in:
CortexCore
2023-06-07 18:38:07 +08:00
parent 93292b1a59
commit ed84166723
720 changed files with 297 additions and 65 deletions

View File

@@ -0,0 +1,28 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace BITKit
{
public abstract class Mono : MonoBehaviour, IMonoProxy
{
protected virtual void Awake()
{
}
protected virtual void Start()
{
}
protected virtual void Update()
{
}
protected virtual void FixedUpdate()
{
}
protected virtual void LateUpdate()
{
}
protected virtual void OnDestroy()
{
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 13003171a12d81c4eaee9c516471992a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,99 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Cysharp.Threading.Tasks;
using System;
using System.Threading;
using UnityEngine.Events;
using UnityEngine.UIElements;
#if UNITY_EDITOR
using UnityEditor;
using UnityEditor.UIElements;
#endif
namespace BITKit
{
[System.Serializable]
public struct InvokeMonoAction : IAction
{
public MonoBehaviour monoBehaviour;
public void Excute()
{
(monoBehaviour as IAction).Excute();
}
}
[System.Serializable]
public struct InvokeUnityEvent : IAction
{
public UnityEvent unityEvent;
public void Excute()
{
unityEvent.Invoke();
}
}
[System.Serializable]
public struct ExitApplation : IAction
{
public void Excute()
{
BITAppForUnity.Exit();
}
}
[System.Serializable]
public struct DebugText : IAction
{
[SerializeReference, SubclassSelector] public References text;
public void Excute()
{
Debug.Log(text);
}
}
public class MonoAction : MonoBehaviour, IAction
{
[SerializeReference, SubclassSelector] public List<IAction> actions;
CancellationToken cancellationToken;
void Start()
{
cancellationToken = gameObject.GetCancellationTokenOnDestroy();
}
public async void Excute()
{
try
{
await UniTask.SwitchToMainThread(cancellationToken);
foreach (var x in actions)
{
x.Excute();
}
}
catch (OperationCanceledException)
{
}
catch (System.Exception)
{
throw;
}
}
}
#if UNITY_EDITOR
[CustomEditor(typeof(MonoAction))]
public class MonoActinoInspector : BITInspector<MonoAction>
{
public override VisualElement CreateInspectorGUI()
{
CreateSubTitle("Settings");
var actions = root.Create<PropertyField>();
var button = root.Create<Button>();
actions.bindingPath = nameof(MonoAction.actions);
button.text = "Excute";
button.clicked += agent.Excute;
return root;
}
}
#endif
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d7c307dd96b0ae44db43b135d73ae46a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,40 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
namespace BITKit
{
public class MonoEvents : Mono
{
public UnityEvent OnAwake = new();
public UnityEvent OnStart = new();
public UnityEvent<float> OnUpdate = new();
public UnityEvent<float> OnFixexUpdate = new();
public UnityEvent<float> OnLateUpdate = new();
public UnityEvent OnDestroyComponent = new();
protected override void Awake()
{
OnAwake.Invoke();
}
protected override void Start()
{
OnStart.Invoke();
}
protected override void Update()
{
OnUpdate.Invoke(Time.deltaTime);
}
protected override void FixedUpdate()
{
OnFixexUpdate.Invoke(Time.deltaTime);
}
protected override void LateUpdate()
{
OnLateUpdate.Invoke(Time.deltaTime);
}
protected override void OnDestroy()
{
OnDestroyComponent.Invoke();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1e8903c9eaac98b4788b121973994a29
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: