Compare commits
20 Commits
ee1171d3e3
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| ab60b35be2 | |||
| 1436080fd6 | |||
| be4cc888b5 | |||
| 04ad260824 | |||
| d6336faed0 | |||
| 0f831b8862 | |||
| 3714fa87e7 | |||
| 425198ab96 | |||
| 5a02de8c9c | |||
| 60df9a93aa | |||
| 39a051eacf | |||
| 0ca799ca34 | |||
| 65a5775647 | |||
| 88c15a43f2 | |||
| 8ed4f93e24 | |||
| 0c79cd874e | |||
| f724058cea | |||
| a3ea09c2a9 | |||
| ddf38a88b6 | |||
| ae9793d6f9 |
8
Assets/Assets/Resources/Volume.meta
Normal file
8
Assets/Assets/Resources/Volume.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 09bf3e667692a1341a327b7560df35aa
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
294
Assets/Assets/Resources/Volume/Default.asset
Normal file
294
Assets/Assets/Resources/Volume/Default.asset
Normal file
@@ -0,0 +1,294 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &-6930818438622466647
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 3
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 6bd486065ce11414fa40e631affc4900, type: 3}
|
||||
m_Name: ProbeVolumesOptions
|
||||
m_EditorClassIdentifier: Unity.RenderPipelines.Core.Runtime::UnityEngine.Rendering.ProbeVolumesOptions
|
||||
active: 1
|
||||
normalBias:
|
||||
m_OverrideState: 0
|
||||
m_Value: 0.05
|
||||
viewBias:
|
||||
m_OverrideState: 0
|
||||
m_Value: 0.1
|
||||
scaleBiasWithMinProbeDistance:
|
||||
m_OverrideState: 0
|
||||
m_Value: 0
|
||||
samplingNoise:
|
||||
m_OverrideState: 0
|
||||
m_Value: 0.1
|
||||
animateSamplingNoise:
|
||||
m_OverrideState: 0
|
||||
m_Value: 1
|
||||
leakReductionMode:
|
||||
m_OverrideState: 0
|
||||
m_Value: 2
|
||||
minValidDotProductValue:
|
||||
m_OverrideState: 0
|
||||
m_Value: 0.1
|
||||
occlusionOnlyReflectionNormalization:
|
||||
m_OverrideState: 0
|
||||
m_Value: 1
|
||||
intensityMultiplier:
|
||||
m_OverrideState: 0
|
||||
m_Value: 1
|
||||
skyOcclusionIntensityMultiplier:
|
||||
m_OverrideState: 0
|
||||
m_Value: 1
|
||||
worldOffset:
|
||||
m_OverrideState: 0
|
||||
m_Value: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &-3285242745950591362
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 3
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 0b2db86121404754db890f4c8dfe81b2, type: 3}
|
||||
m_Name: Bloom
|
||||
m_EditorClassIdentifier:
|
||||
active: 1
|
||||
skipIterations:
|
||||
m_OverrideState: 0
|
||||
m_Value: 1
|
||||
threshold:
|
||||
m_OverrideState: 0
|
||||
m_Value: 0.9
|
||||
intensity:
|
||||
m_OverrideState: 0
|
||||
m_Value: 0
|
||||
scatter:
|
||||
m_OverrideState: 0
|
||||
m_Value: 0.7
|
||||
clamp:
|
||||
m_OverrideState: 0
|
||||
m_Value: 65472
|
||||
tint:
|
||||
m_OverrideState: 1
|
||||
m_Value: {r: 0, g: 0, b: 0, a: 1}
|
||||
highQualityFiltering:
|
||||
m_OverrideState: 0
|
||||
m_Value: 0
|
||||
downscale:
|
||||
m_OverrideState: 0
|
||||
m_Value: 0
|
||||
maxIterations:
|
||||
m_OverrideState: 0
|
||||
m_Value: 6
|
||||
dirtTexture:
|
||||
m_OverrideState: 0
|
||||
m_Value: {fileID: 0}
|
||||
dimension: 1
|
||||
dirtIntensity:
|
||||
m_OverrideState: 0
|
||||
m_Value: 0
|
||||
--- !u!114 &-2940743133789450860
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 3
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: a074ec59f6e910b4e8c49f57e56cf95a, type: 3}
|
||||
m_Name: VolumetricFogVolumeComponent
|
||||
m_EditorClassIdentifier:
|
||||
active: 1
|
||||
distance:
|
||||
m_OverrideState: 0
|
||||
m_Value: 64
|
||||
baseHeight:
|
||||
m_OverrideState: 0
|
||||
m_Value: 0
|
||||
maximumHeight:
|
||||
m_OverrideState: 0
|
||||
m_Value: 50
|
||||
enableGround:
|
||||
m_OverrideState: 0
|
||||
m_Value: 0
|
||||
groundHeight:
|
||||
m_OverrideState: 0
|
||||
m_Value: 0
|
||||
density:
|
||||
m_OverrideState: 0
|
||||
m_Value: 0.2
|
||||
attenuationDistance:
|
||||
m_OverrideState: 0
|
||||
m_Value: 128
|
||||
enableAPVContribution:
|
||||
m_OverrideState: 0
|
||||
m_Value: 0
|
||||
APVContributionWeight:
|
||||
m_OverrideState: 0
|
||||
m_Value: 1
|
||||
enableMainLightContribution:
|
||||
m_OverrideState: 0
|
||||
m_Value: 0
|
||||
anisotropy:
|
||||
m_OverrideState: 0
|
||||
m_Value: 0.4
|
||||
scattering:
|
||||
m_OverrideState: 0
|
||||
m_Value: 0.15
|
||||
tint:
|
||||
m_OverrideState: 0
|
||||
m_Value: {r: 1, g: 1, b: 1, a: 1}
|
||||
enableAdditionalLightsContribution:
|
||||
m_OverrideState: 0
|
||||
m_Value: 0
|
||||
maxSteps:
|
||||
m_OverrideState: 0
|
||||
m_Value: 128
|
||||
blurIterations:
|
||||
m_OverrideState: 0
|
||||
m_Value: 2
|
||||
enabled:
|
||||
m_OverrideState: 0
|
||||
m_Value: 0
|
||||
renderPassEvent:
|
||||
m_OverrideState: 0
|
||||
m_Value: 550
|
||||
--- !u!114 &-2307326953841441124
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 3
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 97c23e3b12dc18c42a140437e53d3951, type: 3}
|
||||
m_Name: Tonemapping
|
||||
m_EditorClassIdentifier:
|
||||
active: 1
|
||||
mode:
|
||||
m_OverrideState: 1
|
||||
m_Value: 2
|
||||
neutralHDRRangeReductionMode:
|
||||
m_OverrideState: 0
|
||||
m_Value: 2
|
||||
acesPreset:
|
||||
m_OverrideState: 0
|
||||
m_Value: 3
|
||||
hueShiftAmount:
|
||||
m_OverrideState: 0
|
||||
m_Value: 0
|
||||
detectPaperWhite:
|
||||
m_OverrideState: 0
|
||||
m_Value: 0
|
||||
paperWhite:
|
||||
m_OverrideState: 0
|
||||
m_Value: 300
|
||||
detectBrightnessLimits:
|
||||
m_OverrideState: 0
|
||||
m_Value: 1
|
||||
minNits:
|
||||
m_OverrideState: 0
|
||||
m_Value: 0.005
|
||||
maxNits:
|
||||
m_OverrideState: 0
|
||||
m_Value: 1000
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: d7fd9488000d3734a9e00ee676215985, type: 3}
|
||||
m_Name: Default
|
||||
m_EditorClassIdentifier:
|
||||
components:
|
||||
- {fileID: -2940743133789450860}
|
||||
- {fileID: -3285242745950591362}
|
||||
- {fileID: 531387521984870518}
|
||||
- {fileID: -2307326953841441124}
|
||||
- {fileID: 4550874325240702303}
|
||||
- {fileID: -6930818438622466647}
|
||||
- {fileID: 6698165480939181587}
|
||||
--- !u!114 &531387521984870518
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 3
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 66f335fb1ffd8684294ad653bf1c7564, type: 3}
|
||||
m_Name: ColorAdjustments
|
||||
m_EditorClassIdentifier:
|
||||
active: 1
|
||||
postExposure:
|
||||
m_OverrideState: 0
|
||||
m_Value: 0
|
||||
contrast:
|
||||
m_OverrideState: 0
|
||||
m_Value: 0
|
||||
colorFilter:
|
||||
m_OverrideState: 0
|
||||
m_Value: {r: 1, g: 1, b: 1, a: 1}
|
||||
hueShift:
|
||||
m_OverrideState: 0
|
||||
m_Value: 0
|
||||
saturation:
|
||||
m_OverrideState: 0
|
||||
m_Value: 0
|
||||
--- !u!114 &4550874325240702303
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 3
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 221518ef91623a7438a71fef23660601, type: 3}
|
||||
m_Name: WhiteBalance
|
||||
m_EditorClassIdentifier:
|
||||
active: 1
|
||||
temperature:
|
||||
m_OverrideState: 0
|
||||
m_Value: 0
|
||||
tint:
|
||||
m_OverrideState: 0
|
||||
m_Value: 0
|
||||
--- !u!114 &6698165480939181587
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 3
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: ccf1aba9553839d41ae37dd52e9ebcce, type: 3}
|
||||
m_Name: MotionBlur
|
||||
m_EditorClassIdentifier: Unity.RenderPipelines.Universal.Runtime::UnityEngine.Rendering.Universal.MotionBlur
|
||||
active: 1
|
||||
mode:
|
||||
m_OverrideState: 0
|
||||
m_Value: 0
|
||||
quality:
|
||||
m_OverrideState: 0
|
||||
m_Value: 0
|
||||
intensity:
|
||||
m_OverrideState: 1
|
||||
m_Value: 0
|
||||
clamp:
|
||||
m_OverrideState: 0
|
||||
m_Value: 0.05
|
||||
8
Assets/Assets/Resources/Volume/Default.asset.meta
Normal file
8
Assets/Assets/Resources/Volume/Default.asset.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 25c4b60273b147748b67dfd9bd7a6a4d
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -75,8 +75,8 @@ MonoBehaviour:
|
||||
m_OverrideState: 0
|
||||
m_Value: 65472
|
||||
tint:
|
||||
m_OverrideState: 0
|
||||
m_Value: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_OverrideState: 1
|
||||
m_Value: {r: 0, g: 0, b: 0, a: 1}
|
||||
highQualityFiltering:
|
||||
m_OverrideState: 0
|
||||
m_Value: 0
|
||||
@@ -261,19 +261,19 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: c01700fd266d6914ababb731e09af2eb, type: 3}
|
||||
m_Name: DepthOfField
|
||||
m_EditorClassIdentifier: Unity.RenderPipelines.Universal.Runtime::UnityEngine.Rendering.Universal.DepthOfField
|
||||
active: 1
|
||||
active: 0
|
||||
mode:
|
||||
m_OverrideState: 0
|
||||
m_Value: 0
|
||||
m_OverrideState: 1
|
||||
m_Value: 1
|
||||
gaussianStart:
|
||||
m_OverrideState: 0
|
||||
m_Value: 10
|
||||
m_OverrideState: 1
|
||||
m_Value: 20
|
||||
gaussianEnd:
|
||||
m_OverrideState: 0
|
||||
m_OverrideState: 1
|
||||
m_Value: 30
|
||||
gaussianMaxRadius:
|
||||
m_OverrideState: 0
|
||||
m_Value: 1
|
||||
m_OverrideState: 1
|
||||
m_Value: 1.5
|
||||
highQualitySampling:
|
||||
m_OverrideState: 0
|
||||
m_Value: 0
|
||||
|
||||
Submodule Assets/Convention updated: a3483f23d8...fd68071416
File diff suppressed because one or more lines are too long
@@ -616,7 +616,8 @@ PrefabInstance:
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_RemovedGameObjects: []
|
||||
m_RemovedGameObjects:
|
||||
- {fileID: 8780852774427548101, guid: c659abfe74df5de47a769f8d52c18fcc, type: 3}
|
||||
m_AddedGameObjects: []
|
||||
m_AddedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: c659abfe74df5de47a769f8d52c18fcc, type: 3}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
using Demo.Game.Attr;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Demo.Game
|
||||
{
|
||||
[Scriptable]
|
||||
public class Anchor : ScriptableObject
|
||||
{
|
||||
protected override bool IsSelfEnableUpdate => false;
|
||||
|
||||
@@ -3,7 +3,7 @@ using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
[CustomEditor(typeof(Demo.ScriptableObject), true)]
|
||||
[CustomEditor(typeof(Demo.Game.ScriptableObject), true)]
|
||||
public class SOEditor : Convention.AbstractCustomEditor
|
||||
{
|
||||
|
||||
|
||||
@@ -1,9 +1,49 @@
|
||||
using Convention;
|
||||
using Demo.Game.Attr;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Demo.Game
|
||||
{
|
||||
namespace ConfigType
|
||||
{
|
||||
public class PrefabRootObjectConfig : ScriptLoadableConfig
|
||||
{
|
||||
public Dictionary<string, string[]> LoadedGameObjectNames = new();
|
||||
|
||||
public override void Deserialize(BinaryReader reader)
|
||||
{
|
||||
int count = BinarySerializeUtility.ReadInt(reader);
|
||||
for (; count > 0;count--)
|
||||
{
|
||||
var temp = BinarySerializeUtility.DeserializeStringArray(reader);
|
||||
var key = temp[0];
|
||||
var value = temp[1..];
|
||||
LoadedGameObjectNames.Add(key, value);
|
||||
}
|
||||
base.Deserialize(reader);
|
||||
}
|
||||
|
||||
public override void Serialize(BinaryWriter writer)
|
||||
{
|
||||
BinarySerializeUtility.WriteInt(writer, LoadedGameObjectNames.Count);
|
||||
foreach (var (key,value) in LoadedGameObjectNames)
|
||||
{
|
||||
string[] temp = new string[value.Length + 1];
|
||||
temp[0] = key;
|
||||
Array.Copy(value, 0, temp, 1, value.Length);
|
||||
BinarySerializeUtility.SerializeArray(writer, value.ToArray());
|
||||
}
|
||||
base.Serialize(writer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Scriptable]
|
||||
public class PrefabRootObject : ScriptableObject, IAssetBundleLoader
|
||||
{
|
||||
public static PrefabRootObject Make()
|
||||
@@ -11,15 +51,26 @@ namespace Demo.Game
|
||||
return new GameObject().AddComponent<PrefabRootObject>();
|
||||
}
|
||||
|
||||
private readonly List<string> AssetBundles = new();
|
||||
private readonly List<GameObject> Prefabs = new();
|
||||
private int LoadingCounter = 0;
|
||||
private readonly Dictionary<string, List<string>> LoadedGameObjectNames = new();
|
||||
private readonly List<GameObject> LoadedGameObjects = new();
|
||||
|
||||
protected override IEnumerator DoSomethingDuringApplyScript()
|
||||
{
|
||||
yield return base.DoSomethingDuringApplyScript();
|
||||
yield return new WaitUntil(() => LoadingCounter == 0);
|
||||
}
|
||||
|
||||
public override IEnumerator UnloadScript()
|
||||
{
|
||||
yield return base.UnloadScript();
|
||||
foreach (var ab in AssetBundles)
|
||||
foreach (var obj in LoadedGameObjects)
|
||||
{
|
||||
yield return this.UnloadAssetBundle(ab);
|
||||
Destroy(obj);
|
||||
}
|
||||
foreach (var item in LoadedGameObjectNames)
|
||||
{
|
||||
yield return this.UnloadAssetBundle(item.Key);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,31 +80,27 @@ namespace Demo.Game
|
||||
/// <param name="ab"></param>
|
||||
/// <param name="prefab"></param>
|
||||
[Convention.RScript.Variable.Attr.Method]
|
||||
public IEnumerator Load(string ab, string prefab)
|
||||
public void Load(string ab, string prefab)
|
||||
{
|
||||
AssetBundle assetBundle = null;
|
||||
yield return this.LoadAssetBundle(ab, x => assetBundle = x);
|
||||
GameObject prefabObject = null;
|
||||
if (assetBundle != null)
|
||||
LoadingCounter++;
|
||||
ConventionUtility.StartCoroutine(this.LoadAssetBundle(ab, assetBundle =>
|
||||
{
|
||||
var ir = assetBundle.LoadAssetAsync<GameObject>(prefab);
|
||||
yield return ir;
|
||||
if (ir.asset != null)
|
||||
GameObject prefabObject = null;
|
||||
if (assetBundle != null)
|
||||
{
|
||||
prefabObject = Instantiate(ir.asset as GameObject);
|
||||
Prefabs.Add(prefabObject);
|
||||
prefabObject = Instantiate(assetBundle.LoadAsset<GameObject>(prefab));
|
||||
LoadedGameObjects.Add(prefabObject);
|
||||
prefabObject.transform.SetParent(transform);
|
||||
AssetBundles.Add(ab);
|
||||
if (LoadedGameObjectNames.ContainsKey(ab) == false)
|
||||
LoadedGameObjectNames.Add(ab, new());
|
||||
LoadedGameObjectNames[ab].Add(prefab);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError($"Load Prefab failed", this);
|
||||
Debug.LogError($"Load AssetBundle failed", this);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError($"Load AssetBundle failed", this);
|
||||
}
|
||||
LoadingCounter--;
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,47 @@
|
||||
using Convention;
|
||||
using Demo.Game.Attr;
|
||||
using Demo.Game.ConfigType;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Convention;
|
||||
using System.IO;
|
||||
using Unity.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Demo.Game
|
||||
{
|
||||
namespace ConfigType
|
||||
{
|
||||
public class SkyUpdatementConfig : UpdatementIntConfig
|
||||
{
|
||||
public string SkyAssetBundlePath;
|
||||
public string[] SkyNames;
|
||||
public int[] SkyIndexs;
|
||||
|
||||
public override void Deserialize(BinaryReader reader)
|
||||
{
|
||||
SkyAssetBundlePath = BinarySerializeUtility.ReadString(reader);
|
||||
SkyNames = BinarySerializeUtility.DeserializeStringArray(reader);
|
||||
SkyIndexs = BinarySerializeUtility.DeserializeIntArray(reader);
|
||||
base.Deserialize(reader);
|
||||
}
|
||||
|
||||
public override void Serialize(BinaryWriter writer)
|
||||
{
|
||||
BinarySerializeUtility.WriteString(writer, SkyAssetBundlePath);
|
||||
BinarySerializeUtility.SerializeArray(writer, SkyNames);
|
||||
BinarySerializeUtility.SerializeArray(writer, SkyIndexs);
|
||||
base.Serialize(writer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Scriptable]
|
||||
public class SkyUpdatement : Updatement<int>, IAssetBundleLoader
|
||||
{
|
||||
protected override ScriptLoadableConfig MakeConfig()
|
||||
{
|
||||
return new SkyUpdatementConfig();
|
||||
}
|
||||
public static SkyUpdatement Make()
|
||||
{
|
||||
return new GameObject().AddComponent<SkyUpdatement>();
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
using Convention;
|
||||
using Demo.Game.Attr;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Convention;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Demo.Game
|
||||
{
|
||||
[Scriptable]
|
||||
public class WorldLightObject : ScriptableObject
|
||||
{
|
||||
public static WorldLightObject Make()
|
||||
|
||||
@@ -6,11 +6,67 @@ using Cinemachine;
|
||||
#endif
|
||||
using Convention.WindowsUI.Variant;
|
||||
using UnityEngine;
|
||||
using Demo.Game.Attr;
|
||||
using System.IO;
|
||||
using Convention;
|
||||
using Demo.Game.ConfigType;
|
||||
|
||||
namespace Demo.Game
|
||||
{
|
||||
namespace ConfigType
|
||||
{
|
||||
public class CameraObjectConfig : ScriptLoadableConfig
|
||||
{
|
||||
public bool orthographic;
|
||||
public float fieldOfView;
|
||||
public float orthographicSize;
|
||||
public float nearClipPlane;
|
||||
public float farClipPlane;
|
||||
public float depth;
|
||||
public int VirtualCameraFollow;
|
||||
public int VirtualCameraLookAt;
|
||||
public Vector3 VirtualCameraFollowOffset;
|
||||
public Vector3 VirtualCameraLookAtDamping;
|
||||
|
||||
public override void Deserialize(BinaryReader reader)
|
||||
{
|
||||
orthographic = BinarySerializeUtility.ReadBool(reader);
|
||||
fieldOfView = BinarySerializeUtility.ReadFloat(reader);
|
||||
orthographicSize = BinarySerializeUtility.ReadFloat(reader);
|
||||
nearClipPlane = BinarySerializeUtility.ReadFloat(reader);
|
||||
farClipPlane = BinarySerializeUtility.ReadFloat(reader);
|
||||
depth = BinarySerializeUtility.ReadFloat(reader);
|
||||
VirtualCameraFollow = BinarySerializeUtility.ReadInt(reader);
|
||||
VirtualCameraLookAt = BinarySerializeUtility.ReadInt(reader);
|
||||
VirtualCameraFollowOffset = BinarySerializeUtility.ReadVec3(reader);
|
||||
VirtualCameraLookAtDamping = BinarySerializeUtility.ReadVec3(reader);
|
||||
base.Deserialize(reader);
|
||||
}
|
||||
|
||||
public override void Serialize(BinaryWriter writer)
|
||||
{
|
||||
BinarySerializeUtility.WriteBool(writer, orthographic);
|
||||
BinarySerializeUtility.WriteFloat(writer, fieldOfView);
|
||||
BinarySerializeUtility.WriteFloat(writer, orthographicSize);
|
||||
BinarySerializeUtility.WriteFloat(writer, nearClipPlane);
|
||||
BinarySerializeUtility.WriteFloat(writer, farClipPlane);
|
||||
BinarySerializeUtility.WriteFloat(writer, depth);
|
||||
BinarySerializeUtility.WriteInt(writer, VirtualCameraFollow);
|
||||
BinarySerializeUtility.WriteInt(writer,VirtualCameraLookAt);
|
||||
BinarySerializeUtility.WriteVec3(writer, VirtualCameraFollowOffset);
|
||||
BinarySerializeUtility.WriteVec3(writer, VirtualCameraLookAtDamping);
|
||||
base.Serialize(writer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Scriptable(nameof(MakeCameraObject))]
|
||||
public class CameraObject : ScriptableObject
|
||||
{
|
||||
protected override ScriptLoadableConfig MakeConfig()
|
||||
{
|
||||
return new CameraObjectConfig();
|
||||
}
|
||||
private Camera MainCamera => Camera.main;
|
||||
private CinemachineCamera m_VirtualCamera;
|
||||
private CinemachineCamera VirtualCamera
|
||||
@@ -49,7 +105,7 @@ namespace Demo.Game
|
||||
[Convention.RScript.Variable.Attr.Method]
|
||||
public void SetOrthographic(bool orthographic)
|
||||
{
|
||||
MainCamera.orthographic = orthographic;
|
||||
GetConfig<CameraObjectConfig>().orthographic = MainCamera.orthographic = orthographic;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -58,7 +114,7 @@ namespace Demo.Game
|
||||
[Convention.RScript.Variable.Attr.Method]
|
||||
public void SetFieldOfView(float fieldOfView)
|
||||
{
|
||||
MainCamera.fieldOfView = fieldOfView;
|
||||
GetConfig<CameraObjectConfig>().fieldOfView = MainCamera.fieldOfView = fieldOfView;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -67,7 +123,7 @@ namespace Demo.Game
|
||||
[Convention.RScript.Variable.Attr.Method]
|
||||
public void SetOrthographicSize(float orthographicSize)
|
||||
{
|
||||
MainCamera.orthographicSize = orthographicSize;
|
||||
GetConfig<CameraObjectConfig>().orthographicSize = MainCamera.orthographicSize = orthographicSize;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -76,7 +132,7 @@ namespace Demo.Game
|
||||
[Convention.RScript.Variable.Attr.Method]
|
||||
public void SetNearClipPlane(float nearClipPlane)
|
||||
{
|
||||
MainCamera.nearClipPlane = nearClipPlane;
|
||||
GetConfig<CameraObjectConfig>().nearClipPlane = MainCamera.nearClipPlane = nearClipPlane;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -85,7 +141,7 @@ namespace Demo.Game
|
||||
[Convention.RScript.Variable.Attr.Method]
|
||||
public void SetFarClipPlane(float farClipPlane)
|
||||
{
|
||||
MainCamera.farClipPlane = farClipPlane;
|
||||
GetConfig<CameraObjectConfig>().farClipPlane = MainCamera.farClipPlane = farClipPlane;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -94,7 +150,7 @@ namespace Demo.Game
|
||||
[Convention.RScript.Variable.Attr.Method]
|
||||
public void SetDepth(float depth)
|
||||
{
|
||||
MainCamera.depth = depth;
|
||||
GetConfig<CameraObjectConfig>().depth = MainCamera.depth = depth;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -103,6 +159,7 @@ namespace Demo.Game
|
||||
[Convention.RScript.Variable.Attr.Method]
|
||||
public void SetVirtualCameraFollow(ScriptableObject target)
|
||||
{
|
||||
GetConfig<CameraObjectConfig>().VirtualCameraFollow = GetRoot().FindIndex(target);
|
||||
VirtualCamera.Follow = target.transform;
|
||||
}
|
||||
|
||||
@@ -112,6 +169,7 @@ namespace Demo.Game
|
||||
[Convention.RScript.Variable.Attr.Method]
|
||||
public void SetVirtualCameraLookAt(ScriptableObject target)
|
||||
{
|
||||
GetConfig<CameraObjectConfig>().VirtualCameraLookAt = GetRoot().FindIndex(target);
|
||||
VirtualCamera.LookAt = target.transform;
|
||||
}
|
||||
|
||||
@@ -127,28 +185,11 @@ namespace Demo.Game
|
||||
var body = VirtualCamera.GetCinemachineComponent(CinemachineCore.Stage.Body) as CinemachineFollow;
|
||||
if (body != null)
|
||||
{
|
||||
GetConfig<CameraObjectConfig>().VirtualCameraFollowOffset = new Vector3(x, y, z);
|
||||
body.FollowOffset = new Vector3(x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置虚拟相机跟随阻尼
|
||||
/// </summary>
|
||||
/// <param name="x">X轴阻尼</param>
|
||||
/// <param name="y">Y轴阻尼</param>
|
||||
/// <param name="z">Z轴阻尼</param>
|
||||
//[Convention.RScript.Variable.Attr.Method]
|
||||
//public void SetVirtualCameraFollowDamping(float x, float y, float z)
|
||||
//{
|
||||
// var body = VirtualCamera.GetCinemachineComponent(CinemachineCore.Stage.Body) as CinemachineFollow;
|
||||
// if (body != null)
|
||||
// {
|
||||
// body.XDamping = x;
|
||||
// body.YDamping = y;
|
||||
// body.ZDamping = z;
|
||||
// }
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// 设置虚拟相机观察阻尼
|
||||
/// </summary>
|
||||
@@ -161,6 +202,7 @@ namespace Demo.Game
|
||||
var aim = VirtualCamera.GetCinemachineComponent(CinemachineCore.Stage.Body) as CinemachineRotationComposer;
|
||||
if (aim != null)
|
||||
{
|
||||
GetConfig<CameraObjectConfig>().VirtualCameraLookAtDamping = new Vector3(x, y, z);
|
||||
aim.Damping = new(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,32 +1,61 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Convention;
|
||||
using UnityEngine;
|
||||
using Demo.Game.Attr;
|
||||
using System;
|
||||
using Unity.Collections;
|
||||
using UnityEngine.Rendering;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using Unity.Collections;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
|
||||
namespace Demo.Game
|
||||
{
|
||||
namespace ConfigType
|
||||
{
|
||||
public class DDTConfig : ScriptLoadableConfig
|
||||
{
|
||||
[Content] public NativeArray<float> Datas = new(128, Allocator.Persistent, NativeArrayOptions.UninitializedMemory);
|
||||
[Content] public int Count = 0;
|
||||
|
||||
public override void Deserialize(BinaryReader reader)
|
||||
{
|
||||
BinarySerializeUtility.DeserializeNativeArray(reader, ref Datas);
|
||||
Count = Datas.Length;
|
||||
base.Deserialize(reader);
|
||||
}
|
||||
|
||||
public override void Serialize(BinaryWriter writer)
|
||||
{
|
||||
var newArray = new NativeArray<float>(Count, Allocator.Persistent, NativeArrayOptions.UninitializedMemory);
|
||||
NativeArray<float>.Copy(Datas, newArray, Count);
|
||||
Datas = newArray;
|
||||
BinarySerializeUtility.SerializeNativeArray(writer, Datas);
|
||||
base.Serialize(writer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Scriptable]
|
||||
public class DDT : ScriptableObject
|
||||
{
|
||||
protected override ConfigType.ScriptLoadableConfig MakeConfig()
|
||||
{
|
||||
return new ConfigType.DDTConfig();
|
||||
}
|
||||
protected override bool IsSelfEnableUpdate => false;
|
||||
public static DDT Make()
|
||||
{
|
||||
return new GameObject().AddComponent<DDT>();
|
||||
}
|
||||
|
||||
public NativeArray<float> Datas = new(128, Allocator.Persistent, NativeArrayOptions.UninitializedMemory);
|
||||
public int Count { get; private set; } = 0;
|
||||
|
||||
[Convention.RScript.Variable.Attr.Method]
|
||||
public void Add(float value)
|
||||
{
|
||||
if (Count >= Datas.Length)
|
||||
Datas.ResizeArray(Mathf.FloorToInt(Count * 1.5f));
|
||||
Datas[Count] = value;
|
||||
Count++;
|
||||
int Count = GetConfig<ConfigType.DDTConfig>().Count;
|
||||
if (Count >= GetConfig<ConfigType.DDTConfig>().Datas.Length)
|
||||
GetConfig<ConfigType.DDTConfig>().Datas.ResizeArray(Mathf.FloorToInt(Count * 1.5f));
|
||||
GetConfig<ConfigType.DDTConfig>().Datas[Count] = value;
|
||||
GetConfig<ConfigType.DDTConfig>().Count++;
|
||||
}
|
||||
|
||||
[Convention.RScript.Variable.Attr.Method]
|
||||
@@ -38,27 +67,24 @@ namespace Demo.Game
|
||||
[Convention.RScript.Variable.Attr.Method]
|
||||
public float At(int index)
|
||||
{
|
||||
int Count = GetConfig<ConfigType.DDTConfig>().Count;
|
||||
if (index < 0)
|
||||
index = Count + index;
|
||||
if (index < 0 || index >= Count)
|
||||
throw new IndexOutOfRangeException($"{index} is out of [0, {Count})");
|
||||
return Datas[index];
|
||||
return GetConfig<ConfigType.DDTConfig>().Datas[index];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <20><>ȡ<EFBFBD><C8A1><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[Convention.RScript.Variable.Attr.Method]
|
||||
public int GetCount()
|
||||
{
|
||||
return Count;
|
||||
return GetConfig<ConfigType.DDTConfig>().Count;
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
if (Datas.IsCreated)
|
||||
Datas.Dispose();
|
||||
if (GetConfig<ConfigType.DDTConfig>().Datas.IsCreated)
|
||||
GetConfig<ConfigType.DDTConfig>().Datas.Dispose();
|
||||
}
|
||||
|
||||
#region Serialize
|
||||
@@ -69,36 +95,25 @@ namespace Demo.Game
|
||||
yield return this.ParseScript2Expr(scriptFile.LoadAsText());
|
||||
using var stream = File.OpenWrite(cacheFile.GetFullPath());
|
||||
using var writer = new BinaryWriter(stream);
|
||||
writer.Write(Count);
|
||||
for (int i = 0; i < Count; i++)
|
||||
writer.Write(GetConfig<ConfigType.DDTConfig>().Count);
|
||||
for (int i = 0, e = GetConfig<ConfigType.DDTConfig>().Count; i < e; i++)
|
||||
{
|
||||
writer.Write(Datas[i]);
|
||||
writer.Write(GetConfig<ConfigType.DDTConfig>().Datas[i]);
|
||||
}
|
||||
}
|
||||
protected override IEnumerator LoadFromImptCacheFile(ToolFile cacheFile)
|
||||
{
|
||||
using var stream = File.OpenRead(cacheFile.GetFullPath());
|
||||
using var reader = new BinaryReader(stream);
|
||||
Count = reader.ReadInt32();
|
||||
Datas.ResizeArray(Mathf.Max(128, Count));
|
||||
for (int i = 0; i < Count; i++)
|
||||
GetConfig<ConfigType.DDTConfig>().Count = reader.ReadInt32();
|
||||
GetConfig<ConfigType.DDTConfig>().Datas.ResizeArray(Mathf.Max(128, GetConfig<ConfigType.DDTConfig>().Count));
|
||||
for (int i = 0, e = GetConfig<ConfigType.DDTConfig>().Count; i < e; i++)
|
||||
{
|
||||
Datas[i] = reader.ReadSingle();
|
||||
GetConfig<ConfigType.DDTConfig>().Datas[i] = reader.ReadSingle();
|
||||
}
|
||||
yield break;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#if UNITY_EDITOR
|
||||
[Setting, SerializeField] private List<float> d_Datas = new();
|
||||
protected override IEnumerator DoSomethingDuringApplyScript()
|
||||
{
|
||||
yield return base.DoSomethingDuringApplyScript();
|
||||
for (int i = 0; i < Count; i++)
|
||||
d_Datas.Add(Datas[i]);
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace Demo.Editor
|
||||
{
|
||||
foreach (var type in asm.GetTypes())
|
||||
{
|
||||
if (typeof(ScriptableObject).IsAssignableFrom(type) && type.IsAbstract == false)
|
||||
if (typeof(Demo.Game.ScriptableObject).IsAssignableFrom(type) && type.IsAbstract == false)
|
||||
{
|
||||
result.Add(type.Name, type);
|
||||
}
|
||||
@@ -378,6 +378,7 @@ namespace Demo.Editor
|
||||
private void RegisterVariableGenerater()
|
||||
{
|
||||
// Generate Framework
|
||||
Debug.Log(nameof(RegisterVariableGenerater), this);
|
||||
var generaters = DefaultInstantiate.GetScriptableObjectInstantiate();
|
||||
foreach (var asm in AppDomain.CurrentDomain.GetAssemblies())
|
||||
{
|
||||
@@ -390,7 +391,7 @@ namespace Demo.Editor
|
||||
{
|
||||
new Convention.RScript.Variable.CStyle.CScriptRScriptVariableGenerater(type, () => generater(), null, filename).Register();
|
||||
}
|
||||
else if (typeof(ScriptableObject).IsAssignableFrom(type))
|
||||
else if (typeof(Demo.Game.ScriptableObject).IsAssignableFrom(type))
|
||||
{
|
||||
new Convention.RScript.Variable.CStyle.CScriptRScriptVariableGenerater(type, null, null, filename).Register();
|
||||
}
|
||||
@@ -420,7 +421,7 @@ namespace Demo.Editor
|
||||
helperHeaderDir.MustExistsPath();
|
||||
foreach (var (name, variable) in Convention.RScript.Variable.RScriptInjectVariableGenerater.AllRScriptInjectVariables)
|
||||
{
|
||||
(helperHeaderDir | name).SaveAsText(variable.scriptIndicator);
|
||||
(helperHeaderDir | name.Replace('<', '[').Replace('>', ']')).SaveAsText(variable.scriptIndicator);
|
||||
}
|
||||
|
||||
// Reset
|
||||
|
||||
@@ -200,46 +200,120 @@ namespace Demo.Game
|
||||
var rootFileName = (string)MainConfig.FindItem("root");
|
||||
var rootObject = new ToolFile(Path.Combine(content.RootSourceDir, rootFileName));
|
||||
rootObject.MustExistsPath();
|
||||
// 缓存MD5与重编译检查
|
||||
var rootObjectDir = rootObject.GetParentDir();
|
||||
ToolFile cacheDir = rootObjectDir | ".cache";
|
||||
var projectHashFile = cacheDir | "projectHash.json";
|
||||
Dictionary<string, string> projectHash = new();
|
||||
bool isRecompile = true;
|
||||
if (!!projectHashFile)
|
||||
{
|
||||
projectHash = projectHashFile.LoadAsJson<Dictionary<string, string>>();
|
||||
foreach (var (file, md5) in projectHash)
|
||||
{
|
||||
if (new ToolFile(file).CalculateHash() != md5)
|
||||
{
|
||||
isRecompile = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
var rootGameObject = new GameObject(rootObject.GetName(true)).AddComponent<RootObject>();
|
||||
MainObject = rootGameObject;
|
||||
rootGameObject.transform.SetParent(transform);
|
||||
rootGameObject.ScriptName = rootObject.GetName(true);
|
||||
rootGameObject.audioSystem = MainAudio;
|
||||
rootGameObject.LoadedScriptSet.Add(rootObject);
|
||||
rootGameObject.EnableScript(content.RootSourceDir, this);
|
||||
rootGameObject.SetContent(nameof(SongOffset), SongOffset);
|
||||
rootGameObject.SetContent(nameof(IsAutoPlay), IsAutoPlay ? 1 : 0);
|
||||
rootGameObject.SetContent("SongLength", MainAudio.CurrentClip.length);
|
||||
static IEnumerator Foo(IEnumerator ir)
|
||||
if (isRecompile || true)
|
||||
{
|
||||
Stack<IEnumerator> loadingTask = new();
|
||||
loadingTask.Push(ir);
|
||||
while (loadingTask.Count > 0)
|
||||
static IEnumerator Foo(IEnumerator ir)
|
||||
{
|
||||
if (loadingTask.Peek().MoveNext())
|
||||
Stack<IEnumerator> loadingTask = new();
|
||||
loadingTask.Push(ir);
|
||||
while (loadingTask.Count > 0)
|
||||
{
|
||||
if (loadingTask.Peek().Current is IEnumerator next)
|
||||
loadingTask.Push(next);
|
||||
else if (loadingTask.Peek().Current is ScriptableObject)
|
||||
yield return null;
|
||||
if (loadingTask.Peek().MoveNext())
|
||||
{
|
||||
if (loadingTask.Peek().Current is IEnumerator next)
|
||||
loadingTask.Push(next);
|
||||
else if (loadingTask.Peek().Current is ScriptableObject)
|
||||
yield return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
loadingTask.Pop();
|
||||
}
|
||||
}
|
||||
else
|
||||
yield break;
|
||||
}
|
||||
yield return ConventionUtility.AvoidFakeStop(rootGameObject.ParseFromScriptFile2Expr(rootObject));//Foo(rootGameObject.ParseFromScriptFile2Expr(rootObject));
|
||||
int applyDownCount = 0;
|
||||
void NDFS(ScriptableObject current)
|
||||
{
|
||||
foreach (var child in current.Childs)
|
||||
{
|
||||
loadingTask.Pop();
|
||||
NDFS(child);
|
||||
}
|
||||
if (current.IsScriptApply == false)
|
||||
{
|
||||
applyDownCount++;
|
||||
IEnumerator NDFSFoo()
|
||||
{
|
||||
yield return current.ApplyScript();
|
||||
current.ResetEnterGameStatus();
|
||||
applyDownCount--;
|
||||
}
|
||||
ConventionUtility.StartCoroutine(NDFSFoo());
|
||||
}
|
||||
}
|
||||
yield break;
|
||||
}
|
||||
yield return Foo(rootGameObject.ParseFromScriptFile2Expr(rootObject));//ConventionUtility.AvoidFakeStop(rootGameObject.ParseFromScriptFile2Expr(rootObject));
|
||||
static void NDFS(ScriptableObject current)
|
||||
{
|
||||
foreach (var child in current.Childs)
|
||||
NDFS(rootGameObject);
|
||||
yield return new WaitUntil(() => applyDownCount == 0);
|
||||
projectHash.Clear();
|
||||
foreach (var path in rootGameObject.LoadedScriptSet)
|
||||
{
|
||||
NDFS(child);
|
||||
projectHash.Add(path, new ToolFile(path).CalculateHash());
|
||||
}
|
||||
if (current.IsScriptApply == false)
|
||||
ConventionUtility.StartCoroutine(current.ApplyScript());
|
||||
// 哈希缓存
|
||||
projectHashFile.SaveAsJson(projectHash);
|
||||
// 编译结果
|
||||
var projectBinaryFile = cacheDir | "project.dat";
|
||||
using var stream = new FileInfo(projectBinaryFile).OpenWrite();
|
||||
using var writer = new BinaryWriter(stream);
|
||||
rootGameObject.Config.Serialize(writer);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 加载
|
||||
var projectBinaryFile = cacheDir | "project.dat";
|
||||
using var stream = new FileInfo(projectBinaryFile).OpenRead();
|
||||
using var reader = new BinaryReader(stream);
|
||||
rootGameObject.Config.Deserialize(reader);
|
||||
int applyDownCount = 0;
|
||||
void NDFS(ScriptableObject current)
|
||||
{
|
||||
foreach (var child in current.Childs)
|
||||
{
|
||||
NDFS(child);
|
||||
}
|
||||
if (current.IsScriptApply == false)
|
||||
{
|
||||
applyDownCount++;
|
||||
IEnumerator NDFSFoo()
|
||||
{
|
||||
yield return current.ApplyScript();
|
||||
current.ResetEnterGameStatus();
|
||||
applyDownCount--;
|
||||
}
|
||||
ConventionUtility.StartCoroutine(NDFSFoo());
|
||||
}
|
||||
}
|
||||
NDFS(rootGameObject);
|
||||
yield return new WaitUntil(() => applyDownCount == 0);
|
||||
}
|
||||
NDFS(rootGameObject);
|
||||
float loadRootObjectEndTime = Time.realtimeSinceStartup;
|
||||
float loadRootObjectElapsed = (loadRootObjectEndTime - loadRootObjectStartTime) * 1000f;
|
||||
Debug.Log($"[GameInit] Load Root Object 耗时: {loadRootObjectElapsed:F2} ms", this);
|
||||
|
||||
@@ -3,6 +3,8 @@ using Convention.WindowsUI.Variant;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
@@ -16,7 +18,56 @@ namespace Demo.Game
|
||||
|
||||
[Content] public GameController RootGameController;
|
||||
|
||||
public string SourcePath;
|
||||
[Setting]public string SourcePath;
|
||||
[Header("GlobalConfig")]
|
||||
public readonly HashSet<string> LoadedScriptSet = new();
|
||||
public readonly Dictionary<int, ScriptableObject> LoadedScriptIndex = new();
|
||||
public readonly Dictionary<ScriptableObject, int> LoadedScriptRIndex = new();
|
||||
private int LoadedScriptCnt = 0;
|
||||
/// <summary>
|
||||
/// 被用于自动生成
|
||||
/// </summary>
|
||||
/// <param name="obj"></param>
|
||||
/// <returns></returns>
|
||||
public int PushLoadedScriptObject(ScriptableObject obj)
|
||||
{
|
||||
while (LoadedScriptIndex.TryAdd(LoadedScriptCnt, obj) == false)
|
||||
LoadedScriptCnt++;
|
||||
LoadedScriptRIndex.Add(obj, LoadedScriptCnt);
|
||||
return LoadedScriptCnt++;
|
||||
}
|
||||
/// <summary>
|
||||
/// 被用于从缓存中生成
|
||||
/// </summary>
|
||||
/// <param name="obj"></param>
|
||||
/// <param name="index"></param>
|
||||
/// <returns></returns>
|
||||
public int PushLoadedScriptObject(ScriptableObject obj, int index)
|
||||
{
|
||||
LoadedScriptIndex.Add(index, obj);
|
||||
LoadedScriptRIndex.Add(obj, index);
|
||||
return index;
|
||||
}
|
||||
/// <summary>
|
||||
/// 通过序列号获得物体
|
||||
/// </summary>
|
||||
/// <param name="index"></param>
|
||||
/// <returns></returns>
|
||||
public ScriptableObject FindWithIndex(int index)
|
||||
{
|
||||
if(index<0)
|
||||
return null;
|
||||
return LoadedScriptIndex[index];
|
||||
}
|
||||
/// <summary>
|
||||
/// 通过物体获得序列号
|
||||
/// </summary>
|
||||
/// <param name="obj"></param>
|
||||
/// <returns>若无法找到将返回-1</returns>
|
||||
public int FindIndex(ScriptableObject obj)
|
||||
{
|
||||
return LoadedScriptRIndex.TryGetValue(obj, out var index) ? index : -1;
|
||||
}
|
||||
|
||||
protected override IEnumerator DoSomethingDuringApplyScript()
|
||||
{
|
||||
|
||||
@@ -1,18 +1,15 @@
|
||||
using Convention;
|
||||
using Convention.WindowsUI.Variant;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using Convention;
|
||||
using Convention.RScript;
|
||||
using Convention.WindowsUI.Variant;
|
||||
using Demo.Game;
|
||||
using Dreamteck.Splines;
|
||||
using Unity.VisualScripting;
|
||||
using Unity.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Demo
|
||||
namespace Demo.Game
|
||||
{
|
||||
public interface IScriptableObject
|
||||
{
|
||||
@@ -21,6 +18,76 @@ namespace Demo
|
||||
|
||||
#region ScriptableObject Inside
|
||||
|
||||
namespace Attr
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
|
||||
sealed class ScriptableAttribute : Attribute
|
||||
{
|
||||
public readonly string generaterName;
|
||||
|
||||
public ScriptableAttribute(string generaterName = "Make")
|
||||
{
|
||||
this.generaterName = generaterName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace ConfigType
|
||||
{
|
||||
[Serializable]
|
||||
public class ScriptLoadableConfig
|
||||
{
|
||||
[Content] public int UID = -1;
|
||||
[Content] public Vector3 EnterGameLocalPosition = Vector3.zero, EnterGameEulerAngles = Vector3.zero, EnterGameLocalScaling = Vector3.one;
|
||||
[Content] public bool IsSetObjectDisable = false;
|
||||
[Content] public int UpdatePerFrame = 1;
|
||||
|
||||
[Setting] public string ScriptName = "";
|
||||
private int[] ChildTypes = null;
|
||||
private ScriptLoadableConfig[] childs = null;
|
||||
|
||||
[Setting] public ScriptableObject target;
|
||||
|
||||
public virtual void Deserialize(BinaryReader reader)
|
||||
{
|
||||
UID = BinarySerializeUtility.ReadInt(reader);
|
||||
EnterGameLocalPosition = BinarySerializeUtility.ReadVec3(reader);
|
||||
EnterGameEulerAngles = BinarySerializeUtility.ReadVec3(reader);
|
||||
EnterGameLocalScaling = BinarySerializeUtility.ReadVec3(reader);
|
||||
IsSetObjectDisable = BinarySerializeUtility.ReadBool(reader);
|
||||
UpdatePerFrame = BinarySerializeUtility.ReadInt(reader);
|
||||
ScriptName = BinarySerializeUtility.ReadString(reader);
|
||||
ChildTypes = BinarySerializeUtility.DeserializeIntArray(reader);
|
||||
int childCount = ChildTypes.Length;
|
||||
childs = new ScriptLoadableConfig[childCount];
|
||||
for (int i = 0; i < childCount; i++)
|
||||
{
|
||||
var scriptObject = DefaultInstantiate.GetScriptableObjectInstantiate()[DefaultInstantiate.ScriptableObjectID2Typename[ChildTypes[i]]].Invoke();
|
||||
scriptObject.EnableScript(target);
|
||||
childs[i] = scriptObject.Config;
|
||||
childs[i].Deserialize(reader);
|
||||
}
|
||||
}
|
||||
public virtual void Serialize(BinaryWriter writer)
|
||||
{
|
||||
BinarySerializeUtility.WriteInt(writer, UID);
|
||||
BinarySerializeUtility.WriteVec3(writer, EnterGameLocalPosition);
|
||||
BinarySerializeUtility.WriteVec3(writer, EnterGameEulerAngles);
|
||||
BinarySerializeUtility.WriteVec3(writer, EnterGameLocalScaling);
|
||||
BinarySerializeUtility.WriteBool(writer, IsSetObjectDisable);
|
||||
BinarySerializeUtility.WriteInt(writer, UpdatePerFrame);
|
||||
BinarySerializeUtility.WriteString(writer, ScriptName);
|
||||
childs = (from child in target.Childs select child.Config).ToArray();
|
||||
ChildTypes = (from child in childs select DefaultInstantiate.ScriptableObjectTypename2ID[child.target.GetType().Name]).ToArray();
|
||||
BinarySerializeUtility.SerializeArray(writer, ChildTypes);
|
||||
foreach (var child in childs)
|
||||
{
|
||||
child.Serialize(writer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public partial class ScriptableObject : IScriptableObject
|
||||
{
|
||||
/// <summary>
|
||||
@@ -34,13 +101,28 @@ namespace Demo
|
||||
/// </summary>
|
||||
public partial class ScriptableObject
|
||||
{
|
||||
[Content, SerializeField]
|
||||
private Vector3
|
||||
EnterGameLocalPosition = Vector3.zero,
|
||||
EnterGameEulerAngles = Vector3.zero,
|
||||
EnterGameLocalScaling = Vector3.one;
|
||||
[Content, SerializeField] private bool IsSetObjectDisable = false;
|
||||
[Content] public int UpdatePerFrame = 1;
|
||||
protected virtual ConfigType.ScriptLoadableConfig MakeConfig()
|
||||
{
|
||||
return new ConfigType.ScriptLoadableConfig();
|
||||
}
|
||||
[Setting, SerializeField] private ConfigType.ScriptLoadableConfig m_Config = null;
|
||||
public ConfigType.ScriptLoadableConfig Config
|
||||
{
|
||||
// 懒加载生成Config
|
||||
get
|
||||
{
|
||||
if (m_Config == null)
|
||||
{
|
||||
m_Config = MakeConfig();
|
||||
m_Config.target = this;
|
||||
}
|
||||
return m_Config;
|
||||
}
|
||||
}
|
||||
public ConfigT GetConfig<ConfigT>() where ConfigT : ConfigType.ScriptLoadableConfig
|
||||
{
|
||||
return (ConfigT)Config;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置坐标
|
||||
@@ -51,7 +133,7 @@ namespace Demo
|
||||
[Convention.RScript.Variable.Attr.Method]
|
||||
public void SetLocalPosition(float x, float y, float z)
|
||||
{
|
||||
EnterGameLocalPosition = new(x, y, z);
|
||||
Config.EnterGameLocalPosition = transform.localPosition = new(x, y, z);
|
||||
}
|
||||
/// <summary>
|
||||
/// 设置欧拉角
|
||||
@@ -62,7 +144,7 @@ namespace Demo
|
||||
[Convention.RScript.Variable.Attr.Method]
|
||||
public void SetLocalEulerAngles(float x, float y, float z)
|
||||
{
|
||||
EnterGameEulerAngles = new(x, y, z);
|
||||
Config.EnterGameEulerAngles = transform.localEulerAngles = new(x, y, z);
|
||||
}
|
||||
/// <summary>
|
||||
/// 设置缩放
|
||||
@@ -73,7 +155,7 @@ namespace Demo
|
||||
[Convention.RScript.Variable.Attr.Method]
|
||||
public void SetLocalScaling(float x, float y, float z)
|
||||
{
|
||||
EnterGameLocalScaling = new(x, y, z);
|
||||
Config.EnterGameLocalScaling = transform.localScale= new(x, y, z);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -83,7 +165,8 @@ namespace Demo
|
||||
[Convention.RScript.Variable.Attr.Method]
|
||||
public void SetObjectDisable()
|
||||
{
|
||||
IsSetObjectDisable = true;
|
||||
Config.IsSetObjectDisable = true;
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -94,15 +177,15 @@ namespace Demo
|
||||
[Convention.RScript.Variable.Attr.Method]
|
||||
public void SetUpdatePerFrame(int frame)
|
||||
{
|
||||
UpdatePerFrame = Mathf.Max(1, frame);
|
||||
Config.UpdatePerFrame = Mathf.Max(1, frame);
|
||||
}
|
||||
|
||||
private void ScriptableObjectDoReset()
|
||||
{
|
||||
transform.localPosition = EnterGameLocalPosition;
|
||||
transform.localEulerAngles = EnterGameEulerAngles;
|
||||
transform.localScale = EnterGameLocalScaling;
|
||||
gameObject.SetActive(IsSetObjectDisable == false);
|
||||
transform.localPosition = Config.EnterGameLocalPosition;
|
||||
transform.localEulerAngles = Config.EnterGameEulerAngles;
|
||||
transform.localScale = Config.EnterGameLocalScaling;
|
||||
gameObject.SetActive(Config.IsSetObjectDisable == false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,12 +194,12 @@ namespace Demo
|
||||
/// </summary>
|
||||
public partial class ScriptableObject
|
||||
{
|
||||
public readonly Dictionary<string, float> ScriptableObjectContents = new();
|
||||
private NativeHashMap<int, float> ScriptableObjectContents;
|
||||
|
||||
[Convention.RScript.Variable.Attr.Method]
|
||||
public float GetContent(string key)
|
||||
{
|
||||
if (ScriptableObjectContents.TryGetValue(key, out var result))
|
||||
if (ScriptableObjectContents.IsCreated && ScriptableObjectContents.TryGetValue(key.GetHashCode(), out var result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
@@ -126,7 +209,11 @@ namespace Demo
|
||||
[Convention.RScript.Variable.Attr.Method]
|
||||
public float SetContent(string key, float value)
|
||||
{
|
||||
ScriptableObjectContents[key] = value;
|
||||
if (ScriptableObjectContents.IsCreated == false)
|
||||
{
|
||||
ScriptableObjectContents = new(8, AllocatorManager.Persistent);
|
||||
}
|
||||
ScriptableObjectContents[key.GetHashCode()] = value;
|
||||
return value;
|
||||
}
|
||||
}
|
||||
@@ -140,7 +227,11 @@ namespace Demo
|
||||
public static float OneBarTime = 60;
|
||||
|
||||
private bool isEnableScript = false;
|
||||
public string ScriptName = "";
|
||||
public string ScriptName
|
||||
{
|
||||
get => Config.ScriptName;
|
||||
set => Config.ScriptName = value;
|
||||
}
|
||||
private string s_ScriptType = null;
|
||||
public string m_ScriptType
|
||||
{
|
||||
@@ -155,6 +246,7 @@ namespace Demo
|
||||
public ScriptableObject Parent;
|
||||
public readonly List<ScriptableObject> Childs = new();
|
||||
|
||||
private RootObject rootObjectCache = null;
|
||||
/// <summary>
|
||||
/// 获取根脚本对象
|
||||
/// </summary>
|
||||
@@ -162,12 +254,16 @@ namespace Demo
|
||||
[Convention.RScript.Variable.Attr.Method]
|
||||
public RootObject GetRoot()
|
||||
{
|
||||
if (Parent == null)
|
||||
return this as RootObject;
|
||||
if (Parent is RootObject result)
|
||||
return result;
|
||||
else
|
||||
return Parent.GetRoot();
|
||||
if (rootObjectCache == null)
|
||||
{
|
||||
if (Parent == null)
|
||||
rootObjectCache = this as RootObject;
|
||||
else if (Parent is RootObject result)
|
||||
rootObjectCache = result;
|
||||
else
|
||||
rootObjectCache = Parent.GetRoot();
|
||||
}
|
||||
return rootObjectCache;
|
||||
}
|
||||
|
||||
|
||||
@@ -242,7 +338,7 @@ namespace Demo
|
||||
return result;
|
||||
}
|
||||
|
||||
public void EnableScript(ScriptableObject parent)
|
||||
public void EnableScript(ScriptableObject parent,int uid = -1)
|
||||
{
|
||||
if (isEnableScript)
|
||||
{
|
||||
@@ -250,13 +346,26 @@ namespace Demo
|
||||
return;
|
||||
}
|
||||
this.Parent = parent;
|
||||
if (parent != null)
|
||||
this.ScriptableObjectContents.AddRange(parent.ScriptableObjectContents);
|
||||
if (parent != null && parent.ScriptableObjectContents.IsCreated)
|
||||
{
|
||||
if (ScriptableObjectContents.IsCreated == false)
|
||||
{
|
||||
ScriptableObjectContents = new(parent.ScriptableObjectContents.Count, AllocatorManager.Persistent);
|
||||
}
|
||||
foreach (var item in parent.ScriptableObjectContents)
|
||||
{
|
||||
this.ScriptableObjectContents[item.Key] = item.Value;
|
||||
}
|
||||
}
|
||||
|
||||
this.name = ScriptName;
|
||||
|
||||
isEnableScript = true;
|
||||
// 只有RootObject的parent会是空的
|
||||
if (uid < 0)
|
||||
Config.UID = GetRoot().PushLoadedScriptObject(this);
|
||||
else
|
||||
GetRoot().PushLoadedScriptObject(this, uid);
|
||||
if (parent != null)
|
||||
{
|
||||
MyHierarchyItem = parent.MyHierarchyItem.GetHierarchyItem().CreateSubPropertyItem(1)[0];
|
||||
@@ -332,6 +441,7 @@ namespace Demo
|
||||
// 获取文件
|
||||
var file = new ToolFile(GetRoot().SourcePath);
|
||||
file = file | path;
|
||||
GetRoot().LoadedScriptSet.Add(file);
|
||||
// 找不到脚本
|
||||
if (file.Exists() == false)
|
||||
{
|
||||
@@ -444,7 +554,7 @@ namespace Demo
|
||||
else
|
||||
{
|
||||
// UpdateTicks
|
||||
if (ScriptUpdateCounter % UpdatePerFrame == 0)
|
||||
if (ScriptUpdateCounter % Config.UpdatePerFrame == 0)
|
||||
UpdateTicks(currentTime, deltaTime, tickType);
|
||||
ScriptUpdateCounter += tickType == TickType.Update ? 1 : 0;
|
||||
}
|
||||
@@ -539,7 +649,8 @@ namespace Demo
|
||||
}
|
||||
// 释放资源
|
||||
{
|
||||
this.ScriptableObjectContents.Clear();
|
||||
if (this.ScriptableObjectContents.IsCreated)
|
||||
this.ScriptableObjectContents.Dispose();
|
||||
}
|
||||
IsScriptApply = true;
|
||||
}
|
||||
@@ -568,9 +679,12 @@ namespace Demo
|
||||
MyHierarchyItem.Release();
|
||||
MyHierarchyItem = null;
|
||||
}
|
||||
this.isEnableScript = false;
|
||||
this.Parent = null;
|
||||
this.name = "<Unload>";
|
||||
if (this /*防假空*/)
|
||||
{
|
||||
this.isEnableScript = false;
|
||||
this.Parent = null;
|
||||
this.name = "<Unload>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -699,31 +813,28 @@ namespace Demo
|
||||
public static PropertiesWindow TimelineWindow;
|
||||
private PropertiesWindow.ItemEntry MyTimelineEntry;
|
||||
private Editor.UI.TimelineItem MyTimelineItem;
|
||||
//[SerializeField] private bool IsTimelineItemShow = false;
|
||||
private static List<TimelineScriptObject> TimelineScriptObjectWhichOnShow = new();
|
||||
|
||||
private static UnityEngine.UI.Image CacheLastFocusImage;
|
||||
private static Color CacheLastFocusImageOriginColor = new(1, 1, 1, 0.01f);
|
||||
private static Color FocusImageColor = new(1f, 47f / 51f, 0.0156862754f, 0.1f);
|
||||
|
||||
[Content, SerializeField] private bool IsEnableTimelineItem = false;
|
||||
|
||||
[Convention.RScript.Variable.Attr.Method]
|
||||
public void EnableTimelineItem()
|
||||
public override IEnumerator UnloadScript()
|
||||
{
|
||||
IsEnableTimelineItem = true;
|
||||
yield return base.UnloadScript();
|
||||
// 这里的两处判空是因为如果抛出错误就会打断了逻辑, 所以这里需要判断
|
||||
if (MyTimelineItem != null)
|
||||
{
|
||||
MyTimelineItem.RawButton.onClick.RemoveAllListeners();
|
||||
MyTimelineItem = null;
|
||||
}
|
||||
}
|
||||
|
||||
protected override IEnumerator DoSomethingDuringApplyScript()
|
||||
public override void OnHierarchyItemClick(HierarchyItem item)
|
||||
{
|
||||
yield return base.DoSomethingDuringApplyScript();
|
||||
if (IsEnableTimelineItem)
|
||||
if (MyTimelineEntry == null)
|
||||
{
|
||||
if (MyTimelineEntry == null)
|
||||
{
|
||||
MyTimelineEntry = TimelineWindow.CreateRootItemEntries(1)[0];
|
||||
MyTimelineItem = MyTimelineEntry.ref_value.GetComponent<Editor.UI.TimelineItem>();
|
||||
}
|
||||
MyTimelineEntry = TimelineWindow.CreateRootItemEntries(1)[0];
|
||||
MyTimelineItem = MyTimelineEntry.ref_value.GetComponent<Editor.UI.TimelineItem>();
|
||||
MyTimelineItem.title = ScriptName;
|
||||
MyTimelineItem.RawButton.onClick.RemoveAllListeners();
|
||||
MyTimelineItem.AddListener(() =>
|
||||
@@ -735,44 +846,20 @@ namespace Demo
|
||||
CacheLastFocusImage.color = FocusImageColor;
|
||||
});
|
||||
SetupTimelineItem(MyTimelineItem);
|
||||
TimelineScriptObjectWhichOnShow.Add(this);
|
||||
}
|
||||
}
|
||||
|
||||
public override IEnumerator UnloadScript()
|
||||
{
|
||||
yield return base.UnloadScript();
|
||||
// 这里的两处判空是因为如果抛出错误就会打断了逻辑, 所以这里需要判断
|
||||
if (MyTimelineItem != null)
|
||||
{
|
||||
MyTimelineItem.RawButton.onClick.RemoveAllListeners();
|
||||
MyTimelineItem = null;
|
||||
}
|
||||
if (MyTimelineEntry != null)
|
||||
else if (MyTimelineEntry != null)
|
||||
{
|
||||
MyTimelineEntry.Release();
|
||||
MyTimelineEntry = null;
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnHierarchyItemClick(HierarchyItem item)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private float UIResizeOnTimelineCount = 0;
|
||||
protected override void UpdateTicks(float currentTime, float deltaTime, TickType tickType)
|
||||
{
|
||||
base.UpdateTicks(currentTime, deltaTime, tickType);
|
||||
// 存在严重的性能开销, 在解决之前将不会允许其快速自动更新
|
||||
if (IsEnableTimelineItem)
|
||||
if (MyTimelineEntry != null)
|
||||
{
|
||||
if (UIResizeOnTimelineCount > 0.1 || tickType != TickType.Update)
|
||||
{
|
||||
UIResizeOnTimelineCount = 0;
|
||||
MyTimelineItem.ResizeOnTimeline();
|
||||
}
|
||||
UIResizeOnTimelineCount += deltaTime;
|
||||
MyTimelineItem.ResizeOnTimeline();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,8 +7,8 @@ using Dreamteck.Splines;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Demo
|
||||
@@ -17,68 +17,6 @@ namespace Demo
|
||||
{
|
||||
public static class DefaultInstantiate
|
||||
{
|
||||
public static Dictionary<string, Func<ScriptableObject>> GameObjectInstantiate = new()
|
||||
{
|
||||
{ $"{nameof(Anchor)}",Anchor.Make},
|
||||
// Camera
|
||||
{ $"{nameof(CameraObject)}",CameraObject.MakeCameraObject},
|
||||
// Global Env
|
||||
{ $"{nameof(PrefabRootObject)}",PrefabRootObject.Make },
|
||||
{ $"{nameof(SkyUpdatement)}",SkyUpdatement.Make},
|
||||
// Sub World
|
||||
{ $"{nameof(SubWorld)}",SubWorld.Make},
|
||||
};
|
||||
|
||||
public static Dictionary<string, Func<ScriptableObject>> DDTInstantiate = new()
|
||||
{
|
||||
{ $"{nameof(DDT)}",DDT.Make}
|
||||
};
|
||||
|
||||
public static Dictionary<string, Func<ScriptableObject>> TickUpdatementInstantiate = new()
|
||||
{
|
||||
{ $"{nameof(LookAtAnchor)}",LookAtAnchor.Make},
|
||||
{ $"{nameof(TickMovement)}",TickMovement.Make},
|
||||
{ $"{nameof(TickRotation)}",TickRotation.Make},
|
||||
{ $"{nameof(TickScaling)}",TickScaling.Make},
|
||||
};
|
||||
|
||||
public static Dictionary<string, Func<ScriptableObject>> MaterialUpdatementInstantiate = new()
|
||||
{
|
||||
{ $"{nameof(MaterialUpdatement)}",MaterialUpdatement.Make},
|
||||
{ $"{nameof(ColorUpdatement)}",ColorUpdatement.Make},
|
||||
{ $"{nameof(EmissionColorUpdatement)}",EmissionColorUpdatement.Make},
|
||||
};
|
||||
|
||||
public static Dictionary<string, Func<ScriptableObject>> SplineInstantiate = new()
|
||||
{
|
||||
{ $"{nameof(SplineCore)}",SplineCore.Make},
|
||||
{ $"{nameof(SplineNode)}",SplineNode.Make},
|
||||
{ $"{nameof(SplineAnchor)}",SplineAnchor.Make},
|
||||
{ $"{nameof(SplineMovement)}",SplineMovement.Make},
|
||||
{ $"{nameof(SplineRotation)}",SplineRotation.Make},
|
||||
{ $"{nameof(SplineScaling)}",SplineScaling.Make},
|
||||
{ $"{nameof(SplinePointerObject)}",SplinePointerObject.Make},
|
||||
{ $"{nameof(SplineTrackRenderer)}",SplineTrackRenderer.Make},
|
||||
{ $"{nameof(SplineTubeRenderer)}",SplineTubeRenderer.Make},
|
||||
{ $"{nameof(SplineSurfaceRenderer)}",SplineSurfaceRenderer.Make},
|
||||
{ $"{nameof(SplineRenderer)}",SplineRenderer.Make},
|
||||
};
|
||||
|
||||
public static Dictionary<string, Func<ScriptableObject>> JudgementInstantiate = new()
|
||||
{
|
||||
// 可判定物只能有一个种类被使用,否则会引起输入检定冲突
|
||||
{ $"{nameof(FullScreenInteraction)}",FullScreenInteraction.Make},
|
||||
// Effect
|
||||
{ $"{nameof(ParticleEffect)}",ParticleEffect.Make },
|
||||
// JudgementEffect
|
||||
{ $"{nameof(ParticleJudgement)}",ParticleJudgement.Make},
|
||||
};
|
||||
|
||||
public static Dictionary<string, Func<ScriptableObject>> SingleVolumeInstantiate = new()
|
||||
{
|
||||
{ $"{nameof(MotionBlurVolume)}", MotionBlurVolume.Make }
|
||||
};
|
||||
|
||||
public static void OpenInstantiateMenu(this ScriptableObject self, RectTransform item)
|
||||
{
|
||||
List<SharedModule.CallbackData> result = new()
|
||||
@@ -95,17 +33,34 @@ namespace Demo
|
||||
SharedModule.instance.OpenCustomMenu(item, result.ToArray());
|
||||
}
|
||||
|
||||
static DefaultInstantiate()
|
||||
{
|
||||
s_ScriptableObjectInstantiate = new();
|
||||
ScriptableObjectTypename2ID = new();
|
||||
ScriptableObjectID2Typename = new();
|
||||
int cnt = 0;
|
||||
foreach (var type in Utility.SeekType(x => x.IsSubclassOf(typeof(ScriptableObject)) && x.GetCustomAttribute<Attr.ScriptableAttribute>() != null))
|
||||
{
|
||||
var attr = type.GetCustomAttribute<Attr.ScriptableAttribute>();
|
||||
s_ScriptableObjectInstantiate.Add(type.Name, () => (ScriptableObject)ConventionUtility.InvokeMember(type.GetMethod(attr.generaterName), null));
|
||||
}
|
||||
var typelist = s_ScriptableObjectInstantiate.Keys.ToList();
|
||||
typelist.Sort();
|
||||
foreach (var type in typelist)
|
||||
{
|
||||
ScriptableObjectTypename2ID.Add(type, cnt);
|
||||
ScriptableObjectID2Typename.Add(cnt, type);
|
||||
cnt++;
|
||||
}
|
||||
}
|
||||
|
||||
private static Dictionary<string, Func<ScriptableObject>> s_ScriptableObjectInstantiate;
|
||||
public readonly static Dictionary<string, int> ScriptableObjectTypename2ID;
|
||||
public readonly static Dictionary<int, string> ScriptableObjectID2Typename;
|
||||
|
||||
public static Dictionary<string, Func<ScriptableObject>> GetScriptableObjectInstantiate()
|
||||
{
|
||||
return s_ScriptableObjectInstantiate ??= new Dictionary<string, Func<ScriptableObject>>(GameObjectInstantiate
|
||||
.Union(DDTInstantiate)
|
||||
.Union(TickUpdatementInstantiate)
|
||||
.Union(MaterialUpdatementInstantiate)
|
||||
.Union(SplineInstantiate)
|
||||
.Union(JudgementInstantiate)
|
||||
.Union(SingleVolumeInstantiate));
|
||||
return s_ScriptableObjectInstantiate;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -212,31 +167,33 @@ namespace Demo
|
||||
}
|
||||
}
|
||||
|
||||
public partial class ScriptableObject
|
||||
namespace Game
|
||||
{
|
||||
protected virtual bool IsImptSerialize => false;
|
||||
protected virtual IEnumerator LoadFromImptCacheFile(ToolFile cacheFile)
|
||||
public partial class ScriptableObject
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
protected virtual IEnumerator CreateAndLoadingImptCacheFile(ToolFile scriptFile, ToolFile cacheFile)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
protected virtual bool IsImptSerialize => false;
|
||||
protected virtual IEnumerator LoadFromImptCacheFile(ToolFile cacheFile)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
protected virtual IEnumerator CreateAndLoadingImptCacheFile(ToolFile scriptFile, ToolFile cacheFile)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private readonly RScriptImportClass s_GenerateImport = new()
|
||||
private readonly RScriptImportClass s_GenerateImport = new()
|
||||
{
|
||||
typeof(Mathf),
|
||||
typeof(RandomTool),
|
||||
};
|
||||
public RScriptImportClass GenerateImport()
|
||||
{
|
||||
return s_GenerateImport;
|
||||
}
|
||||
public RScriptImportClass GenerateImport()
|
||||
{
|
||||
return s_GenerateImport;
|
||||
}
|
||||
|
||||
public RScriptVariables GenerateVariables(ScriptableObject self)
|
||||
{
|
||||
RScriptVariables variables = new()
|
||||
public RScriptVariables GenerateVariables(ScriptableObject self)
|
||||
{
|
||||
RScriptVariables variables = new()
|
||||
{
|
||||
{ "this", new() { data = self, type = self.GetType() } },
|
||||
{ "self", new() { data = self, type = self.GetType() } },
|
||||
@@ -251,101 +208,102 @@ namespace Demo
|
||||
{ nameof(IInteraction.JudgementLevel),
|
||||
new() { data = IInteractionJudgementLevelInstance.instance, type = typeof(IInteractionJudgementLevelInstance) } }
|
||||
};
|
||||
return variables;
|
||||
}
|
||||
return variables;
|
||||
}
|
||||
|
||||
private static readonly Dictionary<string, object> s_FileLocker = new();
|
||||
private static readonly Dictionary<string, object> s_FileLocker = new();
|
||||
|
||||
public IEnumerator ParseFromScriptFile2Expr(ToolFile file)
|
||||
{
|
||||
IsParseScript2Expr = true;
|
||||
try
|
||||
public IEnumerator ParseFromScriptFile2Expr(ToolFile file)
|
||||
{
|
||||
var hash = file.CalculateHash();
|
||||
var lastHashFile = file.GetParentDir() | ".cache" | $"{file.GetFilename(true)}.hash";
|
||||
var bin = file.GetParentDir() | ".cache" | $"{file.GetFilename(true)}.bin";
|
||||
if (IsImptSerialize)
|
||||
IsParseScript2Expr = true;
|
||||
try
|
||||
{
|
||||
if (lastHashFile.Exists() == false || lastHashFile.LoadAsText() != hash)
|
||||
var hash = file.CalculateHash();
|
||||
var lastHashFile = file.GetParentDir() | ".cache" | $"{file.GetFilename(true)}.hash";
|
||||
var bin = file.GetParentDir() | ".cache" | $"{file.GetFilename(true)}.bin";
|
||||
if (IsImptSerialize)
|
||||
{
|
||||
lastHashFile.MustExistsPath();
|
||||
lastHashFile.SaveAsText(hash);
|
||||
yield return ConventionUtility.AvoidFakeStop(CreateAndLoadingImptCacheFile(file, bin));
|
||||
if (lastHashFile.Exists() == false || lastHashFile.LoadAsText() != hash)
|
||||
{
|
||||
lastHashFile.MustExistsPath();
|
||||
lastHashFile.SaveAsText(hash);
|
||||
yield return ConventionUtility.AvoidFakeStop(CreateAndLoadingImptCacheFile(file, bin));
|
||||
}
|
||||
else
|
||||
{
|
||||
yield return ConventionUtility.AvoidFakeStop(LoadFromImptCacheFile(bin));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
yield return ConventionUtility.AvoidFakeStop(LoadFromImptCacheFile(bin));
|
||||
IEnumerator step = null;
|
||||
RScriptEngine engine = new();
|
||||
RScriptImportClass importClass = GenerateImport();
|
||||
RScriptVariables variables = GenerateVariables(this);
|
||||
object locker;
|
||||
if (lastHashFile.Exists() == false || lastHashFile.LoadAsText() != hash)
|
||||
{
|
||||
lastHashFile.MustExistsPath();
|
||||
bin.MustExistsPath();
|
||||
lastHashFile.SaveAsText(hash);
|
||||
var script = file.LoadAsText();
|
||||
|
||||
var structBin = engine.Compile(script, importClass, variables);
|
||||
lock (s_FileLocker)
|
||||
{
|
||||
if (s_FileLocker.TryGetValue(file.GetFullPath(), out locker) == false)
|
||||
{
|
||||
s_FileLocker.Add(file.GetFullPath(), locker = new object());
|
||||
}
|
||||
}
|
||||
lock (locker)
|
||||
{
|
||||
bin.SaveAsBinary(RScriptSerializer.SerializeClass(structBin));
|
||||
}
|
||||
step = engine.RunAsync(script, importClass, variables);
|
||||
}
|
||||
else
|
||||
{
|
||||
RScriptContext.SerializableClass structBin;
|
||||
lock (s_FileLocker)
|
||||
{
|
||||
if (s_FileLocker.TryGetValue(file.GetFullPath(), out locker) == false)
|
||||
{
|
||||
s_FileLocker.Add(file.GetFullPath(), locker = new object());
|
||||
}
|
||||
}
|
||||
lock (locker)
|
||||
{
|
||||
structBin = RScriptSerializer.DeserializeClass(bin.LoadAsBinary());
|
||||
}
|
||||
step = engine.RunAsync(structBin, importClass, variables);
|
||||
|
||||
}
|
||||
yield return step;// ConventionUtility.AvoidFakeStop(step);
|
||||
}
|
||||
}
|
||||
else
|
||||
finally
|
||||
{
|
||||
IsParseScript2Expr = false;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerator ParseScript2Expr(string script)
|
||||
{
|
||||
IsParseScript2Expr = true;
|
||||
try
|
||||
{
|
||||
IEnumerator step = null;
|
||||
RScriptEngine engine = new();
|
||||
RScriptImportClass importClass = GenerateImport();
|
||||
RScriptVariables variables = GenerateVariables(this);
|
||||
object locker;
|
||||
if (lastHashFile.Exists() == false || lastHashFile.LoadAsText() != hash)
|
||||
{
|
||||
lastHashFile.MustExistsPath();
|
||||
bin.MustExistsPath();
|
||||
lastHashFile.SaveAsText(hash);
|
||||
var script = file.LoadAsText();
|
||||
|
||||
var structBin = engine.Compile(script, importClass, variables);
|
||||
lock (s_FileLocker)
|
||||
{
|
||||
if (s_FileLocker.TryGetValue(file.GetFullPath(), out locker) == false)
|
||||
{
|
||||
s_FileLocker.Add(file.GetFullPath(), locker = new object());
|
||||
}
|
||||
}
|
||||
lock (locker)
|
||||
{
|
||||
bin.SaveAsBinary(RScriptSerializer.SerializeClass(structBin));
|
||||
}
|
||||
step = engine.RunAsync(script, importClass, variables);
|
||||
}
|
||||
else
|
||||
{
|
||||
RScriptContext.SerializableClass structBin;
|
||||
lock (s_FileLocker)
|
||||
{
|
||||
if (s_FileLocker.TryGetValue(file.GetFullPath(), out locker) == false)
|
||||
{
|
||||
s_FileLocker.Add(file.GetFullPath(), locker = new object());
|
||||
}
|
||||
}
|
||||
lock (locker)
|
||||
{
|
||||
structBin = RScriptSerializer.DeserializeClass(bin.LoadAsBinary());
|
||||
}
|
||||
step = engine.RunAsync(structBin, importClass, variables);
|
||||
|
||||
}
|
||||
yield return step;// ConventionUtility.AvoidFakeStop(step);
|
||||
var step = engine.RunAsync(script, importClass, variables);
|
||||
yield return step;//ConventionUtility.AvoidFakeStop(step);
|
||||
}
|
||||
finally
|
||||
{
|
||||
IsParseScript2Expr = false;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
IsParseScript2Expr = false;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerator ParseScript2Expr(string script)
|
||||
{
|
||||
IsParseScript2Expr = true;
|
||||
try
|
||||
{
|
||||
RScriptEngine engine = new();
|
||||
RScriptImportClass importClass = GenerateImport();
|
||||
RScriptVariables variables = GenerateVariables(this);
|
||||
|
||||
var step = engine.RunAsync(script, importClass, variables);
|
||||
yield return step;//ConventionUtility.AvoidFakeStop(step);
|
||||
}
|
||||
finally
|
||||
{
|
||||
IsParseScript2Expr = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +1,46 @@
|
||||
using Convention;
|
||||
using Demo.Game.Attr;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Convention;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
namespace Demo.Game
|
||||
{
|
||||
public class SubWorld : ScriptableObject
|
||||
namespace ConfigType
|
||||
{
|
||||
// SubWorld 配置
|
||||
public class SubWorldConfig : ScriptLoadableConfig
|
||||
{
|
||||
public string project;
|
||||
|
||||
public override void Deserialize(BinaryReader reader)
|
||||
{
|
||||
project = BinarySerializeUtility.ReadString(reader);
|
||||
base.Deserialize(reader);
|
||||
}
|
||||
|
||||
public override void Serialize(BinaryWriter writer)
|
||||
{
|
||||
BinarySerializeUtility.WriteString(writer, project);
|
||||
base.Serialize(writer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Scriptable]
|
||||
public class SubWorld : ScriptableObject
|
||||
{
|
||||
protected override ConfigType.ScriptLoadableConfig MakeConfig()
|
||||
{
|
||||
return new ConfigType.SubWorldConfig();
|
||||
}
|
||||
public static SubWorld Make()
|
||||
{
|
||||
return new GameObject().AddComponent<SubWorld>();
|
||||
}
|
||||
|
||||
[Content, SerializeField] private string project;
|
||||
[Content, SerializeField] private GameController SubWorldGameController;
|
||||
|
||||
protected override IEnumerator DoSomethingDuringApplyScript()
|
||||
@@ -23,8 +49,8 @@ namespace Demo.Game
|
||||
var ir = SceneManager.LoadSceneAsync(Editor.EditorController.SceneName, LoadSceneMode.Additive);
|
||||
ir.completed += x =>
|
||||
{
|
||||
SubWorldGameController = (from controller in FindObjectsOfType<GameController>()
|
||||
where controller.RootSourcePath == project
|
||||
SubWorldGameController = (from controller in FindObjectsByType<GameController>(FindObjectsSortMode.None)
|
||||
where controller.RootSourcePath == GetConfig<ConfigType.SubWorldConfig>().project
|
||||
select controller).First();
|
||||
ConventionUtility.StartCoroutine(SubWorldGameController.GameInitBySubWorld(GetRoot().InputCatch));
|
||||
};
|
||||
@@ -43,7 +69,7 @@ namespace Demo.Game
|
||||
[Convention.RScript.Variable.Attr.Method]
|
||||
public void Load(string project)
|
||||
{
|
||||
this.project = project;
|
||||
GetConfig<ConfigType.SubWorldConfig>().project = project;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,112 @@
|
||||
using Convention;
|
||||
using Demo.Editor.UI;
|
||||
using Demo.Game.ConfigType;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Unity.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Demo.Game
|
||||
{
|
||||
namespace ConfigType
|
||||
{
|
||||
public abstract class UpdatementConfig<DataType>: ScriptLoadableConfig where DataType : struct
|
||||
{
|
||||
public NativeArray<float> TimePoints;
|
||||
public NativeArray<DataType> Positions;
|
||||
public NativeArray<MathExtension.EaseCurveType> EaseCurveTypes;
|
||||
|
||||
protected abstract void DeserializePositions(BinaryReader reader, ref NativeArray<DataType> positions);
|
||||
protected abstract void SerializePositions(BinaryWriter writer, in NativeArray<DataType> positions);
|
||||
|
||||
public override void Deserialize(BinaryReader reader)
|
||||
{
|
||||
BinarySerializeUtility.DeserializeNativeArray(reader, ref TimePoints);
|
||||
DeserializePositions(reader, ref Positions);
|
||||
{
|
||||
NativeArray<int> temp = new(EaseCurveTypes.Length, Allocator.Temp, NativeArrayOptions.UninitializedMemory);
|
||||
BinarySerializeUtility.DeserializeNativeArray(reader, ref temp);
|
||||
for (int i = 0, e = EaseCurveTypes.Length; i < e; i++)
|
||||
{
|
||||
EaseCurveTypes[i] = (MathExtension.EaseCurveType)temp[i];
|
||||
}
|
||||
temp.Dispose();
|
||||
}
|
||||
base.Deserialize(reader);
|
||||
}
|
||||
|
||||
public override void Serialize(BinaryWriter writer)
|
||||
{
|
||||
BinarySerializeUtility.SerializeNativeArray(writer, TimePoints);
|
||||
SerializePositions(writer, Positions);
|
||||
{
|
||||
NativeArray<int> temp = new(EaseCurveTypes.Length, Allocator.Temp, NativeArrayOptions.UninitializedMemory);
|
||||
for (int i = 0, e = EaseCurveTypes.Length; i < e; i++)
|
||||
{
|
||||
temp[i] = (int)EaseCurveTypes[i];
|
||||
}
|
||||
BinarySerializeUtility.SerializeNativeArray(writer, temp);
|
||||
temp.Dispose();
|
||||
}
|
||||
base.Serialize(writer);
|
||||
}
|
||||
}
|
||||
|
||||
public class UpdatementIntConfig : UpdatementConfig<int>
|
||||
{
|
||||
protected override sealed void DeserializePositions(BinaryReader reader, ref NativeArray<int> positions)
|
||||
{
|
||||
BinarySerializeUtility.DeserializeNativeArray(reader, ref positions);
|
||||
}
|
||||
|
||||
protected override sealed void SerializePositions(BinaryWriter writer, in NativeArray<int> positions)
|
||||
{
|
||||
BinarySerializeUtility.SerializeNativeArray(writer, positions);
|
||||
}
|
||||
}
|
||||
|
||||
public class UpdatementFloatConfig : UpdatementConfig<float>
|
||||
{
|
||||
protected override sealed void DeserializePositions(BinaryReader reader, ref NativeArray<float> positions)
|
||||
{
|
||||
BinarySerializeUtility.DeserializeNativeArray(reader, ref positions);
|
||||
}
|
||||
|
||||
protected override sealed void SerializePositions(BinaryWriter writer, in NativeArray<float> positions)
|
||||
{
|
||||
BinarySerializeUtility.SerializeNativeArray(writer, positions);
|
||||
}
|
||||
}
|
||||
|
||||
public class UpdatementVec2Config : UpdatementConfig<Vector2>
|
||||
{
|
||||
protected override sealed void DeserializePositions(BinaryReader reader, ref NativeArray<Vector2> positions)
|
||||
{
|
||||
BinarySerializeUtility.DeserializeNativeArray(reader, ref positions);
|
||||
}
|
||||
|
||||
protected override sealed void SerializePositions(BinaryWriter writer, in NativeArray<Vector2> positions)
|
||||
{
|
||||
BinarySerializeUtility.SerializeNativeArray(writer, positions);
|
||||
}
|
||||
}
|
||||
|
||||
public class UpdatementVec3Config : UpdatementConfig<Vector3>
|
||||
{
|
||||
protected override sealed void DeserializePositions(BinaryReader reader, ref NativeArray<Vector3> positions)
|
||||
{
|
||||
BinarySerializeUtility.DeserializeNativeArray(reader, ref positions);
|
||||
}
|
||||
|
||||
protected override sealed void SerializePositions(BinaryWriter writer, in NativeArray<Vector3> positions)
|
||||
{
|
||||
BinarySerializeUtility.SerializeNativeArray(writer, positions);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class Updatement<DataType> : TimelineScriptObject where DataType : struct
|
||||
{
|
||||
[Serializable]
|
||||
@@ -17,39 +116,9 @@ namespace Demo.Game
|
||||
public DataType Position = default;
|
||||
public MathExtension.EaseCurveType easeCurveType = MathExtension.EaseCurveType.Linear;
|
||||
}
|
||||
[Serializable]
|
||||
public struct UpdatementCompiledEntries: IDisposable
|
||||
{
|
||||
public NativeArray<float> TimePoints;
|
||||
public NativeArray<DataType> Positions;
|
||||
public NativeArray<MathExtension.EaseCurveType> EaseCurveTypes;
|
||||
public readonly int Count;
|
||||
|
||||
public UpdatementCompiledEntries(NativeArray<float> timePoints,
|
||||
NativeArray<DataType> positions,
|
||||
NativeArray<MathExtension.EaseCurveType> easeCurveTypes,
|
||||
int count)
|
||||
{
|
||||
TimePoints = timePoints;
|
||||
Positions = positions;
|
||||
EaseCurveTypes = easeCurveTypes;
|
||||
Count = count;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (TimePoints.IsCreated)
|
||||
TimePoints.Dispose();
|
||||
if (Positions.IsCreated)
|
||||
Positions.Dispose();
|
||||
if (EaseCurveTypes.IsCreated)
|
||||
EaseCurveTypes.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
public int Content = 0;
|
||||
private readonly List<UpdatementEntry> Entries = new();
|
||||
public UpdatementCompiledEntries CompiledEntries;
|
||||
protected abstract void UpdateData(DataType data);
|
||||
protected abstract DataType Lerp(DataType begin, DataType end, float t);
|
||||
|
||||
@@ -72,18 +141,15 @@ namespace Demo.Game
|
||||
private void BuildupCompiledEntriesAndReleaseEntries()
|
||||
{
|
||||
Entries.Sort((x, y) => x.TimePoint.CompareTo(y.TimePoint));
|
||||
CompiledEntries = new(
|
||||
new NativeArray<float>(Entries.Count, Allocator.Persistent, NativeArrayOptions.UninitializedMemory),
|
||||
new NativeArray<DataType>(Entries.Count, Allocator.Persistent, NativeArrayOptions.UninitializedMemory),
|
||||
new NativeArray<MathExtension.EaseCurveType>(Entries.Count, Allocator.Persistent, NativeArrayOptions.UninitializedMemory),
|
||||
Entries.Count
|
||||
);
|
||||
GetConfig<UpdatementConfig<DataType>>().TimePoints = new NativeArray<float>(Entries.Count, Allocator.Persistent, NativeArrayOptions.UninitializedMemory);
|
||||
GetConfig<UpdatementConfig<DataType>>().Positions = new NativeArray<DataType>(Entries.Count, Allocator.Persistent, NativeArrayOptions.UninitializedMemory);
|
||||
GetConfig<UpdatementConfig<DataType>>().EaseCurveTypes = new NativeArray<MathExtension.EaseCurveType>(Entries.Count, Allocator.Persistent, NativeArrayOptions.UninitializedMemory);
|
||||
int index = 0;
|
||||
foreach (var item in Entries)
|
||||
{
|
||||
CompiledEntries.TimePoints[index] = item.TimePoint;
|
||||
CompiledEntries.Positions[index] = item.Position;
|
||||
CompiledEntries.EaseCurveTypes[index] = item.easeCurveType;
|
||||
GetConfig<UpdatementConfig<DataType>>().TimePoints[index] = item.TimePoint;
|
||||
GetConfig<UpdatementConfig<DataType>>().Positions[index] = item.Position;
|
||||
GetConfig<UpdatementConfig<DataType>>().EaseCurveTypes[index] = item.easeCurveType;
|
||||
index++;
|
||||
}
|
||||
Entries.Clear();
|
||||
@@ -92,10 +158,10 @@ namespace Demo.Game
|
||||
private void UpdateEntry(int start, float percent)
|
||||
{
|
||||
int head = start;
|
||||
int tail = Mathf.Min(start + 1, CompiledEntries.Count - 1);
|
||||
UpdateData(Lerp(CompiledEntries.Positions[start],
|
||||
CompiledEntries.Positions[tail],
|
||||
MathExtension.Evaluate(Mathf.Clamp01(percent), CompiledEntries.EaseCurveTypes[head])));
|
||||
int tail = Mathf.Min(start + 1, GetConfig<UpdatementConfig<DataType>>().TimePoints.Length - 1);
|
||||
UpdateData(Lerp(GetConfig<UpdatementConfig<DataType>>().Positions[start],
|
||||
GetConfig<UpdatementConfig<DataType>>().Positions[tail],
|
||||
MathExtension.Evaluate(Mathf.Clamp01(percent), GetConfig<UpdatementConfig<DataType>>().EaseCurveTypes[head])));
|
||||
}
|
||||
|
||||
protected override IEnumerator DoSomethingDuringApplyScript()
|
||||
@@ -111,7 +177,7 @@ namespace Demo.Game
|
||||
public override void ResetEnterGameStatus()
|
||||
{
|
||||
base.ResetEnterGameStatus();
|
||||
if (CompiledEntries.Count <= 1)
|
||||
if (GetConfig<UpdatementConfig<DataType>>().TimePoints.Length <= 1)
|
||||
return;
|
||||
UpdateEntry(0, 0);
|
||||
}
|
||||
@@ -119,7 +185,9 @@ namespace Demo.Game
|
||||
public override IEnumerator UnloadScript()
|
||||
{
|
||||
Content = 0;
|
||||
CompiledEntries = default;
|
||||
GetConfig<UpdatementConfig<DataType>>().TimePoints.Dispose();
|
||||
GetConfig<UpdatementConfig<DataType>>().Positions.Dispose();
|
||||
GetConfig<UpdatementConfig<DataType>>().EaseCurveTypes.Dispose();
|
||||
yield return base.UnloadScript();
|
||||
}
|
||||
|
||||
@@ -129,12 +197,12 @@ namespace Demo.Game
|
||||
|
||||
float GetPercentValue()
|
||||
{
|
||||
if (Content + 1 == CompiledEntries.Count)
|
||||
if (Content + 1 == GetConfig<UpdatementConfig<DataType>>().TimePoints.Length)
|
||||
return 1;
|
||||
return (currentTime - CompiledEntries.TimePoints[Content]) / (CompiledEntries.TimePoints[Content + 1] - CompiledEntries.TimePoints[Content]);
|
||||
return (currentTime - GetConfig<UpdatementConfig<DataType>>().TimePoints[Content]) / (GetConfig<UpdatementConfig<DataType>>().TimePoints[Content + 1] - GetConfig<UpdatementConfig<DataType>>().TimePoints[Content]);
|
||||
}
|
||||
|
||||
if (CompiledEntries.Count <= 1)
|
||||
if (GetConfig<UpdatementConfig<DataType>>().TimePoints.Length <= 1)
|
||||
return;
|
||||
switch (tickType)
|
||||
{
|
||||
@@ -142,17 +210,17 @@ namespace Demo.Game
|
||||
case TickType.Start:
|
||||
{
|
||||
Content = 0;
|
||||
while (Content + 1 < CompiledEntries.Count && CompiledEntries.TimePoints[Content + 1] < currentTime)
|
||||
while (Content + 1 < GetConfig<UpdatementConfig<DataType>>().TimePoints.Length && GetConfig<UpdatementConfig<DataType>>().TimePoints[Content + 1] < currentTime)
|
||||
Content++;
|
||||
UpdateEntry(Content, GetPercentValue());
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (CompiledEntries.TimePoints[0] > currentTime)
|
||||
if (GetConfig<UpdatementConfig<DataType>>().TimePoints[0] > currentTime)
|
||||
return;
|
||||
if (Content + 1 < CompiledEntries.Count && CompiledEntries.TimePoints[Content + 1] < currentTime)
|
||||
if (Content + 1 < GetConfig<UpdatementConfig<DataType>>().TimePoints.Length && GetConfig<UpdatementConfig<DataType>>().TimePoints[Content + 1] < currentTime)
|
||||
Content++;
|
||||
if (Content + 1 > CompiledEntries.Count)
|
||||
if (Content + 1 > GetConfig<UpdatementConfig<DataType>>().TimePoints.Length)
|
||||
return;
|
||||
UpdateEntry(Content, GetPercentValue());
|
||||
break;
|
||||
@@ -161,21 +229,22 @@ namespace Demo.Game
|
||||
|
||||
public DataType Evaluate(float time)
|
||||
{
|
||||
if (CompiledEntries.Count == 0)
|
||||
if (GetConfig<UpdatementConfig<DataType>>().TimePoints.Length == 0)
|
||||
return default;
|
||||
if (CompiledEntries.Count == 1)
|
||||
return CompiledEntries.Positions[0];
|
||||
if (time < CompiledEntries.TimePoints[0])
|
||||
return CompiledEntries.Positions[0];
|
||||
for (int i = 1; i < CompiledEntries.Count; i++)
|
||||
if (GetConfig<UpdatementConfig<DataType>>().TimePoints.Length == 1)
|
||||
return GetConfig<UpdatementConfig<DataType>>().Positions[0];
|
||||
if (time < GetConfig<UpdatementConfig<DataType>>().TimePoints[0])
|
||||
return GetConfig<UpdatementConfig<DataType>>().Positions[0];
|
||||
for (int i = 1; i < GetConfig<UpdatementConfig<DataType>>().TimePoints.Length; i++)
|
||||
{
|
||||
if (CompiledEntries.TimePoints[i - 1] <= time && CompiledEntries.TimePoints[i] > time)
|
||||
if (GetConfig<UpdatementConfig<DataType>>().TimePoints[i - 1] <= time && GetConfig<UpdatementConfig<DataType>>().TimePoints[i] > time)
|
||||
{
|
||||
return Lerp(CompiledEntries.Positions[i - 1], CompiledEntries.Positions[i],
|
||||
(time - CompiledEntries.TimePoints[i - 1]) / (CompiledEntries.TimePoints[i] - CompiledEntries.TimePoints[i - 1]));
|
||||
return Lerp(GetConfig<UpdatementConfig<DataType>>().Positions[i - 1], GetConfig<UpdatementConfig<DataType>>().Positions[i],
|
||||
(time - GetConfig<UpdatementConfig<DataType>>().TimePoints[i - 1]) /
|
||||
(GetConfig<UpdatementConfig<DataType>>().TimePoints[i] - GetConfig<UpdatementConfig<DataType>>().TimePoints[i - 1]));
|
||||
}
|
||||
}
|
||||
return CompiledEntries.Positions[^1];
|
||||
return GetConfig<UpdatementConfig<DataType>>().Positions[^1];
|
||||
}
|
||||
|
||||
[Content] public GameObject UpdateTarget;
|
||||
@@ -195,15 +264,20 @@ namespace Demo.Game
|
||||
/// <param name="item">实例在父类中控制</param>
|
||||
protected override void SetupTimelineItem(TimelineItem item)
|
||||
{
|
||||
if (CompiledEntries.Count == 0)
|
||||
if (GetConfig<UpdatementConfig<DataType>>().TimePoints.Length == 0)
|
||||
return;
|
||||
|
||||
item.SetupDuration(new(CompiledEntries.TimePoints[0], CompiledEntries.TimePoints[^1]), GetTimelineItemColor());
|
||||
item.SetupDuration(new(GetConfig<UpdatementConfig<DataType>>().TimePoints[0], GetConfig<UpdatementConfig<DataType>>().TimePoints[^1]), GetTimelineItemColor());
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
CompiledEntries.Dispose();
|
||||
if (GetConfig<UpdatementConfig<DataType>>().TimePoints.IsCreated)
|
||||
GetConfig<UpdatementConfig<DataType>>().TimePoints.Dispose();
|
||||
if (GetConfig<UpdatementConfig<DataType>>().Positions.IsCreated)
|
||||
GetConfig<UpdatementConfig<DataType>>().Positions.Dispose();
|
||||
if (GetConfig<UpdatementConfig<DataType>>().EaseCurveTypes.IsCreated)
|
||||
GetConfig<UpdatementConfig<DataType>>().EaseCurveTypes.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Submodule Assets/Scripts/Framework/[RScript] updated: 0a7f6eb362...249a2f9ce3
@@ -1,11 +1,48 @@
|
||||
using Convention;
|
||||
using Demo.Game.Attr;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Convention;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Demo.Game
|
||||
{
|
||||
namespace ConfigType
|
||||
{
|
||||
public class ParticleEffectConfig : IEffectHookObjectConfig
|
||||
{
|
||||
public Dictionary<string, string[]> AssetBundles;
|
||||
public override void Deserialize(BinaryReader reader)
|
||||
{
|
||||
int count = BinarySerializeUtility.ReadInt(reader);
|
||||
while(count-->0)
|
||||
{
|
||||
var temp = BinarySerializeUtility.DeserializeStringArray(reader);
|
||||
var key = temp[0];
|
||||
var value = temp[1..];
|
||||
AssetBundles.Add(key, value);
|
||||
}
|
||||
base.Deserialize(reader);
|
||||
}
|
||||
|
||||
public override void Serialize(BinaryWriter writer)
|
||||
{
|
||||
BinarySerializeUtility.WriteInt(writer, AssetBundles.Count);
|
||||
foreach (var (key, value) in AssetBundles)
|
||||
{
|
||||
string[] temp = new string[value.Length + 1];
|
||||
temp[0] = key;
|
||||
Array.Copy(value, 0, temp, 1, value.Length);
|
||||
BinarySerializeUtility.SerializeArray(writer, value.ToArray());
|
||||
}
|
||||
base.Serialize(writer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Scriptable]
|
||||
public class ParticleEffect : IEffectHookObject, IAssetBundleLoader
|
||||
{
|
||||
public static ParticleEffect Make()
|
||||
@@ -13,15 +50,14 @@ namespace Demo.Game
|
||||
return new GameObject().AddComponent<ParticleEffect>();
|
||||
}
|
||||
|
||||
private Dictionary<string,bool> AssetBundleLoaders = new();
|
||||
private readonly List<string> AssetBundles = new();
|
||||
private int AssetBundleLoadingCounter = 0;
|
||||
private readonly Dictionary<string,List<string>> AssetBundles = new();
|
||||
private readonly List<GameObject> Prefabs = new();
|
||||
|
||||
protected override IEnumerator DoSomethingDuringApplyScript()
|
||||
{
|
||||
yield return base.DoSomethingDuringApplyScript();
|
||||
while (AssetBundleLoaders.Any(x => x.Value == false))
|
||||
yield return null;
|
||||
yield return new WaitUntil(() => AssetBundleLoadingCounter == 0);
|
||||
}
|
||||
|
||||
public override IEnumerator UnloadScript()
|
||||
@@ -29,7 +65,7 @@ namespace Demo.Game
|
||||
yield return base.UnloadScript();
|
||||
foreach (var ab in AssetBundles)
|
||||
{
|
||||
yield return this.UnloadAssetBundle(ab);
|
||||
yield return this.UnloadAssetBundle(ab.Key);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +77,7 @@ namespace Demo.Game
|
||||
[Convention.RScript.Variable.Attr.Method]
|
||||
public void Load(string ab, string prefab)
|
||||
{
|
||||
AssetBundleLoaders.TryAdd(ab, false);
|
||||
AssetBundleLoadingCounter++;
|
||||
ConventionUtility.StartCoroutine(this.LoadAssetBundle(ab, x =>
|
||||
{
|
||||
GameObject sub = Instantiate(x.LoadAsset<GameObject>(prefab));
|
||||
@@ -49,8 +85,10 @@ namespace Demo.Game
|
||||
Prefabs.Add(sub);
|
||||
sub.transform.SetParent(transform);
|
||||
sub.transform.localPosition = Vector3.zero;
|
||||
AssetBundles.Add(ab);
|
||||
AssetBundleLoaders[ab] = true;
|
||||
if(AssetBundles.ContainsKey(ab)==false)
|
||||
AssetBundles.Add(ab, new());
|
||||
AssetBundles[ab].Add(prefab);
|
||||
AssetBundleLoadingCounter--;
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,35 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using Convention;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Demo.Game
|
||||
{
|
||||
namespace ConfigType
|
||||
{
|
||||
// IEffectHookObject 配置(抽象基类Config)
|
||||
public class IEffectHookObjectConfig : ScriptLoadableConfig
|
||||
{
|
||||
public int MyInteractionModule;
|
||||
public IEffectHookObject.InteractiveEffectType MyInteractiveLevel;
|
||||
|
||||
public override void Deserialize(BinaryReader reader)
|
||||
{
|
||||
MyInteractionModule = BinarySerializeUtility.ReadInt(reader);
|
||||
MyInteractiveLevel = (IEffectHookObject.InteractiveEffectType)BinarySerializeUtility.ReadInt(reader);
|
||||
base.Deserialize(reader);
|
||||
}
|
||||
|
||||
public override void Serialize(BinaryWriter writer)
|
||||
{
|
||||
BinarySerializeUtility.WriteInt(writer, MyInteractionModule);
|
||||
BinarySerializeUtility.WriteInt(writer, (int)MyInteractiveLevel);
|
||||
base.Serialize(writer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class IEffectHookObject : ScriptableObject, IHookInteraction
|
||||
{
|
||||
public enum InteractiveEffectType
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using Convention;
|
||||
using Demo.Editor.UI;
|
||||
using UnityEngine;
|
||||
@@ -7,6 +8,35 @@ using UnityEngine.Events;
|
||||
|
||||
namespace Demo.Game
|
||||
{
|
||||
namespace ConfigType
|
||||
{
|
||||
public class IInteractionConfig : ScriptLoadableConfig
|
||||
{
|
||||
public Vector2 VisibleDuration;
|
||||
public Vector2 InteractiveDuration;
|
||||
public Vector2 InteractableScoreInterval;
|
||||
public Vector2 InteractableIntervalThatCanScoreBest;
|
||||
|
||||
public override void Deserialize(BinaryReader reader)
|
||||
{
|
||||
VisibleDuration = BinarySerializeUtility.ReadVec2(reader);
|
||||
InteractiveDuration = BinarySerializeUtility.ReadVec2(reader);
|
||||
InteractableScoreInterval = BinarySerializeUtility.ReadVec2(reader);
|
||||
InteractableIntervalThatCanScoreBest = BinarySerializeUtility.ReadVec2(reader);
|
||||
base.Deserialize(reader);
|
||||
}
|
||||
|
||||
public override void Serialize(BinaryWriter writer)
|
||||
{
|
||||
BinarySerializeUtility.WriteVec2(writer, VisibleDuration);
|
||||
BinarySerializeUtility.WriteVec2(writer, InteractiveDuration);
|
||||
BinarySerializeUtility.WriteVec2(writer, InteractableScoreInterval);
|
||||
BinarySerializeUtility.WriteVec2(writer, InteractableIntervalThatCanScoreBest);
|
||||
base.Serialize(writer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public interface IHookInteraction
|
||||
{
|
||||
|
||||
|
||||
@@ -1,9 +1,28 @@
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using Convention;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Demo.Game
|
||||
{
|
||||
namespace ConfigType
|
||||
{
|
||||
// IJudgementHookObject 配置(抽象基类Config)
|
||||
public class IJudgementHookObjectConfig : ScriptLoadableConfig
|
||||
{
|
||||
public int MyInteractionModule;
|
||||
public override void Deserialize(BinaryReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
}
|
||||
|
||||
public override void Serialize(BinaryWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class IJudgementHookObject : ScriptableObject, IHookInteraction
|
||||
{
|
||||
|
||||
@@ -33,11 +52,10 @@ namespace Demo.Game
|
||||
/// <summary>
|
||||
/// 绑定IInteraction对象,若不手动绑定则会自动绑定到父物体的IInteraction
|
||||
/// </summary>
|
||||
/// <param name="path"></param>
|
||||
[Convention.RScript.Variable.Attr.Method]
|
||||
public void Bind(string path)
|
||||
public void Bind(IInteraction module)
|
||||
{
|
||||
MyInteractionModule = FindWithPath(path) as IInteraction;
|
||||
MyInteractionModule = module;
|
||||
}
|
||||
|
||||
public override IEnumerator UnloadScript()
|
||||
|
||||
@@ -1,8 +1,32 @@
|
||||
using Convention;
|
||||
using Demo.Game.Attr;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Demo.Game
|
||||
{
|
||||
namespace ConfigType
|
||||
{
|
||||
// FullScreenInteraction 配置
|
||||
public class FullScreenInteractionConfig : IInteractionConfig
|
||||
{
|
||||
public bool IsNeedTap;
|
||||
|
||||
public override void Deserialize(BinaryReader reader)
|
||||
{
|
||||
IsNeedTap = BinarySerializeUtility.ReadBool(reader);
|
||||
base.Deserialize(reader);
|
||||
}
|
||||
|
||||
public override void Serialize(BinaryWriter writer)
|
||||
{
|
||||
BinarySerializeUtility.WriteBool(writer, IsNeedTap);
|
||||
base.Serialize(writer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Scriptable]
|
||||
public class FullScreenInteraction : IInteraction
|
||||
{
|
||||
public static FullScreenInteraction Make()
|
||||
|
||||
@@ -1,11 +1,50 @@
|
||||
using Convention;
|
||||
using NUnit.Framework.Internal;
|
||||
using Demo.Game.Attr;
|
||||
using System.Linq;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Demo.Game
|
||||
{
|
||||
namespace ConfigType
|
||||
{
|
||||
public class ParticleJudgement : IJudgementHookObjectConfig
|
||||
{
|
||||
public bool IsZooming;
|
||||
public MathExtension.EaseCurveType ZoomCurve = MathExtension.EaseCurveType.OutCubic;
|
||||
public IInteraction.JudgementLevel[] LevelArray;
|
||||
public string[] AssetBundles;
|
||||
public string[] Prefabs;
|
||||
public float[] Durations;
|
||||
|
||||
public override void Deserialize(BinaryReader reader)
|
||||
{
|
||||
IsZooming = BinarySerializeUtility.ReadBool(reader);
|
||||
ZoomCurve = (MathExtension.EaseCurveType)BinarySerializeUtility.ReadInt(reader);
|
||||
var temp = BinarySerializeUtility.DeserializeIntArray(reader);
|
||||
LevelArray = (from item in temp select (IInteraction.JudgementLevel)item).ToArray();
|
||||
AssetBundles = BinarySerializeUtility.DeserializeStringArray(reader);
|
||||
Prefabs = BinarySerializeUtility.DeserializeStringArray(reader);
|
||||
Durations = BinarySerializeUtility.DeserializeFloatArray(reader);
|
||||
base.Deserialize(reader);
|
||||
}
|
||||
|
||||
public override void Serialize(BinaryWriter writer)
|
||||
{
|
||||
BinarySerializeUtility.WriteBool(writer, IsZooming);
|
||||
BinarySerializeUtility.WriteInt(writer, (int)ZoomCurve);
|
||||
BinarySerializeUtility.SerializeArray(writer, (from item in LevelArray select (int)item).ToArray());
|
||||
BinarySerializeUtility.SerializeArray(writer, AssetBundles);
|
||||
BinarySerializeUtility.SerializeArray(writer, Prefabs);
|
||||
BinarySerializeUtility.SerializeArray(writer, Durations);
|
||||
base.Serialize(writer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Scriptable]
|
||||
public class ParticleJudgement : IJudgementHookObject, IAssetBundleLoader
|
||||
{
|
||||
public static ParticleJudgement Make()
|
||||
|
||||
@@ -1,12 +1,17 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Convention;
|
||||
using Demo.Game.Attr;
|
||||
using Demo.Game.ConfigType;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Demo.Game
|
||||
{
|
||||
[Scriptable]
|
||||
public class LookAtAnchor : Updatement<int>
|
||||
{
|
||||
protected override ScriptLoadableConfig MakeConfig()
|
||||
{
|
||||
return new UpdatementIntConfig();
|
||||
}
|
||||
public static LookAtAnchor Make()
|
||||
{
|
||||
return new GameObject().AddComponent<LookAtAnchor>();
|
||||
@@ -17,14 +22,12 @@ namespace Demo.Game
|
||||
return begin;
|
||||
}
|
||||
|
||||
private readonly List<ScriptableObject> LookAtCache = new();
|
||||
|
||||
[Content] public int LookAtObject;
|
||||
[Content] public bool IsEnableUpdateEveryTick = false;
|
||||
|
||||
protected override void UpdateData(int data)
|
||||
{
|
||||
ScriptableObject target = LookAtCache[LookAtObject];
|
||||
ScriptableObject target = GetRoot().FindWithIndex(data);
|
||||
if (data != LookAtObject)
|
||||
{
|
||||
LookAtObject = data;
|
||||
@@ -44,8 +47,7 @@ namespace Demo.Game
|
||||
[Convention.RScript.Variable.Attr.Method]
|
||||
public void Add(float time, ScriptableObject target)
|
||||
{
|
||||
LookAtCache.Add(target);
|
||||
ManualAddEntry(time, LookAtCache.Count - 1, default);
|
||||
ManualAddEntry(time, GetRoot().FindIndex(target), default);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,13 +1,45 @@
|
||||
using Convention;
|
||||
using Demo.Game.Attr;
|
||||
using Demo.Game.ConfigType;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering.LookDev;
|
||||
|
||||
namespace Demo.Game
|
||||
{
|
||||
namespace ConfigType
|
||||
{
|
||||
public class MaterialUpdatementConfig : UpdatementIntConfig
|
||||
{
|
||||
public string MaterialAssetBundlePath;
|
||||
public string[] MaterialNames;
|
||||
public int[] MaterialIndexs;
|
||||
|
||||
public override void Deserialize(BinaryReader reader)
|
||||
{
|
||||
MaterialAssetBundlePath = BinarySerializeUtility.ReadString(reader);
|
||||
MaterialNames = BinarySerializeUtility.DeserializeStringArray(reader);
|
||||
MaterialIndexs = BinarySerializeUtility.DeserializeIntArray(reader);
|
||||
base.Deserialize(reader);
|
||||
}
|
||||
|
||||
public override void Serialize(BinaryWriter writer)
|
||||
{
|
||||
BinarySerializeUtility.WriteString(writer, MaterialAssetBundlePath);
|
||||
BinarySerializeUtility.SerializeArray(writer, MaterialNames);
|
||||
BinarySerializeUtility.SerializeArray(writer, MaterialIndexs);
|
||||
base.Serialize(writer);
|
||||
}
|
||||
}
|
||||
}
|
||||
[Scriptable]
|
||||
public class MaterialUpdatement : Updatement<int>, IAssetBundleLoader
|
||||
{
|
||||
protected override ScriptLoadableConfig MakeConfig()
|
||||
{
|
||||
return new MaterialUpdatementConfig();
|
||||
}
|
||||
public static MaterialUpdatement Make()
|
||||
{
|
||||
return new GameObject().AddComponent<MaterialUpdatement>();
|
||||
|
||||
@@ -1,12 +1,38 @@
|
||||
using Convention;
|
||||
using Demo.Game.ConfigType;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Convention;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Demo.Game
|
||||
{
|
||||
namespace ConfigType
|
||||
{
|
||||
public class BaseOnMaterialUpdatementConfig : UpdatementFloatConfig
|
||||
{
|
||||
public int TargetMeshRenderer;
|
||||
|
||||
public override void Deserialize(BinaryReader reader)
|
||||
{
|
||||
TargetMeshRenderer = BinarySerializeUtility.ReadInt(reader);
|
||||
base.Deserialize(reader);
|
||||
}
|
||||
|
||||
public override void Serialize(BinaryWriter writer)
|
||||
{
|
||||
BinarySerializeUtility.WriteInt(writer, TargetMeshRenderer);
|
||||
base.Serialize(writer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class BaseOnMaterialUpdatement : Updatement<float>
|
||||
{
|
||||
protected override ConfigType.ScriptLoadableConfig MakeConfig()
|
||||
{
|
||||
return new BaseOnMaterialUpdatementConfig();
|
||||
}
|
||||
public abstract string TargetFieldName { get; }
|
||||
|
||||
protected override float Lerp(float begin, float end, float t)
|
||||
@@ -27,13 +53,9 @@ namespace Demo.Game
|
||||
/// </summary>
|
||||
/// <param name="path">脚本位置</param>
|
||||
[Convention.RScript.Variable.Attr.Method]
|
||||
public void Load(string path)
|
||||
public void Load(ScriptableObject obj)
|
||||
{
|
||||
var so = FindWithPath(path, false);
|
||||
if (so != null)
|
||||
{
|
||||
TargetMeshRenderer = so.GetComponent<MeshRenderer>();
|
||||
}
|
||||
TargetMeshRenderer = obj.GetComponent<MeshRenderer>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Convention;
|
||||
using Demo.Game.Attr;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Demo.Game
|
||||
{
|
||||
[Scriptable]
|
||||
public class ColorUpdatement : BaseOnMaterialUpdatement
|
||||
{
|
||||
public static ColorUpdatement Make()
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Convention;
|
||||
using Demo.Game.Attr;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Demo.Game
|
||||
{
|
||||
[Scriptable]
|
||||
public class EmissionColorUpdatement : BaseOnMaterialUpdatement
|
||||
{
|
||||
public static EmissionColorUpdatement Make()
|
||||
|
||||
@@ -1,26 +1,79 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using Convention;
|
||||
using Demo.Game.ConfigType;
|
||||
using Dreamteck.Splines;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using Unity.Collections;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
|
||||
namespace Demo.Game
|
||||
{
|
||||
public interface IDependOnSplineRenderer
|
||||
namespace ConfigType
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public static class DependOnSplineRendererUtility
|
||||
{
|
||||
public static BasicSplineRenderer LoadSplineRendererTool(this IDependOnSplineCore self, string path)
|
||||
public class BasicSplineRendererConfig : UpdatementConfig<SplineClipDuration>
|
||||
{
|
||||
return self.SharedInterfaceScriptObject.FindWithPath(path, true) as BasicSplineRenderer;
|
||||
public int MySplineCore;
|
||||
public string LinesAssetBundlePath;
|
||||
public string MyDefaultMaterial;
|
||||
|
||||
public override void Deserialize(BinaryReader reader)
|
||||
{
|
||||
MySplineCore = BinarySerializeUtility.ReadInt(reader);
|
||||
LinesAssetBundlePath = BinarySerializeUtility.ReadString(reader);
|
||||
MyDefaultMaterial = BinarySerializeUtility.ReadString(reader);
|
||||
base.Deserialize(reader);
|
||||
}
|
||||
|
||||
public override void Serialize(BinaryWriter writer)
|
||||
{
|
||||
BinarySerializeUtility.WriteInt(writer, MySplineCore);
|
||||
BinarySerializeUtility.WriteString(writer, LinesAssetBundlePath);
|
||||
BinarySerializeUtility.WriteString(writer, MyDefaultMaterial);
|
||||
base.Serialize(writer);
|
||||
}
|
||||
|
||||
protected override void DeserializePositions(BinaryReader reader, ref NativeArray<SplineClipDuration> positions)
|
||||
{
|
||||
NativeArray<Vector2> temp = new(0, Allocator.Temp, NativeArrayOptions.UninitializedMemory);
|
||||
int e = BinarySerializeUtility.DeserializeNativeArray(reader, ref temp);
|
||||
positions.ResizeArray(e);
|
||||
for (int i = 0; i < e; i++)
|
||||
{
|
||||
positions[i] = new(temp[i].x, temp[i].y);
|
||||
}
|
||||
temp.Dispose();
|
||||
}
|
||||
|
||||
protected override void SerializePositions(BinaryWriter writer, in NativeArray<SplineClipDuration> positions)
|
||||
{
|
||||
NativeArray<Vector2> temp = new(positions.Length, Allocator.Temp, NativeArrayOptions.UninitializedMemory);
|
||||
for (int i = 0, e=positions.Length; i < e; i++)
|
||||
{
|
||||
temp[i] = new(positions[i].ClipFrom, positions[i].ClipTo);
|
||||
}
|
||||
BinarySerializeUtility.SerializeNativeArray(writer, temp);
|
||||
temp.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class BasicSplineRenderer : Updatement<SplineClipDuration>, IAssetBundleLoader, IDependOnSplineCore
|
||||
{
|
||||
protected override ConfigType.ScriptLoadableConfig MakeConfig()
|
||||
{
|
||||
return new BasicSplineRendererConfig();
|
||||
}
|
||||
/// <summary>
|
||||
/// 加载并绑定到新样条线
|
||||
/// </summary>
|
||||
/// <param name="path">对象路径, 不存在时则立刻加载</param>
|
||||
[Convention.RScript.Variable.Attr.Method]
|
||||
public void LoadSpline(SplineCore core)
|
||||
{
|
||||
MySplineCore = core;
|
||||
}
|
||||
|
||||
[Content] public SplineCore MySplineCore { get; set; }
|
||||
[Content] private MeshFilter m_MeshFilter;
|
||||
[Content] private MeshRenderer m_MyMeshRenderer;
|
||||
@@ -94,19 +147,6 @@ namespace Demo.Game
|
||||
ManualAddEntry(time, new(from, to), curveType);
|
||||
}
|
||||
|
||||
[Convention.RScript.Variable.Attr.Method]
|
||||
public void LoadSpline(string path)
|
||||
{
|
||||
this.LoadSplineTool(path);
|
||||
}
|
||||
|
||||
|
||||
[Convention.RScript.Variable.Attr.Method]
|
||||
public void LoadSpline(SplineCore spline)
|
||||
{
|
||||
this.MySplineCore = spline;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载对应ab包并加载指定材质
|
||||
/// </summary>
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
using Demo.Game.Attr;
|
||||
using Dreamteck.Splines;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Demo.Game
|
||||
{
|
||||
[Scriptable]
|
||||
public class SplineRenderer : BasicSplineRenderer<Dreamteck.Splines.SplineRenderer>
|
||||
{
|
||||
public static SplineRenderer Make()
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
using Demo.Game.Attr;
|
||||
using Dreamteck.Splines;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Demo.Game
|
||||
{
|
||||
[Scriptable]
|
||||
public class SplineSurfaceRenderer : BasicSplineRenderer<SurfaceGenerator>
|
||||
{
|
||||
public static SplineSurfaceRenderer Make()
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
using Convention;
|
||||
using Demo.Game.Attr;
|
||||
using Dreamteck.Splines;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using Convention;
|
||||
using Dreamteck.Splines;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Demo.Game
|
||||
{
|
||||
[Scriptable]
|
||||
public class SplineTrackRenderer : BasicSplineRenderer<PathGenerator>
|
||||
{
|
||||
public static SplineTrackRenderer Make()
|
||||
|
||||
@@ -1,13 +1,46 @@
|
||||
using Convention;
|
||||
using Demo.Game.Attr;
|
||||
using Demo.Game.ConfigType;
|
||||
using Dreamteck.Splines;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using Convention;
|
||||
using Dreamteck.Splines;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Demo.Game
|
||||
{
|
||||
namespace ConfigType
|
||||
{
|
||||
public class SplineTubeRendererConfig : BasicSplineJustFollowConfig
|
||||
{
|
||||
public const bool DefaultIsDoubleSide = true;
|
||||
public const int DefaultSidesCount = 12;
|
||||
public bool IsDoubleSide = DefaultIsDoubleSide;
|
||||
public int SidesCount = DefaultSidesCount;
|
||||
|
||||
public override void Deserialize(BinaryReader reader)
|
||||
{
|
||||
IsDoubleSide = BinarySerializeUtility.ReadBool(reader);
|
||||
SidesCount = BinarySerializeUtility.ReadInt(reader);
|
||||
base.Deserialize(reader);
|
||||
}
|
||||
|
||||
public override void Serialize(BinaryWriter writer)
|
||||
{
|
||||
BinarySerializeUtility.WriteBool(writer, IsDoubleSide);
|
||||
BinarySerializeUtility.WriteInt(writer, SidesCount);
|
||||
base.Serialize(writer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Scriptable]
|
||||
public class SplineTubeRenderer : BasicSplineRenderer<TubeGenerator>
|
||||
{
|
||||
protected override ScriptLoadableConfig MakeConfig()
|
||||
{
|
||||
return new SplineTubeRendererConfig();
|
||||
}
|
||||
public static SplineTubeRenderer Make()
|
||||
{
|
||||
return new GameObject().AddComponent<SplineTubeRenderer>();
|
||||
|
||||
@@ -1,11 +1,52 @@
|
||||
using Convention;
|
||||
using Demo.Game.Attr;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Demo.Game
|
||||
{
|
||||
public class SplineAnchor : ScriptableObject, IDependOnSplineCore, IDependOnSplineRenderer
|
||||
namespace ConfigType
|
||||
{
|
||||
public class SplineAnchorConfig : ScriptLoadableConfig
|
||||
{
|
||||
public int MySplineCore, MySplineRenderer;
|
||||
public bool isFollowPosition, isFollowRotation;
|
||||
public float MySplineOffset;
|
||||
public override void Deserialize(BinaryReader reader)
|
||||
{
|
||||
MySplineCore = BinarySerializeUtility.ReadInt(reader);
|
||||
MySplineRenderer = BinarySerializeUtility.ReadInt(reader);
|
||||
isFollowPosition = BinarySerializeUtility.ReadBool(reader);
|
||||
isFollowRotation = BinarySerializeUtility.ReadBool(reader);
|
||||
MySplineOffset = BinarySerializeUtility.ReadFloat(reader);
|
||||
base.Deserialize(reader);
|
||||
}
|
||||
|
||||
public override void Serialize(BinaryWriter writer)
|
||||
{
|
||||
BinarySerializeUtility.WriteInt(writer, MySplineCore);
|
||||
BinarySerializeUtility.WriteInt(writer, MySplineRenderer);
|
||||
BinarySerializeUtility.WriteBool(writer, isFollowPosition);
|
||||
BinarySerializeUtility.WriteBool(writer, isFollowRotation);
|
||||
BinarySerializeUtility.WriteFloat(writer, MySplineOffset);
|
||||
base.Serialize(writer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Scriptable]
|
||||
public class SplineAnchor : ScriptableObject, IDependOnSplineCore
|
||||
{
|
||||
/// <summary>
|
||||
/// 加载并绑定到新样条线
|
||||
/// </summary>
|
||||
/// <param name="path">对象路径, 不存在时则立刻加载</param>
|
||||
[Convention.RScript.Variable.Attr.Method]
|
||||
public void LoadSpline(SplineCore core)
|
||||
{
|
||||
MySplineCore = core;
|
||||
}
|
||||
public static SplineAnchor Make()
|
||||
{
|
||||
return new GameObject().AddComponent<SplineAnchor>();
|
||||
@@ -22,16 +63,6 @@ namespace Demo.Game
|
||||
Updater?.Invoke();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载并绑定到新样条线
|
||||
/// </summary>
|
||||
/// <param name="path">对象路径, 不存在时则立刻加载</param>
|
||||
[Convention.RScript.Variable.Attr.Method]
|
||||
public void LoadSpline(string path)
|
||||
{
|
||||
this.LoadSplineTool(path);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 必须先执行LoadSpline加载样条线
|
||||
/// </summary>
|
||||
|
||||
@@ -1,12 +1,41 @@
|
||||
using Convention;
|
||||
using Demo.Game.Attr;
|
||||
using Dreamteck.Splines;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Convention;
|
||||
using Dreamteck.Splines;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Demo.Game
|
||||
{
|
||||
namespace ConfigType
|
||||
{
|
||||
// SplineCore 配置
|
||||
public class SplineCoreConfig : ScriptLoadableConfig
|
||||
{
|
||||
public SplineComputer.SampleMode MySampleMode;
|
||||
public Spline.Type MyType;
|
||||
public bool IsClose;
|
||||
|
||||
public override void Deserialize(BinaryReader reader)
|
||||
{
|
||||
MySampleMode = (SplineComputer.SampleMode)BinarySerializeUtility.ReadInt(reader);
|
||||
MyType = (Spline.Type)BinarySerializeUtility.ReadInt(reader);
|
||||
IsClose = BinarySerializeUtility.ReadBool(reader);
|
||||
base.Deserialize(reader);
|
||||
}
|
||||
|
||||
public override void Serialize(BinaryWriter writer)
|
||||
{
|
||||
BinarySerializeUtility.WriteInt(writer, (int)MySampleMode);
|
||||
BinarySerializeUtility.WriteInt(writer, (int)MyType);
|
||||
BinarySerializeUtility.WriteBool(writer, IsClose);
|
||||
base.Serialize(writer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public struct SplineClipDuration
|
||||
{
|
||||
public float ClipFrom;
|
||||
@@ -22,32 +51,10 @@ namespace Demo.Game
|
||||
public interface IDependOnSplineCore : IScriptableObject
|
||||
{
|
||||
SplineCore MySplineCore { get; set; }
|
||||
void LoadSpline(string path);
|
||||
}
|
||||
|
||||
public static class DependOnSplineCoreUtility
|
||||
{
|
||||
public const string LoadSplineDescription = @"
|
||||
<summary>
|
||||
加载并绑定到新样条线
|
||||
</summary>
|
||||
<param name=""path"">对象相对路径,若对象不存在则作为脚本相对路径加载</param>
|
||||
";
|
||||
|
||||
/// <summary>
|
||||
/// 加载并绑定到新样条线
|
||||
/// </summary>
|
||||
/// <param name="path">对象相对路径,若对象不存在则作为脚本相对路径加载</param>
|
||||
public static SplineCore LoadSplineTool(this IDependOnSplineCore self, string path)
|
||||
{
|
||||
var spline = self.SharedInterfaceScriptObject.FindWithPath(path, false);
|
||||
if (spline == null)
|
||||
spline = self.SharedInterfaceScriptObject.LoadSubScript(nameof(SplineCore), new ToolFile(path).GetFilename(true), path);
|
||||
self.MySplineCore = (SplineCore)spline;
|
||||
return self.MySplineCore;
|
||||
}
|
||||
void LoadSpline(SplineCore core);
|
||||
}
|
||||
|
||||
[Scriptable]
|
||||
public class SplineCore : ScriptableObject
|
||||
{
|
||||
protected override bool IsSelfEnableUpdate => false;
|
||||
@@ -69,14 +76,6 @@ namespace Demo.Game
|
||||
public bool IsClose = false;
|
||||
|
||||
public SplineComputer MySplineComputer => m_MySplineComputer;
|
||||
//{
|
||||
// get
|
||||
// {
|
||||
// if (m_MySplineComputer == null)
|
||||
// m_MySplineComputer = this.GetComponent<SplineComputer>();
|
||||
// return m_MySplineComputer;
|
||||
// }
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="SplineCore"/>需要在子<see cref="SplineNode"/>都添加后再应用脚本才能使得节点生效
|
||||
|
||||
@@ -1,10 +1,44 @@
|
||||
using System.Collections;
|
||||
using Convention;
|
||||
using Demo.Game.Attr;
|
||||
using Dreamteck.Splines;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Demo.Game
|
||||
{
|
||||
namespace ConfigType
|
||||
{
|
||||
public class SplineNodeConfig : ScriptLoadableConfig
|
||||
{
|
||||
public float NodeSize = 1;
|
||||
public Color NodeColor = Color.white;
|
||||
public bool IsSetupNodeRotation = false;
|
||||
public Vector3 NodeRotation = Vector3.zero;
|
||||
public int[] LinkSplineCores;
|
||||
public override void Deserialize(BinaryReader reader)
|
||||
{
|
||||
NodeSize = BinarySerializeUtility.ReadFloat(reader);
|
||||
NodeColor = BinarySerializeUtility.ReadColor(reader);
|
||||
IsSetupNodeRotation = BinarySerializeUtility.ReadBool(reader);
|
||||
NodeRotation = BinarySerializeUtility.ReadVec3(reader);
|
||||
LinkSplineCores = BinarySerializeUtility.DeserializeIntArray(reader);
|
||||
base.Deserialize(reader);
|
||||
}
|
||||
|
||||
public override void Serialize(BinaryWriter writer)
|
||||
{
|
||||
BinarySerializeUtility.WriteFloat(writer, NodeSize);
|
||||
BinarySerializeUtility.WriteColor(writer, NodeColor);
|
||||
BinarySerializeUtility.WriteBool(writer, IsSetupNodeRotation);
|
||||
BinarySerializeUtility.WriteVec3(writer, NodeRotation);
|
||||
BinarySerializeUtility.SerializeArray(writer, LinkSplineCores);
|
||||
base.Serialize(writer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Scriptable]
|
||||
public class SplineNode : ScriptableObject
|
||||
{
|
||||
protected override bool IsSelfEnableUpdate => false;
|
||||
@@ -21,14 +55,13 @@ namespace Demo.Game
|
||||
public Color NodeColor = Color.white;
|
||||
public bool IsSetupNodeRotation = false;
|
||||
public Vector3 NodeRotation = Vector3.zero;
|
||||
public int MyNodeContent = 0;
|
||||
|
||||
|
||||
public Node MyNode => m_MyNode;
|
||||
|
||||
public void AddTo(SplineCore core)
|
||||
{
|
||||
MyNodeContent = core.NodeContent;
|
||||
int MyNodeContent = core.NodeContent;
|
||||
core.MySplineComputer.SetPointColor(MyNodeContent, NodeColor);
|
||||
core.MySplineComputer.SetPointSize(MyNodeContent, NodeSize);
|
||||
core.MySplineComputer.SetPointNormal(MyNodeContent, IsSetupNodeRotation ? NodeRotation.normalized : transform.up);
|
||||
@@ -42,6 +75,7 @@ namespace Demo.Game
|
||||
[Convention.RScript.Variable.Attr.Method]
|
||||
public void SetNodeSize(float size)
|
||||
{
|
||||
SetLocalScaling(size, size, size);
|
||||
NodeSize = size;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +1,47 @@
|
||||
using Convention;
|
||||
using Demo.Game.ConfigType;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using Convention;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Demo.Game
|
||||
{
|
||||
public abstract class BasicSplineJustFollow : Updatement<float>
|
||||
namespace ConfigType
|
||||
{
|
||||
public SplineCore MySplineCore;
|
||||
public class BasicSplineJustFollowConfig : UpdatementFloatConfig
|
||||
{
|
||||
public int MySplineCore;
|
||||
public override void Deserialize(BinaryReader reader)
|
||||
{
|
||||
MySplineCore = BinarySerializeUtility.ReadInt(reader);
|
||||
base.Deserialize(reader);
|
||||
}
|
||||
|
||||
public override void Serialize(BinaryWriter writer)
|
||||
{
|
||||
BinarySerializeUtility.WriteInt(writer, MySplineCore);
|
||||
base.Serialize(writer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class BasicSplineJustFollow : Updatement<float>, IDependOnSplineCore
|
||||
{
|
||||
protected override ConfigType.ScriptLoadableConfig MakeConfig()
|
||||
{
|
||||
return new BasicSplineJustFollowConfig();
|
||||
}
|
||||
/// <summary>
|
||||
/// 加载并绑定到新样条线
|
||||
/// </summary>
|
||||
/// <param name="path">对象路径, 不存在时则立刻加载</param>
|
||||
[Convention.RScript.Variable.Attr.Method]
|
||||
public void LoadSpline(SplineCore core)
|
||||
{
|
||||
MySplineCore = core;
|
||||
}
|
||||
public SplineCore MySplineCore { get; set; }
|
||||
|
||||
protected override float Lerp(float begin, float end, float t)
|
||||
{
|
||||
@@ -33,15 +67,5 @@ namespace Demo.Game
|
||||
{
|
||||
ManualAddEntry(time, value, curveType);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 绑定到样条线
|
||||
/// </summary>
|
||||
/// <param name="path">脚本位置</param>
|
||||
[Convention.RScript.Variable.Attr.Method]
|
||||
public void Load(SplineCore splineCore)
|
||||
{
|
||||
MySplineCore = splineCore;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
using System.Collections;
|
||||
using Convention;
|
||||
using Convention.WindowsUI.Variant;
|
||||
using Dreamteck.Splines;
|
||||
using Demo.Game.Attr;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Demo.Game
|
||||
{
|
||||
[Scriptable]
|
||||
public class SplineMovement : BasicSplineJustFollow
|
||||
{
|
||||
public static SplineMovement Make()
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Convention;
|
||||
using Convention.WindowsUI.Variant;
|
||||
using Dreamteck.Splines;
|
||||
using Demo.Game.Attr;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Demo.Game
|
||||
{
|
||||
[Scriptable]
|
||||
public class SplinePointerObject : BasicSplineJustFollow
|
||||
{
|
||||
public static SplinePointerObject Make()
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using Convention;
|
||||
using Demo.Game.Attr;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Demo.Game
|
||||
@@ -8,6 +6,7 @@ namespace Demo.Game
|
||||
/// <summary>
|
||||
/// 天然被动跟随
|
||||
/// </summary>
|
||||
[Scriptable]
|
||||
public class SplineRotation : BasicSplineJustFollow
|
||||
{
|
||||
public static SplineRotation Make()
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using Demo.Game.Attr;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Demo.Game
|
||||
@@ -5,6 +6,7 @@ namespace Demo.Game
|
||||
/// <summary>
|
||||
/// 天然被动跟随
|
||||
/// </summary>
|
||||
[Scriptable]
|
||||
public class SplineScaling : BasicSplineJustFollow
|
||||
{
|
||||
public static SplineScaling Make()
|
||||
|
||||
@@ -1,14 +1,17 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Convention;
|
||||
using Convention.WindowsUI.Variant;
|
||||
using Demo.Game.Attr;
|
||||
using Demo.Game.ConfigType;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Demo.Game
|
||||
{
|
||||
[Scriptable]
|
||||
public class TickMovement : Updatement<Vector3>
|
||||
{
|
||||
protected override ScriptLoadableConfig MakeConfig()
|
||||
{
|
||||
return new UpdatementVec3Config();
|
||||
}
|
||||
public static TickMovement Make()
|
||||
{
|
||||
return new GameObject().AddComponent<TickMovement>();
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
using System;
|
||||
using Convention;
|
||||
using Demo.Game.Attr;
|
||||
using Demo.Game.ConfigType;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Demo.Game
|
||||
{
|
||||
[Scriptable]
|
||||
public class TickRotation : Updatement<Vector3>
|
||||
{
|
||||
protected override ScriptLoadableConfig MakeConfig()
|
||||
{
|
||||
return new UpdatementVec3Config();
|
||||
}
|
||||
public static TickRotation Make()
|
||||
{
|
||||
return new GameObject().AddComponent<TickRotation>();
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
using System;
|
||||
using Convention;
|
||||
using Demo.Game.Attr;
|
||||
using Demo.Game.ConfigType;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Demo.Game
|
||||
{
|
||||
[Scriptable]
|
||||
public class TickScaling : Updatement<Vector3>
|
||||
{
|
||||
protected override ScriptLoadableConfig MakeConfig()
|
||||
{
|
||||
return new UpdatementVec3Config();
|
||||
}
|
||||
public static TickScaling Make()
|
||||
{
|
||||
return new GameObject().AddComponent<TickScaling>();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Convention;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
@@ -60,6 +61,14 @@ namespace Demo.Game
|
||||
return false;
|
||||
return ConventionUtility.PushValue(component, value, name, BindingFlags.Public | BindingFlags.Instance);
|
||||
}
|
||||
|
||||
public bool TrySetOverrideField<FieldType>(string type, string name, FieldType value)
|
||||
{
|
||||
var component = GetOverride(type);
|
||||
if (component == null)
|
||||
return false;
|
||||
return ConventionUtility.PushValue(component, value, name, BindingFlags.Public | BindingFlags.Instance);
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class BaseForSingleVolume<T> : BaseVolume where T : VolumeComponent
|
||||
|
||||
@@ -1,8 +1,15 @@
|
||||
using Demo.Game.Attr;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering.Universal;
|
||||
|
||||
namespace Demo.Game
|
||||
{
|
||||
namespace ConfigType
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
[Scriptable]
|
||||
public class MotionBlurVolume : BaseForSingleVolume<MotionBlur>
|
||||
{
|
||||
public static MotionBlurVolume Make()
|
||||
|
||||
8
Assets/Scripts/Volume/Updatement.meta
Normal file
8
Assets/Scripts/Volume/Updatement.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6817d5ed5f3f2ba46b718a0003027dee
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
75
Assets/Scripts/Volume/Updatement/BaseVolumeUpdatement.cs
Normal file
75
Assets/Scripts/Volume/Updatement/BaseVolumeUpdatement.cs
Normal file
@@ -0,0 +1,75 @@
|
||||
using Convention;
|
||||
using Demo.Game.Attr;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Demo.Game
|
||||
{
|
||||
namespace ConfigType
|
||||
{
|
||||
public class BaseVolumeUpdatementConfig:ScriptLoadableConfig
|
||||
{
|
||||
public int target;
|
||||
public string updateOverride;
|
||||
public string updateField;
|
||||
|
||||
public override void Deserialize(BinaryReader reader)
|
||||
{
|
||||
target = BinarySerializeUtility.ReadInt(reader);
|
||||
updateOverride = BinarySerializeUtility.ReadString(reader);
|
||||
updateField = BinarySerializeUtility.ReadString(reader);
|
||||
base.Deserialize(reader);
|
||||
}
|
||||
|
||||
public override void Serialize(BinaryWriter writer)
|
||||
{
|
||||
BinarySerializeUtility.WriteInt(writer, target);
|
||||
BinarySerializeUtility.WriteString(writer, updateOverride);
|
||||
BinarySerializeUtility.WriteString(writer, updateField);
|
||||
base.Serialize(writer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class BaseVolumeUpdatement<T> : Updatement<T> where T : unmanaged
|
||||
{
|
||||
[Content, SerializeField] private BaseVolume target;
|
||||
[Content, SerializeField] private string updateOverride;
|
||||
[Content, SerializeField] private string updateField;
|
||||
|
||||
protected override IEnumerator DoSomethingDuringApplyScript()
|
||||
{
|
||||
yield return base.DoSomethingDuringApplyScript();
|
||||
if (target == null)
|
||||
{
|
||||
target = this.UpdateTarget.SeekComponent<BaseVolume>();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void UpdateData(T data)
|
||||
{
|
||||
target.TrySetOverrideField<T>(updateOverride, updateField, data);
|
||||
}
|
||||
|
||||
[Convention.RScript.Variable.Attr.Method]
|
||||
public void SetUpdateOverrideAndField(string updateOverride, string updateField)
|
||||
{
|
||||
this.updateOverride = updateOverride;
|
||||
this.updateField = updateField;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 新增
|
||||
/// </summary>
|
||||
/// <param name="time">插值时间</param>
|
||||
/// <param name="value">值</param>
|
||||
/// <param name="curveType">缓动曲线</param>
|
||||
[Convention.RScript.Variable.Attr.Method]
|
||||
public void Add(float time, T value, MathExtension.EaseCurveType curveType)
|
||||
{
|
||||
ManualAddEntry(time, value, curveType);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3310713d1026b944facb4c172ad38bb1
|
||||
21
Assets/Scripts/Volume/Updatement/VolumeFloatUpdatement.cs
Normal file
21
Assets/Scripts/Volume/Updatement/VolumeFloatUpdatement.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using Convention;
|
||||
using Demo.Game.Attr;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Demo.Game
|
||||
{
|
||||
[Scriptable]
|
||||
public class VolumeFloatUpdatement : BaseVolumeUpdatement<float>
|
||||
{
|
||||
public static VolumeFloatUpdatement Make()
|
||||
{
|
||||
return new GameObject().AddComponent<VolumeFloatUpdatement>();
|
||||
}
|
||||
|
||||
protected override float Lerp(float begin, float end, float t)
|
||||
{
|
||||
return Mathf.Lerp(begin, end, t);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6b3813d5ec8404345bcbd745281e2671
|
||||
19
Assets/Scripts/Volume/Updatement/VolumeIntUpdatement.cs
Normal file
19
Assets/Scripts/Volume/Updatement/VolumeIntUpdatement.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using Demo.Game.Attr;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Demo.Game
|
||||
{
|
||||
[Scriptable]
|
||||
public class VolumeIntUpdatement : BaseVolumeUpdatement<int>
|
||||
{
|
||||
public static VolumeIntUpdatement Make()
|
||||
{
|
||||
return new GameObject().AddComponent<VolumeIntUpdatement>();
|
||||
}
|
||||
|
||||
protected override int Lerp(int begin, int end, float t)
|
||||
{
|
||||
return Mathf.FloorToInt(Mathf.Lerp(begin, end, t));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 600cb8d3ed5900d4baa30e5d8aafa66e
|
||||
67
Assets/Scripts/Volume/VolumeObject.cs
Normal file
67
Assets/Scripts/Volume/VolumeObject.cs
Normal file
@@ -0,0 +1,67 @@
|
||||
using Convention;
|
||||
using Demo.Game.Attr;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
|
||||
namespace Demo.Game
|
||||
{
|
||||
namespace ConfigType
|
||||
{
|
||||
// VolumeObject 配置
|
||||
public class VolumeObjectConfig : ScriptLoadableConfig
|
||||
{
|
||||
public string MyAssetBundle, MyProfile;
|
||||
|
||||
public override void Deserialize(BinaryReader reader)
|
||||
{
|
||||
MyAssetBundle = BinarySerializeUtility.ReadString(reader);
|
||||
MyProfile = BinarySerializeUtility.ReadString(reader);
|
||||
base.Deserialize(reader);
|
||||
}
|
||||
|
||||
public override void Serialize(BinaryWriter writer)
|
||||
{
|
||||
BinarySerializeUtility.WriteString(writer, MyAssetBundle);
|
||||
BinarySerializeUtility.WriteString(writer, MyProfile);
|
||||
base.Serialize(writer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Scriptable]
|
||||
public class VolumeObject : BaseVolume, IAssetBundleLoader
|
||||
{
|
||||
public static VolumeObject Make()
|
||||
{
|
||||
return new GameObject().AddComponent<VolumeObject>();
|
||||
}
|
||||
|
||||
private bool IsLoading = false;
|
||||
[Content, SerializeField] private string MyAssetBundle, MyProfile;
|
||||
|
||||
protected override IEnumerator DoSomethingDuringApplyScript()
|
||||
{
|
||||
yield return base.DoSomethingDuringApplyScript();
|
||||
yield return new WaitUntil(() => !IsLoading);
|
||||
if (MyVolume.profile == null)
|
||||
{
|
||||
MyVolume.profile = Resources.Load<VolumeProfile>("Volume/Default");
|
||||
}
|
||||
}
|
||||
|
||||
[Convention.RScript.Variable.Attr.Method]
|
||||
public void Load(string ab, string profile)
|
||||
{
|
||||
IsLoading = true;
|
||||
MyAssetBundle = ab;
|
||||
MyProfile = profile;
|
||||
ConventionUtility.StartCoroutine(this.LoadAssetBundle(ab, x =>
|
||||
{
|
||||
MyVolume.profile = x.LoadAsset<VolumeProfile>(profile);
|
||||
IsLoading = false;
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/Volume/VolumeObject.cs.meta
Normal file
2
Assets/Scripts/Volume/VolumeObject.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6905b41c61f830c4fac86087660118e4
|
||||
@@ -35,7 +35,7 @@ MonoBehaviour:
|
||||
- line: '| useOnDemandResources: 0'
|
||||
- line: '| accelerometerFrequency: 60'
|
||||
- line: '| companyName: LiuBai'
|
||||
- line: '| productName: Murmur-Resonance-Editor'
|
||||
- line: '| productName: ScriptableObject-Editor'
|
||||
- line: '| defaultCursor: {instanceID: 0}'
|
||||
- line: '| cursorHotspot: {x: 0, y: 0}'
|
||||
- line: '| m_SplashScreenBackgroundColor: {r: 0.13725491, g: 0.12156863, b:
|
||||
@@ -165,7 +165,7 @@ MonoBehaviour:
|
||||
- line: '| loadStoreDebugModeEnabled: 0'
|
||||
- line: '| visionOSBundleVersion: 1.0'
|
||||
- line: '| tvOSBundleVersion: 1.0'
|
||||
- line: '| bundleVersion: 1.0'
|
||||
- line: '| bundleVersion: 1.1'
|
||||
- line: '| preloadedAssets:'
|
||||
- line: '| - {instanceID: 0}'
|
||||
- line: '| - {instanceID: 0}'
|
||||
@@ -422,7 +422,7 @@ MonoBehaviour:
|
||||
- line: '| - m_BuildTarget: '
|
||||
- line: '| m_Icons:'
|
||||
- line: '| - serializedVersion: 2'
|
||||
- line: '| m_Icon: {fileID: 2800000, guid: 8a1e37e4b2571444b95d20abbea33454,
|
||||
- line: '| m_Icon: {fileID: 2800000, guid: e7fd089a9ebf1be4589638221dc0a006,
|
||||
type: 3}'
|
||||
- line: '| m_Width: 128'
|
||||
- line: '| m_Height: 128'
|
||||
@@ -1139,9 +1139,9 @@ MonoBehaviour:
|
||||
- rid: 4324738286741356696
|
||||
type: {class: WindowsPlatformSettings, ns: UnityEditor.WindowsStandalone, asm: UnityEditor.WindowsStandalone.Extensions}
|
||||
data:
|
||||
m_Development: 0
|
||||
m_Development: 1
|
||||
m_ConnectProfiler: 0
|
||||
m_BuildWithDeepProfilingSupport: 0
|
||||
m_BuildWithDeepProfilingSupport: 1
|
||||
m_AllowDebugging: 0
|
||||
m_WaitForManagedDebugger: 0
|
||||
m_ManagedDebuggerFixedPort: 0
|
||||
|
||||
@@ -207,7 +207,7 @@ MonoBehaviour:
|
||||
type: {class: RenderGraphSettings, ns: UnityEngine.Rendering.Universal, asm: Unity.RenderPipelines.Universal.Runtime}
|
||||
data:
|
||||
m_Version: 0
|
||||
m_EnableRenderCompatibilityMode: 1
|
||||
m_EnableRenderCompatibilityMode: 0
|
||||
- rid: 4324738240734560265
|
||||
type: {class: UniversalRenderPipelineEditorShaders, ns: UnityEngine.Rendering.Universal, asm: Unity.RenderPipelines.Universal.Runtime}
|
||||
data:
|
||||
|
||||
Reference in New Issue
Block a user