更改文件架构
This commit is contained in:
8
Packages/Common~/Scripts/Anchor.meta
Normal file
8
Packages/Common~/Scripts/Anchor.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a3c559f0cc939c341bc9ba8945565657
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
11
Packages/Common~/Scripts/Anchor/IAnchor.cs
Normal file
11
Packages/Common~/Scripts/Anchor/IAnchor.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
namespace BITKit
|
||||
{
|
||||
public interface IAnchor
|
||||
{
|
||||
Location GetLocation();
|
||||
Rigidbody GetRigidbody();
|
||||
}
|
||||
}
|
11
Packages/Common~/Scripts/Anchor/IAnchor.cs.meta
Normal file
11
Packages/Common~/Scripts/Anchor/IAnchor.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f3315cdacc30ad64fafcd1ad218ffa10
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Packages/Common~/Scripts/Animator.meta
Normal file
8
Packages/Common~/Scripts/Animator.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e39cd8e24c8ae004391619757a6b217f
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
9
Packages/Common~/Scripts/Animator/AnimationProperty.cs
Normal file
9
Packages/Common~/Scripts/Animator/AnimationProperty.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class AnimationProperty : MonoBehaviour
|
||||
{
|
||||
public static implicit operator float(AnimationProperty self) => self.value;
|
||||
public float value;
|
||||
}
|
11
Packages/Common~/Scripts/Animator/AnimationProperty.cs.meta
Normal file
11
Packages/Common~/Scripts/Animator/AnimationProperty.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a970eb848545573428bd7acd46bdac3d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
14
Packages/Common~/Scripts/Animator/AnimatorHelper.cs
Normal file
14
Packages/Common~/Scripts/Animator/AnimatorHelper.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
namespace BITKit
|
||||
{
|
||||
public class AnimatorHelper : MonoBehaviour
|
||||
{
|
||||
public Transform root;
|
||||
void OnAnimatorMove()
|
||||
{
|
||||
root?.SendMessage(nameof(OnAnimatorMove));
|
||||
}
|
||||
}
|
||||
}
|
11
Packages/Common~/Scripts/Animator/AnimatorHelper.cs.meta
Normal file
11
Packages/Common~/Scripts/Animator/AnimatorHelper.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5c77ffb9999903044809af0e80a9d4fc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
21
Packages/Common~/Scripts/Animator/AnimatorLookAt.cs
Normal file
21
Packages/Common~/Scripts/Animator/AnimatorLookAt.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
namespace BITKit
|
||||
{
|
||||
public class AnimatorLookAt : MonoBehaviour
|
||||
{
|
||||
public Animator animator;
|
||||
public float weight;
|
||||
public float headWeight;
|
||||
public float bodyWeight;
|
||||
public float eyesWeight;
|
||||
public Transform target;
|
||||
public Vector3 offset;
|
||||
void OnAnimatorIK(int layerIndex)
|
||||
{
|
||||
animator.SetLookAtWeight(weight, headWeight, bodyWeight, eyesWeight);
|
||||
animator.SetLookAtPosition(target.rotation * offset + target.position);
|
||||
}
|
||||
}
|
||||
}
|
11
Packages/Common~/Scripts/Animator/AnimatorLookAt.cs.meta
Normal file
11
Packages/Common~/Scripts/Animator/AnimatorLookAt.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 990a889ead6235645865a68b81fabf8c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
34
Packages/Common~/Scripts/Animator/AnimatorStateHelper.cs
Normal file
34
Packages/Common~/Scripts/Animator/AnimatorStateHelper.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
namespace BITKit
|
||||
{
|
||||
public class AnimatorStateHelper : StateMachineBehaviour
|
||||
{
|
||||
public string stateName;
|
||||
IGenericEvent<string> genericEvent;
|
||||
public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
|
||||
{
|
||||
EnsureValid(animator);
|
||||
genericEvent?.Invoke<string>(Constant.Animation.OnPlay, stateName);
|
||||
}
|
||||
public override void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
|
||||
{
|
||||
EnsureValid(animator);
|
||||
genericEvent?.Invoke<AnimatorStateInfo>(stateName, stateInfo);
|
||||
}
|
||||
public override void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
|
||||
{
|
||||
EnsureValid(animator);
|
||||
genericEvent?.Invoke<string>(Constant.Animation.OnPlayEnd, stateName);
|
||||
genericEvent?.Invoke<AnimatorStateInfo>(stateName, new());
|
||||
}
|
||||
void EnsureValid(Animator animator)
|
||||
{
|
||||
if (genericEvent is null)
|
||||
{
|
||||
genericEvent = animator.GetComponent<IGenericEvent<string>>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2947ebfac0dc0854397e325f85bca066
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
27
Packages/Common~/Scripts/Animator/SetAnimatorParameters.cs
Normal file
27
Packages/Common~/Scripts/Animator/SetAnimatorParameters.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using System.Threading;
|
||||
namespace BITKit
|
||||
{
|
||||
public class SetAnimatorParameters : Provider<float>
|
||||
{
|
||||
public Animator animator;
|
||||
[SubclassSelector, SerializeReference] public References floatName;
|
||||
CancellationToken cancellationToken;
|
||||
void Start()
|
||||
{
|
||||
cancellationToken = gameObject.GetCancellationTokenOnDestroy();
|
||||
}
|
||||
public override float Get()
|
||||
{
|
||||
return animator.GetFloat(floatName);
|
||||
}
|
||||
public override async void Set(float t)
|
||||
{
|
||||
await UniTask.SwitchToMainThread(cancellationToken);
|
||||
animator?.SetFloat(floatName, t);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 186b0c933823eb4449e3c6d7cb6381ed
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
103
Packages/Common~/Scripts/Animator/UnityAnimator.cs
Normal file
103
Packages/Common~/Scripts/Animator/UnityAnimator.cs
Normal file
@@ -0,0 +1,103 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Unity.Mathematics;
|
||||
namespace BITKit.Animations
|
||||
{
|
||||
public class UnityAnimator : MonoBehaviour, IAnimator
|
||||
{
|
||||
[System.Serializable]
|
||||
public record AnimatorPlayEvent
|
||||
{
|
||||
public string stateName;
|
||||
public int index;
|
||||
}
|
||||
[System.Serializable]
|
||||
public class AnimatorLayerInfo
|
||||
{
|
||||
public string stateName;
|
||||
public string fullStateName;
|
||||
public AnimatorStateInfo currentState = new();
|
||||
public event Action<string> onStateEnter;
|
||||
public event Action<string> onStateExit;
|
||||
public void OnStateEnter(string name)
|
||||
{
|
||||
onStateEnter?.Invoke(name);
|
||||
}
|
||||
public void OnStateExit(string name)
|
||||
{
|
||||
onStateExit?.Invoke(name);
|
||||
}
|
||||
}
|
||||
[Header(Constant.Header.Components)]
|
||||
public Animator animator;
|
||||
[Header(Constant.Header.State)]
|
||||
public bool isMatchingTarget;
|
||||
public AnimatorLayerInfo this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
if (layerInfos.Count <= index)
|
||||
{
|
||||
for (int i = layerInfos.Count - 1; i < index; i++)
|
||||
{
|
||||
layerInfos.Add(new());
|
||||
}
|
||||
}
|
||||
return layerInfos[index];
|
||||
}
|
||||
}
|
||||
public List<AnimatorLayerInfo> layerInfos = new();
|
||||
public void CrossFade(string name, float duration, int index = 0, float normalizedTimeOffset = 0)
|
||||
{
|
||||
animator.CrossFade(name, duration, index);
|
||||
}
|
||||
public void Play(string name, int index = -1, float normalizedTimeOffset = 0)
|
||||
{
|
||||
// Debug.Log(name);
|
||||
name = name.Replace(".", "_");
|
||||
|
||||
if (index is -1)
|
||||
{
|
||||
animator.Play(name, -1, normalizedTimeOffset);
|
||||
}
|
||||
else
|
||||
{
|
||||
animator.Play(name, index, normalizedTimeOffset);
|
||||
}
|
||||
|
||||
}
|
||||
public void OnStateEnter(int index, string name)
|
||||
{
|
||||
this[index].fullStateName = name;
|
||||
foreach (var item in name.Split("."))
|
||||
{
|
||||
name = item;
|
||||
break;
|
||||
}
|
||||
this[index].stateName = name;
|
||||
this[index].OnStateEnter(name);
|
||||
}
|
||||
public void OnStateExit(int index, string name)
|
||||
{
|
||||
this[index].OnStateExit(name);
|
||||
}
|
||||
public float3 GetRootVelocity()
|
||||
{
|
||||
return animator.velocity;
|
||||
}
|
||||
void Update()
|
||||
{
|
||||
int index = 0;
|
||||
foreach (var x in layerInfos)
|
||||
{
|
||||
x.currentState = animator.GetCurrentAnimatorStateInfo(index++);
|
||||
}
|
||||
isMatchingTarget = animator.isMatchingTarget;
|
||||
}
|
||||
}
|
||||
}
|
11
Packages/Common~/Scripts/Animator/UnityAnimator.cs.meta
Normal file
11
Packages/Common~/Scripts/Animator/UnityAnimator.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a6ac57edc8fc02840a5887fc4ad996e1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
81
Packages/Common~/Scripts/Animator/UnityAnimatorStateInfo.cs
Normal file
81
Packages/Common~/Scripts/Animator/UnityAnimatorStateInfo.cs
Normal file
@@ -0,0 +1,81 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using BITKit;
|
||||
using UnityEngine.Animations;
|
||||
using UnityEngine.UIElements;
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
using UnityEditor.UIElements;
|
||||
#endif
|
||||
namespace BITKit.Animations
|
||||
{
|
||||
public class UnityAnimatorStateInfo : StateMachineBehaviour
|
||||
{
|
||||
[SerializeReference, SubclassSelector] public References stateName;
|
||||
public IAnimator animator;
|
||||
public int index;
|
||||
public float duration;
|
||||
public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
|
||||
{
|
||||
EnsureCreation(animator);
|
||||
try
|
||||
{
|
||||
this.animator?.OnStateEnter(layerIndex, stateName);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogWarning(animator.name);
|
||||
Console.WriteLine(e);
|
||||
throw;
|
||||
}
|
||||
|
||||
}
|
||||
public override void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
|
||||
{
|
||||
EnsureCreation(animator);
|
||||
this.animator?.OnStateExit(layerIndex, stateName);
|
||||
}
|
||||
public override void OnStateMachineEnter(Animator animator, int stateMachinePathHash)
|
||||
{
|
||||
EnsureCreation(animator);
|
||||
this.animator?.OnStateEnter(index, stateName);
|
||||
}
|
||||
public override void OnStateMachineExit(Animator animator, int stateMachinePathHash)
|
||||
{
|
||||
EnsureCreation(animator);
|
||||
this.animator?.OnStateExit(index, stateName);
|
||||
}
|
||||
|
||||
public void Play()
|
||||
{
|
||||
if (duration is 0)
|
||||
{
|
||||
animator.Play(stateName);
|
||||
}
|
||||
else
|
||||
{
|
||||
animator.CrossFade(stateName, duration, index);
|
||||
}
|
||||
}
|
||||
void EnsureCreation(Animator animator)
|
||||
{
|
||||
if (this.animator is null)
|
||||
{
|
||||
this.animator = animator.GetComponent<IAnimator>();
|
||||
}
|
||||
}
|
||||
}
|
||||
/* #if UNITY_EDITOR
|
||||
[CustomEditor(typeof(UnityAnimatorStateInfo))]
|
||||
public class UnityAnimatorStateInfoInspector : BITInspector<UnityAnimatorStateInfo>
|
||||
{
|
||||
public override VisualElement CreateInspectorGUI()
|
||||
{
|
||||
var stateName = root.Create<PropertyField>();
|
||||
return root;
|
||||
}
|
||||
}
|
||||
#endif */
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b8427dbe4b1369d4facb6106e0a37fe5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Packages/Common~/Scripts/AssetBundle.meta
Normal file
8
Packages/Common~/Scripts/AssetBundle.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e543adc26ebe7eb4f8bbf91abb15f3a7
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
52
Packages/Common~/Scripts/AssetBundle/AssetBundleHelper.cs
Normal file
52
Packages/Common~/Scripts/AssetBundle/AssetBundleHelper.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using BITKit;
|
||||
using UnityEditor;
|
||||
using Sirenix.OdinInspector;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using Newtonsoft.Json;
|
||||
namespace BITKit.IO
|
||||
{
|
||||
public class AssetBundleHelper : SerializedMonoBehaviour
|
||||
{
|
||||
[Sirenix.OdinInspector.FilePath]
|
||||
public string path;
|
||||
public string header = "Header";
|
||||
public List<string> strings = new();
|
||||
[ContextMenu(nameof(Write))]
|
||||
public void Write()
|
||||
{
|
||||
Dictionary<string, string> dictionary = new();
|
||||
foreach (var _str in strings)
|
||||
{
|
||||
dictionary.Add(_str, Guid.NewGuid().ToString());
|
||||
}
|
||||
var value = strings.Select(x => new BITAsset()
|
||||
{
|
||||
Name = x,
|
||||
Buffer = Encoding.UTF8.GetBytes(x)
|
||||
}).ToList();
|
||||
value.Add(new()
|
||||
{
|
||||
Name = nameof(header),
|
||||
Buffer = Encoding.UTF8.GetBytes(header),
|
||||
});
|
||||
value.Add(new()
|
||||
{
|
||||
Name = nameof(dictionary),
|
||||
Buffer = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(dictionary)),
|
||||
});
|
||||
BITAssets.Build(path, value.ToArray());
|
||||
}
|
||||
[ContextMenu(nameof(Read))]
|
||||
public async void Read()
|
||||
{
|
||||
Debug.Log(await BITAssets.ReadTextAsync(path, nameof(header)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4e3196b4abd41a547bf666f10c336761
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"name": "BITKit.AssetBundle",
|
||||
"rootNamespace": "",
|
||||
"references": [
|
||||
"GUID:a209c53514018594f9f482516f2a6781",
|
||||
"GUID:14fe60d984bf9f84eac55c6ea033a8f4",
|
||||
"GUID:9400d40641bab5b4a9702f65bf5c6eb5"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 09142b71c256ed34a9c6cb6b06d26607
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
20
Packages/Common~/Scripts/AssetBundle/Base64Parser.cs
Normal file
20
Packages/Common~/Scripts/AssetBundle/Base64Parser.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System.IO;
|
||||
namespace BITKit
|
||||
{
|
||||
public class Base64Parser : MonoBehaviour
|
||||
{
|
||||
public string path;
|
||||
public string outputPath;
|
||||
public string json;
|
||||
[ContextMenu(nameof(Decompress))]
|
||||
public void Decompress()
|
||||
{
|
||||
var base64 = File.ReadAllText(path);
|
||||
var json = GZipHelper.GZipDecompressString(base64);
|
||||
File.WriteAllText(outputPath, json);
|
||||
}
|
||||
}
|
||||
}
|
11
Packages/Common~/Scripts/AssetBundle/Base64Parser.cs.meta
Normal file
11
Packages/Common~/Scripts/AssetBundle/Base64Parser.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 10f9b80835b42654c8411dcfb1049db6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Packages/Common~/Scripts/AudioSystem.meta
Normal file
8
Packages/Common~/Scripts/AudioSystem.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a672b877573bbc8428b542a574c94694
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
54
Packages/Common~/Scripts/AudioSystem/AudioSO.cs
Normal file
54
Packages/Common~/Scripts/AudioSystem/AudioSO.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
#if MIRROR
|
||||
using Mirror;
|
||||
#endif
|
||||
namespace BITKit
|
||||
{
|
||||
#if MIRROR
|
||||
public static class AudioSOExtensions
|
||||
{
|
||||
public static Dictionary<int, AudioSO> dictionary = new();
|
||||
[RuntimeInitializeOnLoadMethod]
|
||||
static void Reload()
|
||||
{
|
||||
dictionary.Clear();
|
||||
}
|
||||
/* public static void Write(this NetworkWriter writer, AudioClip value)
|
||||
{
|
||||
writer.Write(value.name);
|
||||
}
|
||||
public static AudioClip ReadAudioClip(this NetworkReader reader)
|
||||
{
|
||||
return Data.Get<AudioClip>(reader.ReadString());
|
||||
} */
|
||||
public static void WriteAudioSO(this NetworkWriter writer, AudioSO value)
|
||||
{
|
||||
writer.Write(value.instanceID);
|
||||
}
|
||||
public static AudioSO ReadAudioSO(this NetworkReader reader)
|
||||
{
|
||||
return AudioSOExtensions.dictionary[reader.ReadInt()];
|
||||
}
|
||||
}
|
||||
#endif
|
||||
public class AudioSO : BITKitSO
|
||||
{
|
||||
public AudioClip[] clips;
|
||||
public float distance;
|
||||
public bool loop;
|
||||
public AudioClip Get()
|
||||
{
|
||||
return clips.Random();
|
||||
}
|
||||
public int instanceID;
|
||||
public override void RegisterAssets()
|
||||
{
|
||||
instanceID = GetInstanceID();
|
||||
#if MIRROR
|
||||
AudioSOExtensions.dictionary.Add(instanceID, this);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
11
Packages/Common~/Scripts/AudioSystem/AudioSO.cs.meta
Normal file
11
Packages/Common~/Scripts/AudioSystem/AudioSO.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0ef4c5762c1803242b6592d5df3aea28
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 64
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "BITKit.AudioSystem",
|
||||
"rootNamespace": "",
|
||||
"references": [
|
||||
"GUID:a209c53514018594f9f482516f2a6781",
|
||||
"GUID:30817c1a0e6d646d99c048fc403f5979",
|
||||
"GUID:1d0b9d21c3ff546a4aa32399dfd33474",
|
||||
"GUID:14fe60d984bf9f84eac55c6ea033a8f4",
|
||||
"GUID:9400d40641bab5b4a9702f65bf5c6eb5"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 274d4ecae4648e94c8b2cee7218378a0
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
43
Packages/Common~/Scripts/AudioSystem/NetworkAudioSource.cs
Normal file
43
Packages/Common~/Scripts/AudioSystem/NetworkAudioSource.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
#if MIRROR
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Mirror;
|
||||
namespace BITKit
|
||||
{
|
||||
public class NetworkAudioSource : NetworkBehaviour
|
||||
{
|
||||
[Header(Constant.Header.Components)]
|
||||
public AudioSource audioSource;
|
||||
[Header(Constant.Header.InternalVariables)]
|
||||
IGenericEvent<string> genericEvent;
|
||||
public void Play(AudioSO so)
|
||||
{
|
||||
if (isOwned)
|
||||
CmdPlay(so);
|
||||
else if (isServer)
|
||||
RpcPlay(so);
|
||||
}
|
||||
void Start()
|
||||
{
|
||||
TryGetComponent<IGenericEvent<string>>(out genericEvent);
|
||||
}
|
||||
[Command]
|
||||
void CmdPlay(AudioSO so)
|
||||
{
|
||||
RpcPlay(so);
|
||||
}
|
||||
[ClientRpc]
|
||||
void RpcPlay(AudioSO so)
|
||||
{
|
||||
audioSource.loop = so.loop;
|
||||
audioSource.clip = so.Get();
|
||||
audioSource.Play();
|
||||
if (genericEvent is not null)
|
||||
{
|
||||
genericEvent.Invoke(so);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fb5fde05e74fd0d4986f20a023a6863e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
145
Packages/Common~/Scripts/BITAppForUnity.cs
Normal file
145
Packages/Common~/Scripts/BITAppForUnity.cs
Normal file
@@ -0,0 +1,145 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.Remoting.Contexts;
|
||||
using UnityEngine;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine.InputSystem;
|
||||
using UnityEngine.AddressableAssets;
|
||||
namespace BITKit
|
||||
{
|
||||
public class MouseNotOverGameViewException : System.Exception
|
||||
{
|
||||
public MouseNotOverGameViewException()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
public class CreateOnStart:System.Attribute
|
||||
{
|
||||
public readonly string path;
|
||||
public CreateOnStart(params string[] path)
|
||||
{
|
||||
this.path = string.Join("/", path);
|
||||
}
|
||||
}
|
||||
public class BITAppForUnity : MonoBehaviour, IDiagnostics
|
||||
{
|
||||
public struct Path
|
||||
{
|
||||
public const string Entity = nameof(Entity);
|
||||
public const string Services = nameof(Services);
|
||||
public const string Prefabs = nameof(Prefabs);
|
||||
}
|
||||
private static bool IsPlaying { get; set; }
|
||||
public static ValidHandle AllowCursor = new();
|
||||
public static ValidHandle AllowTouchSupport = new();
|
||||
public static GameObject GameObject;
|
||||
public static void ThrowIfNotPlaying()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
if (IsPlaying is false)
|
||||
{
|
||||
throw new AppIsNotPlayingException();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
public static void ThrowIfWindowNotFocus()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
if (UnityEditor.EditorWindow.mouseOverWindow.ToString() is not " (UnityEditor.GameView)")
|
||||
{
|
||||
//Debug.Log(UnityEditor.EditorWindow.mouseOverWindow);
|
||||
throw new MouseNotOverGameViewException();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
[RuntimeInitializeOnLoadMethod]
|
||||
private static async void Reload()
|
||||
{
|
||||
IsPlaying = true;
|
||||
BIT4Log.OnLog += Debug.Log;
|
||||
BIT4Log.OnWarning += Debug.LogWarning;
|
||||
BIT4Log.OnException += Debug.LogException;
|
||||
|
||||
BIT4Log.Log<BITApp>($"正在初始化");
|
||||
|
||||
BIT4Log.Log<BITApp>($"正在注册Log");
|
||||
|
||||
BIT4Log.Log<BITApp>($"正在加载配置文件");
|
||||
|
||||
var settings = Addressables.LoadAssetAsync<ScriptableObject>(nameof(BITApp.AppSettings)).WaitForCompletion() as BITSettingsSO;
|
||||
|
||||
BIT4Log.Log<BITApp>($"正在启动{Application.productName}");
|
||||
|
||||
BITApp.Start(Application.productName, settings!.appSettings);
|
||||
|
||||
AllowCursor = new();
|
||||
AllowTouchSupport = new();
|
||||
|
||||
BIT4Log.Log<BITApp>($"正在创建{nameof(BITApp)}");
|
||||
GameObject = new(nameof(BITApp));
|
||||
GameObject.AddComponent<BITAppForUnity>();
|
||||
DontDestroyOnLoad(GameObject);
|
||||
AllowCursor.AddListener(ToggleCursor);
|
||||
AllowTouchSupport.AddListener(ToggleTouchSupport);
|
||||
|
||||
foreach (var x in await ReflectionHelper.GetAttributes<CreateOnStart>())
|
||||
{
|
||||
var prefab = Addressables.LoadAssetAsync<GameObject>(x.path).WaitForCompletion();
|
||||
var instance = Instantiate(prefab);
|
||||
DontDestroyOnLoad(instance);
|
||||
}
|
||||
|
||||
BIT4Log.Log<BITApp>($"已创建{nameof(BITApp)}");
|
||||
}
|
||||
static void ToggleCursor(bool active)
|
||||
{
|
||||
Cursor.lockState = active ? CursorLockMode.None : CursorLockMode.Locked;
|
||||
Cursor.visible = active;
|
||||
}
|
||||
static void ToggleTouchSupport(bool active)
|
||||
{
|
||||
if (active)
|
||||
{
|
||||
UnityEngine.InputSystem.EnhancedTouch.EnhancedTouchSupport.Enable();
|
||||
}
|
||||
else
|
||||
{
|
||||
UnityEngine.InputSystem.EnhancedTouch.EnhancedTouchSupport.Disable();
|
||||
}
|
||||
}
|
||||
[BITCommand]
|
||||
public static async void Exit()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
UnityEditor.EditorApplication.isPlaying = false;
|
||||
await BITApp.Stop();
|
||||
#else
|
||||
await BITApp.Stop();
|
||||
Application.Quit();
|
||||
#endif
|
||||
}
|
||||
void Start()
|
||||
{
|
||||
var cancellationToken = gameObject.GetCancellationTokenOnDestroy();
|
||||
|
||||
cancellationToken.Register(Exit);
|
||||
|
||||
BIT4Log.Log<BITApp>($"已创建{nameof(BITApp)}");
|
||||
}
|
||||
void OnDestroy()
|
||||
{
|
||||
IsPlaying = false;
|
||||
}
|
||||
public string GetName()
|
||||
{
|
||||
return nameof(BITApp);
|
||||
}
|
||||
|
||||
public object GetDiagnostics()
|
||||
{
|
||||
return BITApp.State;
|
||||
}
|
||||
}
|
||||
}
|
11
Packages/Common~/Scripts/BITAppForUnity.cs.meta
Normal file
11
Packages/Common~/Scripts/BITAppForUnity.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f96142c4842a85b49b0e9cce2bef4330
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
13
Packages/Common~/Scripts/BITFramework.cs
Normal file
13
Packages/Common~/Scripts/BITFramework.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BITKit
|
||||
{
|
||||
[CreateOnStart(BITAppForUnity.Path.Services,"Framework")]
|
||||
public class BITFramework : MonoBehaviour
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
11
Packages/Common~/Scripts/BITFramework.cs.meta
Normal file
11
Packages/Common~/Scripts/BITFramework.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e8fcb06ade133b644aee2ab794f9ef0f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
3
Packages/Common~/Scripts/BITKit.Unity.asmref
Normal file
3
Packages/Common~/Scripts/BITKit.Unity.asmref
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"reference": "GUID:14fe60d984bf9f84eac55c6ea033a8f4"
|
||||
}
|
7
Packages/Common~/Scripts/BITKit.Unity.asmref.meta
Normal file
7
Packages/Common~/Scripts/BITKit.Unity.asmref.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e6698f38bbe091640b9fa934fda7abc3
|
||||
AssemblyDefinitionReferenceImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
10
Packages/Common~/Scripts/BITSettingsSO.cs
Normal file
10
Packages/Common~/Scripts/BITSettingsSO.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
namespace BITKit
|
||||
{
|
||||
public class BITSettingsSO : BITKitSO
|
||||
{
|
||||
public BITApp.AppSettings appSettings;
|
||||
}
|
||||
}
|
11
Packages/Common~/Scripts/BITSettingsSO.cs.meta
Normal file
11
Packages/Common~/Scripts/BITSettingsSO.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 299c12767e9d5184aa1f79b556abe02a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Packages/Common~/Scripts/Buff.meta
Normal file
8
Packages/Common~/Scripts/Buff.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5d2848fc2a9c5e1499ea785b1a635e38
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
27
Packages/Common~/Scripts/Buff/IBuff.cs
Normal file
27
Packages/Common~/Scripts/Buff/IBuff.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
namespace BITKit
|
||||
{
|
||||
public class SimpleBuff : IBuff
|
||||
{
|
||||
public T GetBuff<T>()
|
||||
{
|
||||
return default;
|
||||
}
|
||||
public void AddBuffListener<T>(string type, Func<T> func)
|
||||
{
|
||||
|
||||
}
|
||||
public void RemoveBuffListener<T>(string type, Func<T> func)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
public interface IBuff
|
||||
{
|
||||
T GetBuff<T>();
|
||||
void AddBuffListener<T>(string type, Func<T> func);
|
||||
}
|
||||
}
|
11
Packages/Common~/Scripts/Buff/IBuff.cs.meta
Normal file
11
Packages/Common~/Scripts/Buff/IBuff.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1a37647f77c3feb47acf9712adadb429
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Packages/Common~/Scripts/Commands.meta
Normal file
8
Packages/Common~/Scripts/Commands.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c941e0e60ae58fd499b2d1f95e406ad1
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
16
Packages/Common~/Scripts/Commands/UnityCommands.cs
Normal file
16
Packages/Common~/Scripts/Commands/UnityCommands.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Cysharp.Threading.Tasks;
|
||||
namespace BITKit
|
||||
{
|
||||
public class UnityCommands
|
||||
{
|
||||
[BITCommand]
|
||||
public static async void TimeScale(float scale)
|
||||
{
|
||||
await UniTask.SwitchToMainThread();
|
||||
Time.timeScale = scale;
|
||||
}
|
||||
}
|
||||
}
|
11
Packages/Common~/Scripts/Commands/UnityCommands.cs.meta
Normal file
11
Packages/Common~/Scripts/Commands/UnityCommands.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 85f772c236d627446937e0689a4c4ce2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Packages/Common~/Scripts/Components.meta
Normal file
8
Packages/Common~/Scripts/Components.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1a060a5c79259eb408daf2bf3a38d8e1
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
35
Packages/Common~/Scripts/Components/AutoInvoke.cs
Normal file
35
Packages/Common~/Scripts/Components/AutoInvoke.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
namespace BITKit
|
||||
{
|
||||
public class AutoInvoke : MonoBehaviour
|
||||
{
|
||||
public UnityEvent onAwake = new();
|
||||
public UnityEvent onStart = new();
|
||||
public UnityEvent onEnabled = new();
|
||||
public UnityEvent onDisabled = new();
|
||||
public UnityEvent onDestory = new();
|
||||
void Awake()
|
||||
{
|
||||
onAwake.Invoke();
|
||||
}
|
||||
void Start()
|
||||
{
|
||||
onStart.Invoke();
|
||||
}
|
||||
void OnEnabled()
|
||||
{
|
||||
onEnabled.Invoke();
|
||||
}
|
||||
void OnDisable()
|
||||
{
|
||||
onDisabled.Invoke();
|
||||
}
|
||||
void OnDestroy()
|
||||
{
|
||||
onDestory.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
11
Packages/Common~/Scripts/Components/AutoInvoke.cs.meta
Normal file
11
Packages/Common~/Scripts/Components/AutoInvoke.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9fd59b25f569f7e4faff86eb90b61136
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
17
Packages/Common~/Scripts/Components/AutoSetLayer.cs
Normal file
17
Packages/Common~/Scripts/Components/AutoSetLayer.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
namespace BITKit
|
||||
{
|
||||
public class AutoSetLayer : MonoBehaviour
|
||||
{
|
||||
public int layer;
|
||||
void Start()
|
||||
{
|
||||
GetComponentsInChildren<Transform>(true).ForEach(x=>
|
||||
{
|
||||
x.gameObject.layer=layer;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
11
Packages/Common~/Scripts/Components/AutoSetLayer.cs.meta
Normal file
11
Packages/Common~/Scripts/Components/AutoSetLayer.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 177d8bcdbd590ea4a82afeb07a27004b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
14
Packages/Common~/Scripts/Components/ClipBoardHelper.cs
Normal file
14
Packages/Common~/Scripts/Components/ClipBoardHelper.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
namespace BITKit
|
||||
{
|
||||
public class ClipBoardHelper : MonoBehaviour
|
||||
{
|
||||
public string clip;
|
||||
public void Excute()
|
||||
{
|
||||
UnityEngine.GUIUtility.systemCopyBuffer = clip;
|
||||
}
|
||||
}
|
||||
}
|
11
Packages/Common~/Scripts/Components/ClipBoardHelper.cs.meta
Normal file
11
Packages/Common~/Scripts/Components/ClipBoardHelper.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 229944dee820ee744b0066df64547f5b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
40
Packages/Common~/Scripts/Components/EffectPlayer.cs
Normal file
40
Packages/Common~/Scripts/Components/EffectPlayer.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Cysharp.Threading.Tasks;
|
||||
namespace BITKit
|
||||
{
|
||||
public class EffectPlayer : MonoBehaviour
|
||||
{
|
||||
[Header(Constant.Header.Settings)]
|
||||
[SerializeField] float duration;
|
||||
[Header(Constant.Header.Components)]
|
||||
[SerializeField] ParticleSystem[] particleSystems;
|
||||
[SerializeField] Behaviour[] behaviours;
|
||||
void Start()
|
||||
{
|
||||
particleSystems.ForEach(x => x.Stop());
|
||||
behaviours.ForEach(x => x.enabled = false);
|
||||
}
|
||||
public async void Excute()
|
||||
{
|
||||
particleSystems.ForEach(x =>
|
||||
{
|
||||
x.time = 0;
|
||||
x.Play(true);
|
||||
});
|
||||
behaviours.ForEach(x =>
|
||||
{
|
||||
x.enabled = true;
|
||||
});
|
||||
await UniTask.Delay(System.TimeSpan.FromSeconds(duration));
|
||||
if (BehaviourHelper.Actived)
|
||||
{
|
||||
behaviours.ForEach(x =>
|
||||
{
|
||||
x.enabled = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
Packages/Common~/Scripts/Components/EffectPlayer.cs.meta
Normal file
11
Packages/Common~/Scripts/Components/EffectPlayer.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 97e364d5d74ebe94da6abf95c6d42c5b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
15
Packages/Common~/Scripts/Components/ExcuteCommand.cs
Normal file
15
Packages/Common~/Scripts/Components/ExcuteCommand.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Sirenix.OdinInspector;
|
||||
namespace BITKit
|
||||
{
|
||||
public class ExcuteCommand : MonoBehaviour
|
||||
{
|
||||
public string command;
|
||||
public void Excute()
|
||||
{
|
||||
Data.Set("Cmd", command);
|
||||
}
|
||||
}
|
||||
}
|
11
Packages/Common~/Scripts/Components/ExcuteCommand.cs.meta
Normal file
11
Packages/Common~/Scripts/Components/ExcuteCommand.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 60dca0da2d1150840899e36e38ec51ce
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
25
Packages/Common~/Scripts/Components/ExcuteOnBehaviour.cs
Normal file
25
Packages/Common~/Scripts/Components/ExcuteOnBehaviour.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
namespace BITKit
|
||||
{
|
||||
public class ExcuteOnBehaviour : MonoBehaviour
|
||||
{
|
||||
public UnityEvent onAwake = new();
|
||||
public UnityEvent onStart = new();
|
||||
public UnityEvent onDestroy = new();
|
||||
void Awake()
|
||||
{
|
||||
onAwake.Invoke();
|
||||
}
|
||||
void Start()
|
||||
{
|
||||
onStart.Invoke();
|
||||
}
|
||||
void OnDestroy()
|
||||
{
|
||||
onDestroy.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f3418a9762cad0041881816917e8e3fd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
21
Packages/Common~/Scripts/Components/ExcuteOnStart.cs
Normal file
21
Packages/Common~/Scripts/Components/ExcuteOnStart.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
namespace BITKit
|
||||
{
|
||||
public class NewBehaviourScript : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
11
Packages/Common~/Scripts/Components/ExcuteOnStart.cs.meta
Normal file
11
Packages/Common~/Scripts/Components/ExcuteOnStart.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 23008cf22fffb5c479bd634e6f5854ce
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Packages/Common~/Scripts/Components/Format.meta
Normal file
8
Packages/Common~/Scripts/Components/Format.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9bef47e46bf365c40939e75d554ac2b8
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
10
Packages/Common~/Scripts/Components/Format/FormatData.cs
Normal file
10
Packages/Common~/Scripts/Components/Format/FormatData.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
namespace BITKit
|
||||
{
|
||||
public abstract class FormatData : Provider<string>
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1f6f9aa0da2cb394aa4000feb228f472
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,24 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
namespace BITKit
|
||||
{
|
||||
public class FormatDataToKeyValue : FormatData
|
||||
{
|
||||
[SubclassSelector, SerializeReference] public References key;
|
||||
public Provider output;
|
||||
Dictionary<string, string> dictionary = new();
|
||||
public override string Get()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
public override void Set(string value)
|
||||
{
|
||||
WWWForm form = new();
|
||||
form.AddField("key", key);
|
||||
form.AddField("value", value);
|
||||
|
||||
output?.Set(form);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bd91a5a5e9a329246b564d409a85fd36
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
20
Packages/Common~/Scripts/Components/IfGreater.cs
Normal file
20
Packages/Common~/Scripts/Components/IfGreater.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
namespace BITKit
|
||||
{
|
||||
public class IfGreater : Provider<float>
|
||||
{
|
||||
public float value;
|
||||
public bool inverse;
|
||||
public Provider<bool> output;
|
||||
public override float Get()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
public override void Set(float t)
|
||||
{
|
||||
output?.Set(t > value ? inverse ? false : true : false);
|
||||
}
|
||||
}
|
||||
}
|
11
Packages/Common~/Scripts/Components/IfGreater.cs.meta
Normal file
11
Packages/Common~/Scripts/Components/IfGreater.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6f92c8285609e554db8286c125d2aa39
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
20
Packages/Common~/Scripts/Components/JsonToJObject.cs
Normal file
20
Packages/Common~/Scripts/Components/JsonToJObject.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
namespace BITKit
|
||||
{
|
||||
public class JsonToJObject : Provider<string>
|
||||
{
|
||||
public Provider output;
|
||||
public override string Get()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
public override void Set(string t)
|
||||
{
|
||||
output.Set(JObject.Parse(t));
|
||||
}
|
||||
}
|
||||
}
|
11
Packages/Common~/Scripts/Components/JsonToJObject.cs.meta
Normal file
11
Packages/Common~/Scripts/Components/JsonToJObject.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1b123661c01b24345bcc273a8e9553da
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
17
Packages/Common~/Scripts/Components/LoopEvent.cs
Normal file
17
Packages/Common~/Scripts/Components/LoopEvent.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
namespace BITKit
|
||||
{
|
||||
public class LoopEvent : MonoBehaviour
|
||||
{
|
||||
public UnityEvent[] events;
|
||||
int currentIndex;
|
||||
public void Excute()
|
||||
{
|
||||
events[currentIndex].Invoke();
|
||||
currentIndex = ++currentIndex % events.Length;
|
||||
}
|
||||
}
|
||||
}
|
11
Packages/Common~/Scripts/Components/LoopEvent.cs.meta
Normal file
11
Packages/Common~/Scripts/Components/LoopEvent.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3223e246d258e0a43b87739e29e815ea
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
19
Packages/Common~/Scripts/Components/ReadFile.cs
Normal file
19
Packages/Common~/Scripts/Components/ReadFile.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Sirenix.OdinInspector;
|
||||
using System.IO;
|
||||
namespace BITKit
|
||||
{
|
||||
public class ReadFile : MonoBehaviour
|
||||
{
|
||||
[FilePath(AbsolutePath = true)]
|
||||
public string path;
|
||||
public Provider output;
|
||||
[Button]
|
||||
public void Excute()
|
||||
{
|
||||
output.Set(File.ReadAllText(path));
|
||||
}
|
||||
}
|
||||
}
|
11
Packages/Common~/Scripts/Components/ReadFile.cs.meta
Normal file
11
Packages/Common~/Scripts/Components/ReadFile.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 283c71347f110a9469d82236fe6270d7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
46
Packages/Common~/Scripts/Components/ReadFromTextAsset.cs
Normal file
46
Packages/Common~/Scripts/Components/ReadFromTextAsset.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
using UnityEditor.UIElements;
|
||||
#endif
|
||||
namespace BITKit
|
||||
{
|
||||
public class ReadFromTextAsset : BITAction
|
||||
{
|
||||
public TextAsset asset;
|
||||
public Provider output;
|
||||
public TranslateSO translateSO;
|
||||
public override void Excute()
|
||||
{
|
||||
BITAppForUnity.ThrowIfNotPlaying();
|
||||
var value = asset.text;
|
||||
if (translateSO)
|
||||
{
|
||||
value = translateSO.Get(value);
|
||||
}
|
||||
output.Set<string>(value);
|
||||
}
|
||||
}
|
||||
#if UNITY_EDITOR
|
||||
[UnityEditor.CustomEditor(typeof(ReadFromTextAsset))]
|
||||
public class ReadFromTextAssetInspector : BITInspector<ReadFromTextAsset>
|
||||
{
|
||||
public override VisualElement CreateInspectorGUI()
|
||||
{
|
||||
CreateSubTitle("TextAsset Reader");
|
||||
FillDefaultInspector(root, serializedObject, true);
|
||||
var excute = root.Create<Button>();
|
||||
|
||||
//excute.bindingPath = nameof(ReadFromTextAsset.Excute);
|
||||
|
||||
excute.text = "读取文本";
|
||||
|
||||
excute.clicked += agent.Excute;
|
||||
return root;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9e2d2c1e3b4f2634894060a904c9d7e0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
78
Packages/Common~/Scripts/Components/SaveToFile.cs
Normal file
78
Packages/Common~/Scripts/Components/SaveToFile.cs
Normal file
@@ -0,0 +1,78 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Sirenix.OdinInspector;
|
||||
using System.IO;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using BITKit.IO;
|
||||
namespace BITKit
|
||||
{
|
||||
public class SaveToFile : Provider, IAction
|
||||
{
|
||||
public bool isPersistentData;
|
||||
public bool crypto;
|
||||
[SerializeReference, SubclassSelector] public References extensions;
|
||||
[SerializeReference, SubclassSelector] public References path;
|
||||
[SerializeReference, SubclassSelector] public NameProvider nameProvider;
|
||||
|
||||
public void Excute()
|
||||
{
|
||||
string path;
|
||||
if (isPersistentData)
|
||||
{
|
||||
path = PathHelper.GetFolderPath(Utility.Path.persistentDataPath, this.path.Get());
|
||||
}
|
||||
else
|
||||
{
|
||||
path = PathHelper.GetFolderPath(Utility.Path.dataPath, this.path);
|
||||
}
|
||||
BITApp.Open(path);
|
||||
}
|
||||
|
||||
public override async void Set<T>(T obj)
|
||||
{
|
||||
await UniTask.SwitchToThreadPool();
|
||||
|
||||
var path = GetPath();
|
||||
BIT4Log.Log<SaveToFile>($"正在保存文件为:{path}");
|
||||
switch (obj)
|
||||
{
|
||||
case string _string:
|
||||
try
|
||||
{
|
||||
if (crypto)
|
||||
{
|
||||
_string = GZipHelper.GZipCompressString(_string);
|
||||
}
|
||||
File.WriteAllText(path, _string);
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
Debug.LogWarning(e);
|
||||
}
|
||||
break;
|
||||
case BITAssets assets:
|
||||
assets.Build(path);
|
||||
break;
|
||||
case byte[] _bytes:
|
||||
File.WriteAllBytes(path, _bytes);
|
||||
break;
|
||||
}
|
||||
}
|
||||
string GetPath()
|
||||
{
|
||||
string path;
|
||||
var fileName = nameProvider.GetName(null, extensions);
|
||||
if (isPersistentData)
|
||||
{
|
||||
path = PathHelper.GetFilePath(Utility.Path.persistentDataPath, this.path.Get(), fileName);
|
||||
}
|
||||
else
|
||||
{
|
||||
path = PathHelper.GetFilePath(Utility.Path.dataPath, this.path, fileName);
|
||||
}
|
||||
return path;
|
||||
}
|
||||
}
|
||||
}
|
11
Packages/Common~/Scripts/Components/SaveToFile.cs.meta
Normal file
11
Packages/Common~/Scripts/Components/SaveToFile.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a11bb2c42173d0f4fa51765c7b064492
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
18
Packages/Common~/Scripts/Components/SetColor.cs
Normal file
18
Packages/Common~/Scripts/Components/SetColor.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
namespace BITKit
|
||||
{
|
||||
public class SetColor : Provider<Color>
|
||||
{
|
||||
public MeshRenderer meshRenderer;
|
||||
public override Color Get()
|
||||
{
|
||||
return meshRenderer.sharedMaterial.color;
|
||||
}
|
||||
public override void Set(Color t)
|
||||
{
|
||||
meshRenderer.sharedMaterial.color = t; ;
|
||||
}
|
||||
}
|
||||
}
|
11
Packages/Common~/Scripts/Components/SetColor.cs.meta
Normal file
11
Packages/Common~/Scripts/Components/SetColor.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 91ebe8c4973b3fb4b8a176fa8966506b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
44
Packages/Common~/Scripts/Components/SetRenderScale.cs
Normal file
44
Packages/Common~/Scripts/Components/SetRenderScale.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering.Universal;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace BITKit
|
||||
{
|
||||
public class SetRenderScale : Provider<float>
|
||||
{
|
||||
public UniversalRenderPipelineAsset asset;
|
||||
public override float Get()
|
||||
{
|
||||
return asset.renderScale;
|
||||
}
|
||||
public override void Set(float t)
|
||||
{
|
||||
asset.renderScale = t;
|
||||
}
|
||||
}
|
||||
#if UNITY_EDITOR
|
||||
[UnityEditor.CustomEditor(typeof(SetRenderScale))]
|
||||
public class SetRenderScaleInspector : BITInspector<SetRenderScale>
|
||||
{
|
||||
public override VisualElement CreateInspectorGUI()
|
||||
{
|
||||
FillDefaultInspector(root, serializedObject, true);
|
||||
|
||||
var slider = root.Create<Slider>();
|
||||
slider.SetValueWithoutNotify(agent.asset.renderScale);
|
||||
slider.label = "渲染倍数";
|
||||
slider.showInputField=true;
|
||||
slider.RegisterValueChangedCallback(OnValueUpdate);
|
||||
|
||||
return root;
|
||||
}
|
||||
void OnValueUpdate(ChangeEvent<float> newValueEvent)
|
||||
{
|
||||
BITAppForUnity.ThrowIfNotPlaying();
|
||||
agent.Set(newValueEvent.newValue);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
11
Packages/Common~/Scripts/Components/SetRenderScale.cs.meta
Normal file
11
Packages/Common~/Scripts/Components/SetRenderScale.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2918d778bb9c84a40b3ed0f47a28676f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
46
Packages/Common~/Scripts/Components/SetRotation.cs
Normal file
46
Packages/Common~/Scripts/Components/SetRotation.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
namespace BITKit
|
||||
{
|
||||
public class SetRotation : Provider
|
||||
{
|
||||
public Transform root;
|
||||
public bool isLocal;
|
||||
public Vector3 weight;
|
||||
public Vector3 defaultEulur;
|
||||
void Awake()
|
||||
{
|
||||
defaultEulur = isLocal ? transform.localEulerAngles : transform.eulerAngles;
|
||||
}
|
||||
public override void Set<T>(T obj)
|
||||
{
|
||||
switch (obj)
|
||||
{
|
||||
case float _float:
|
||||
_SetRotation(Quaternion.Euler(defaultEulur + weight * _float));
|
||||
break;
|
||||
case Vector3 _vector3:
|
||||
_SetRotation(Quaternion.Euler(_vector3));
|
||||
break;
|
||||
case Quaternion quaternion:
|
||||
_SetRotation(quaternion);
|
||||
break;
|
||||
}
|
||||
}
|
||||
void _SetRotation(Quaternion eulur)
|
||||
{
|
||||
if (root)
|
||||
{
|
||||
if (isLocal)
|
||||
{
|
||||
root.localRotation = eulur;
|
||||
}
|
||||
else
|
||||
{
|
||||
root.rotation = eulur;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
Packages/Common~/Scripts/Components/SetRotation.cs.meta
Normal file
11
Packages/Common~/Scripts/Components/SetRotation.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a2b844e702334674a9bad5155edd0c56
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
18
Packages/Common~/Scripts/Components/ShowDictionary.cs
Normal file
18
Packages/Common~/Scripts/Components/ShowDictionary.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
namespace BITKit
|
||||
{
|
||||
public class ShowDictionary : Provider<IDictionary<string, string>>
|
||||
{
|
||||
public IDictionary<string, string> dictionary = new Dictionary<string, string>();
|
||||
public override IDictionary<string, string> Get()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
public override void Set(IDictionary<string, string> t)
|
||||
{
|
||||
dictionary = t;
|
||||
}
|
||||
}
|
||||
}
|
11
Packages/Common~/Scripts/Components/ShowDictionary.cs.meta
Normal file
11
Packages/Common~/Scripts/Components/ShowDictionary.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7b796a99e61404f4e99cc0e91f2a15d3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
45
Packages/Common~/Scripts/Components/ShowProfiler.cs
Normal file
45
Packages/Common~/Scripts/Components/ShowProfiler.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
namespace BITKit
|
||||
{
|
||||
public class ShowProfiler : BITBehavior, IDiagnostics
|
||||
{
|
||||
[Header(Constant.Header.Settings)]
|
||||
[SubclassSelector, SerializeReference] public References pingAddress;
|
||||
[Header(Constant.Header.Output)]
|
||||
public Provider fpsOutput;
|
||||
public Provider pingOutput;
|
||||
DeltaTimer timer = new();
|
||||
Ping ping;
|
||||
[Header(Constant.Header.InternalVariables)]
|
||||
public int frameRate;
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
timer.Update();
|
||||
frameRate = timer;
|
||||
fpsOutput.Set((string)timer);
|
||||
if (pingOutput is not null && (ping is null || ping.isDone))
|
||||
{
|
||||
if (ping is not null && ping.isDone)
|
||||
{
|
||||
pingOutput.Set(ping.time.ToString());
|
||||
}
|
||||
ping = new(pingAddress);
|
||||
}
|
||||
}
|
||||
public override string GetName()
|
||||
{
|
||||
return nameof(ShowProfiler);
|
||||
}
|
||||
public override object GetDiagnostics()
|
||||
{
|
||||
Dictionary<string, string> dictioanry = new();
|
||||
dictioanry.Add(nameof(fpsOutput), fpsOutput ? "有效" : "未定义");
|
||||
dictioanry.Add(nameof(pingOutput), pingOutput ? "有效" : "未定义");
|
||||
dictioanry.Add("FPS", timer);
|
||||
return dictioanry;
|
||||
}
|
||||
}
|
||||
}
|
11
Packages/Common~/Scripts/Components/ShowProfiler.cs.meta
Normal file
11
Packages/Common~/Scripts/Components/ShowProfiler.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 041838da66546b241a2c3b928442dbe7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
18
Packages/Common~/Scripts/Components/ShowTime.cs
Normal file
18
Packages/Common~/Scripts/Components/ShowTime.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Sirenix.OdinInspector;
|
||||
namespace BITKit
|
||||
{
|
||||
public class ShowTime : BITBehavior
|
||||
{
|
||||
[SerializeReference,SubclassSelector]public References timeFormat;
|
||||
public Provider output;
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
output?.Set(timeFormat is not null ? DateTime.Now.ToString(timeFormat) : DateTime.Now.ToString());
|
||||
}
|
||||
}
|
||||
}
|
11
Packages/Common~/Scripts/Components/ShowTime.cs.meta
Normal file
11
Packages/Common~/Scripts/Components/ShowTime.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e988e2142e586b643b27ced60e5c1371
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
15
Packages/Common~/Scripts/Components/ShowVersion.cs
Normal file
15
Packages/Common~/Scripts/Components/ShowVersion.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Sirenix.OdinInspector;
|
||||
namespace BITKit
|
||||
{
|
||||
public class ShowVersion : MonoBehaviour
|
||||
{
|
||||
public Provider output;
|
||||
void Start()
|
||||
{
|
||||
output?.Set(Application.version);
|
||||
}
|
||||
}
|
||||
}
|
11
Packages/Common~/Scripts/Components/ShowVersion.cs.meta
Normal file
11
Packages/Common~/Scripts/Components/ShowVersion.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8bf0407384ab0424f8ff64ba231e02ef
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
360
Packages/Common~/Scripts/Components/SimpleCameraLook.cs
Normal file
360
Packages/Common~/Scripts/Components/SimpleCameraLook.cs
Normal file
@@ -0,0 +1,360 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
using Cinemachine;
|
||||
using Cinemachine.Utility;
|
||||
using TouchPhase = UnityEngine.InputSystem.TouchPhase;
|
||||
using UnityEngine.InputSystem.EnhancedTouch;
|
||||
using Touch = UnityEngine.InputSystem.EnhancedTouch.Touch;
|
||||
using BITKit.IO;
|
||||
using Newtonsoft.Json;
|
||||
using System.IO;
|
||||
using Cysharp.Threading.Tasks;
|
||||
namespace BITKit
|
||||
{
|
||||
public class SimpleCameraLook : MonoBehaviour
|
||||
{
|
||||
private string fileName => Path.Combine(Utility.Path.persistentDataPath, gameObject.scene.name, $"{gameObject.GetInstanceID()}.bit");
|
||||
public enum State
|
||||
{
|
||||
Mouse,
|
||||
Touchscreen,
|
||||
}
|
||||
[Header(Constant.Header.Gameobjects)]
|
||||
public Transform cameraRoot;
|
||||
public CinemachineVirtualCamera virtualCamera;
|
||||
[Header(Constant.Header.Settings)]
|
||||
public TransformMode touchMode;
|
||||
[Header(Constant.Header.Settings)]
|
||||
public InputActionReference viewAction;
|
||||
public InputActionReference movementAction;
|
||||
public InputActionReference adsAction;
|
||||
public InputActionReference entryAction;
|
||||
public InputActionReference entryMoveAction;
|
||||
public InputActionGroup inputGroup = new();
|
||||
[Header(Constant.Header.Settings)]
|
||||
public float minEntrySqrMagnitude = 1;
|
||||
public LayerMask layerMask;
|
||||
[Header(Constant.Header.Settings)]
|
||||
public AnimationCurve scollCurve = new();
|
||||
public AnimationCurve moveCurve = new();
|
||||
public AnimationCurve touchMoveCurve = new();
|
||||
public Vector2 cameraDistanceLimit = new(1, 64);
|
||||
[Header(Constant.Header.Debug)]
|
||||
public int touchesCount;
|
||||
public bool isParallelVector;
|
||||
[Header(Constant.Header.InternalVariables)]
|
||||
public Vector3 lookInput;
|
||||
public Vector3 moveVector;
|
||||
public ValidHandle freeLooking = new();
|
||||
public ValidHandle moving = new();
|
||||
private Cinemachine3rdPersonFollow tpv;
|
||||
private Location startLocation;
|
||||
private Location savedLocation;
|
||||
private float savedDistance;
|
||||
private float startDistance;
|
||||
private CinemachineBrain _brain;
|
||||
public void Reset()
|
||||
{
|
||||
lookInput = startLocation.position.TransientRotationAxis();
|
||||
cameraRoot.position = startLocation;
|
||||
tpv.CameraDistance = startDistance;
|
||||
}
|
||||
public void DisableInput(bool disable)
|
||||
{
|
||||
inputGroup.allowInput.SetDisableElements(nameof(DisableInput), disable);
|
||||
}
|
||||
public void SetTouchMode(int index)
|
||||
{
|
||||
SetTouchMode((TransformMode)index);
|
||||
}
|
||||
public void SetTouchMode(TransformMode mode)
|
||||
{
|
||||
touchMode = mode;
|
||||
}
|
||||
public void Align(Transform target)
|
||||
{
|
||||
if (target.TryGetComponent<SimpleCameraLook>(out var x))
|
||||
{
|
||||
cameraRoot.position = x.cameraRoot.position;
|
||||
//lookInput = x.lookInput;
|
||||
lookInput = x.cameraRoot.rotation.eulerAngles.TransientRotationAxis();
|
||||
if (x.tpv)
|
||||
tpv.CameraDistance = x.tpv.CameraDistance;
|
||||
}
|
||||
else if (target.TryGetComponent<CinemachineVirtualCamera>(out var vCam))
|
||||
{
|
||||
cameraRoot.position = vCam.Follow.position;
|
||||
lookInput = vCam.LookAt.rotation.eulerAngles.TransientRotationAxis();
|
||||
var e = vCam.GetCinemachineComponent<Cinemachine3rdPersonFollow>();
|
||||
if (e)
|
||||
{
|
||||
tpv.CameraDistance = e.CameraDistance;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
cameraRoot.position = target.position;
|
||||
lookInput = target.eulerAngles.TransientRotationAxis();
|
||||
}
|
||||
}
|
||||
public void SaveLocation()
|
||||
{
|
||||
savedLocation = new(cameraRoot);
|
||||
savedDistance = tpv.CameraDistance;
|
||||
BITAssets.Build(
|
||||
PathHelper.GetFilePath(fileName),
|
||||
new IAsset[]
|
||||
{
|
||||
new BITAsset(nameof(savedLocation),JsonUtility.ToJson(savedLocation)),
|
||||
new BITAsset(nameof(savedDistance),JsonConvert.SerializeObject(savedDistance)),
|
||||
}
|
||||
);
|
||||
}
|
||||
public void LoadLocation()
|
||||
{
|
||||
lookInput = savedLocation.rotation.eulerAngles.TransientRotationAxis();
|
||||
cameraRoot.position = savedLocation;
|
||||
tpv.CameraDistance = savedDistance;
|
||||
}
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
freeLooking.AddListener(OnFreeLook);
|
||||
tpv = virtualCamera.GetCinemachineComponent<Cinemachine3rdPersonFollow>();
|
||||
|
||||
savedLocation = startLocation = new(cameraRoot);
|
||||
savedDistance = startDistance = tpv.CameraDistance;
|
||||
|
||||
inputGroup.RegisterCallback(viewAction, OnView);
|
||||
inputGroup.RegisterCallback(movementAction, OnMovement);
|
||||
inputGroup.RegisterCallback(adsAction, OnAds);
|
||||
inputGroup.RegisterCallback(entryAction, OnEntry);
|
||||
inputGroup.RegisterCallback(entryMoveAction, OnEntryMoveAction);
|
||||
|
||||
if (Camera.main != null) _brain = Camera.main.GetComponent<CinemachineBrain>();
|
||||
}
|
||||
|
||||
private async void Start()
|
||||
{
|
||||
var fileName = this.fileName;
|
||||
await UniTask.SwitchToThreadPool();
|
||||
if (File.Exists(fileName))
|
||||
{
|
||||
savedLocation = BITAssets.Read<Location>(fileName, nameof(savedLocation));
|
||||
savedDistance = BITAssets.Read<float>(fileName, nameof(savedDistance));
|
||||
}
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
SetEnabled(true);
|
||||
lookInput = cameraRoot.eulerAngles.TransientRotationAxis();
|
||||
|
||||
freeLooking.RemoveDisableElements(this);
|
||||
|
||||
virtualCamera.enabled = true;
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
SetEnabled(false);
|
||||
freeLooking.AddDisableElements(this);
|
||||
|
||||
virtualCamera.enabled = false;
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
inputGroup.Dispose();
|
||||
}
|
||||
|
||||
private void SetEnabled(bool enabled)
|
||||
{
|
||||
//BIT4Log.Log<SimpleCameraLook>($"正在设置输入状态:{enabled}");
|
||||
BITAppForUnity.AllowTouchSupport.SetElements(this, enabled);
|
||||
inputGroup.allowInput.SetElements(this, enabled);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
//var debuger = DI.Get<IDebuger>();
|
||||
var playerConfig = PlayerConfig.singleton;
|
||||
var sensitivity = playerConfig.touchSensitivity;
|
||||
|
||||
//debuger.Log(nameof(Touch.activeTouches), Touch.activeTouches.Count.ToString());
|
||||
touchesCount = Touch.activeTouches.Count;
|
||||
|
||||
if (Mouse.current.leftButton.wasPressedThisFrame)
|
||||
{
|
||||
var ray = Camera.main.ScreenPointToRay(Mouse.current.position.ReadValue());
|
||||
if (Physics.Raycast(ray, out var raycast, 256, layerMask))
|
||||
{
|
||||
cameraRoot.position = raycast.point;
|
||||
}
|
||||
}
|
||||
|
||||
if (_brain)
|
||||
{
|
||||
inputGroup.allowInput.SetDisableElements(nameof(CinemachineBrain),virtualCamera != (CinemachineVirtualCamera)_brain.ActiveVirtualCamera);
|
||||
}
|
||||
}
|
||||
|
||||
private void LateUpdate()
|
||||
{
|
||||
lookInput.x = Mathf.Clamp(lookInput.x, -80, 80);
|
||||
var newRotation = Quaternion.Euler(lookInput);
|
||||
cameraRoot.rotation = Quaternion.Lerp(cameraRoot.rotation, newRotation, 48 * Time.deltaTime);
|
||||
var offset = cameraRoot.localRotation * moveVector;
|
||||
cameraRoot.localPosition -= offset * Time.deltaTime;
|
||||
}
|
||||
|
||||
private void OnView(InputAction.CallbackContext context)
|
||||
{
|
||||
var playerConfig = PlayerConfig.singleton;
|
||||
var sensitivity = playerConfig.sensitivity * playerConfig.m_yaw;
|
||||
var delta = context.ReadValue<Vector2>();
|
||||
switch (context.control.device)
|
||||
{
|
||||
case Mouse mouse:
|
||||
if (freeLooking && !moving)
|
||||
{
|
||||
lookInput.x -= delta.y * sensitivity;
|
||||
lookInput.y += delta.x * sensitivity;
|
||||
}
|
||||
break;
|
||||
case Touchscreen touchscreen:
|
||||
/* lookInput.x -= delta.y * sensitivity;
|
||||
lookInput.y += delta.x * sensitivity; */
|
||||
switch (touchMode)
|
||||
{
|
||||
case TransformMode.Move:
|
||||
break;
|
||||
case TransformMode.Rotate:
|
||||
lookInput.x -= delta.y * sensitivity;
|
||||
lookInput.y += delta.x * sensitivity;
|
||||
moveVector = default;
|
||||
break;
|
||||
case TransformMode.Scale:
|
||||
break;
|
||||
}
|
||||
if (touchMode is TransformMode.Scale)
|
||||
{
|
||||
OnAds(context);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnAds(InputAction.CallbackContext context)
|
||||
{
|
||||
try
|
||||
{
|
||||
BITAppForUnity.ThrowIfWindowNotFocus();
|
||||
switch (context.control.device)
|
||||
{
|
||||
case Mouse mouse:
|
||||
OnAds(context.ReadValue<Vector2>().y);
|
||||
break;
|
||||
case Touchscreen touchscreen:
|
||||
/* lookInput.x -= delta.y * sensitivity;
|
||||
lookInput.y += delta.x * sensitivity; */
|
||||
switch (touchMode)
|
||||
{
|
||||
case TransformMode.Move:
|
||||
break;
|
||||
case TransformMode.Rotate:
|
||||
moveVector = default;
|
||||
break;
|
||||
case TransformMode.Scale:
|
||||
OnAds(context.ReadValue<Vector2>().y);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (MouseNotOverGameViewException)
|
||||
{
|
||||
|
||||
}
|
||||
catch (System.Exception)
|
||||
{
|
||||
|
||||
throw;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void OnAds(float delta)
|
||||
{
|
||||
var newDistance = tpv.CameraDistance -
|
||||
delta * Time.deltaTime * scollCurve.Evaluate(tpv.CameraDistance);
|
||||
tpv.CameraDistance = Mathf.Clamp(newDistance, cameraDistanceLimit.x, cameraDistanceLimit.y);
|
||||
}
|
||||
|
||||
private void OnFreeLook(bool active)
|
||||
{
|
||||
BITAppForUnity.AllowCursor.SetDisableElements(this, active);
|
||||
}
|
||||
|
||||
private void OnEntry(InputAction.CallbackContext context)
|
||||
{
|
||||
if (context.started)
|
||||
{
|
||||
var delta = viewAction.action.ReadValue<Vector2>();
|
||||
if (delta.sqrMagnitude > minEntrySqrMagnitude)
|
||||
freeLooking.AddElement(this);
|
||||
}
|
||||
else if (context.canceled)
|
||||
{
|
||||
freeLooking.RemoveElement(this);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnMovement(InputAction.CallbackContext context)
|
||||
{
|
||||
switch (context.control.device)
|
||||
{
|
||||
case Mouse mouse:
|
||||
if (moving && freeLooking)
|
||||
{
|
||||
moveVector = context.ReadValue<Vector2>() * moveCurve.Evaluate(tpv.CameraDistance);
|
||||
}
|
||||
break;
|
||||
case Touchscreen touchscreen:
|
||||
/* lookInput.x -= delta.y * sensitivity;
|
||||
lookInput.y += delta.x * sensitivity; */
|
||||
switch (touchMode)
|
||||
{
|
||||
case TransformMode.Move:
|
||||
moveVector = context.ReadValue<Vector2>() * moveCurve.Evaluate(tpv.CameraDistance);
|
||||
break;
|
||||
case TransformMode.Rotate:
|
||||
break;
|
||||
case TransformMode.Scale:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (context.canceled)
|
||||
{
|
||||
moveVector = default;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnEntryMoveAction(InputAction.CallbackContext context)
|
||||
{
|
||||
|
||||
if (context.started)
|
||||
{
|
||||
moving.AddElement(this);
|
||||
}
|
||||
else if (context.canceled)
|
||||
{
|
||||
moving.RemoveElement(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
Packages/Common~/Scripts/Components/SimpleCameraLook.cs.meta
Normal file
11
Packages/Common~/Scripts/Components/SimpleCameraLook.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 462eee3907e22aa4bb427eca250554bc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
37
Packages/Common~/Scripts/Components/StopWatcher.cs
Normal file
37
Packages/Common~/Scripts/Components/StopWatcher.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
namespace BITKit
|
||||
{
|
||||
public class StopWatcher : MonoBehaviour
|
||||
{
|
||||
[SerializeReference, SubclassSelector] public References timeFormat;
|
||||
public bool autoStart;
|
||||
public Provider output;
|
||||
bool started;
|
||||
DateTime dateTime = new();
|
||||
void Start()
|
||||
{
|
||||
if (autoStart)
|
||||
{
|
||||
started = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (started)
|
||||
{
|
||||
dateTime = dateTime.AddSeconds(Time.deltaTime);
|
||||
var timeStr = dateTime.ToString();
|
||||
if (timeFormat is not null)
|
||||
{
|
||||
timeStr = dateTime.ToString(timeFormat);
|
||||
}
|
||||
output.Set(timeStr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
Packages/Common~/Scripts/Components/StopWatcher.cs.meta
Normal file
11
Packages/Common~/Scripts/Components/StopWatcher.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a6f601b83c9c08c4daa9084629c00c4b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
21
Packages/Common~/Scripts/Components/StringProviders.cs
Normal file
21
Packages/Common~/Scripts/Components/StringProviders.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
namespace BITKit
|
||||
{
|
||||
public class StringProviders : Provider<string>
|
||||
{
|
||||
public Provider<string>[] providers;
|
||||
public override string Get()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
public override void Set(string t)
|
||||
{
|
||||
foreach (var provider in providers)
|
||||
{
|
||||
provider.Set(t);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
Packages/Common~/Scripts/Components/StringProviders.cs.meta
Normal file
11
Packages/Common~/Scripts/Components/StringProviders.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 32969b2e57758cf46865f70a0dcd0bb5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
29
Packages/Common~/Scripts/Components/TranslateComponent.cs
Normal file
29
Packages/Common~/Scripts/Components/TranslateComponent.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Cysharp.Threading.Tasks;
|
||||
namespace BITKit
|
||||
{
|
||||
public sealed class TranslateComponent : Provider<string>
|
||||
{
|
||||
[Header(Constant.Header.Settings)]
|
||||
public TranslateSO so;
|
||||
public bool async;
|
||||
[Header(Constant.Header.Output)]
|
||||
public Provider output;
|
||||
[TextArea]
|
||||
public string result;
|
||||
public override string Get()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
public override async void Set(string t)
|
||||
{
|
||||
if (async)
|
||||
{
|
||||
await UniTask.SwitchToThreadPool();
|
||||
}
|
||||
output.Set(result = so.Get(t, false));
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 754334b4be9ed424292fa6f390107d10
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user