Compare commits
11 Commits
ee1171d3e3
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 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,10 +1,40 @@
|
||||
using Convention;
|
||||
using Demo.Game.Attr;
|
||||
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
|
||||
{
|
||||
public static SkyUpdatement Make()
|
||||
|
||||
@@ -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,9 +6,60 @@ using Cinemachine;
|
||||
#endif
|
||||
using Convention.WindowsUI.Variant;
|
||||
using UnityEngine;
|
||||
using Demo.Game.Attr;
|
||||
using System.IO;
|
||||
using Convention;
|
||||
|
||||
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
|
||||
{
|
||||
private Camera MainCamera => Camera.main;
|
||||
|
||||
@@ -1,14 +1,36 @@
|
||||
using Convention;
|
||||
using Demo.Game.Attr;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Convention;
|
||||
using UnityEngine;
|
||||
using System;
|
||||
using Unity.Collections;
|
||||
using UnityEngine.Rendering;
|
||||
using System.IO;
|
||||
using Unity.Collections;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
|
||||
namespace Demo.Game
|
||||
{
|
||||
namespace ConfigType
|
||||
{
|
||||
public class DDTConfig : ScriptLoadableConfig
|
||||
{
|
||||
public NativeArray<float> Datas = new(128, Allocator.Persistent, NativeArrayOptions.UninitializedMemory);
|
||||
|
||||
public override void Deserialize(BinaryReader reader)
|
||||
{
|
||||
BinarySerializeUtility.DeserializeNativeArray(reader, ref Datas);
|
||||
base.Deserialize(reader);
|
||||
}
|
||||
|
||||
public override void Serialize(BinaryWriter writer)
|
||||
{
|
||||
BinarySerializeUtility.SerializeNativeArray(writer, Datas);
|
||||
base.Serialize(writer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Scriptable]
|
||||
public class DDT : ScriptableObject
|
||||
{
|
||||
protected override bool IsSelfEnableUpdate => false;
|
||||
@@ -46,7 +68,7 @@ namespace Demo.Game
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <20><>ȡ<EFBFBD><C8A1><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
|
||||
/// <20><>ȡ<EFBFBD><C8A1><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[Convention.RScript.Variable.Attr.Method]
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -205,6 +205,7 @@ namespace Demo.Game
|
||||
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);
|
||||
@@ -230,16 +231,26 @@ namespace Demo.Game
|
||||
yield break;
|
||||
}
|
||||
yield return Foo(rootGameObject.ParseFromScriptFile2Expr(rootObject));//ConventionUtility.AvoidFakeStop(rootGameObject.ParseFromScriptFile2Expr(rootObject));
|
||||
static void NDFS(ScriptableObject current)
|
||||
int applyDownCount = 0;
|
||||
void NDFS(ScriptableObject current)
|
||||
{
|
||||
foreach (var child in current.Childs)
|
||||
{
|
||||
NDFS(child);
|
||||
}
|
||||
if (current.IsScriptApply == false)
|
||||
ConventionUtility.StartCoroutine(current.ApplyScript());
|
||||
{
|
||||
applyDownCount++;
|
||||
IEnumerator NDFSFoo()
|
||||
{
|
||||
yield return current.ApplyScript();
|
||||
applyDownCount--;
|
||||
}
|
||||
ConventionUtility.StartCoroutine(NDFSFoo());
|
||||
}
|
||||
}
|
||||
NDFS(rootGameObject);
|
||||
yield return new WaitUntil(() => applyDownCount == 0);
|
||||
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
|
||||
{
|
||||
public class ScriptLoadableConfig
|
||||
{
|
||||
public int UID = -1;
|
||||
public Vector3 EnterGameLocalPosition, EnterGameEulerAngles, EnterGameLocalScaling;
|
||||
public bool IsSetObjectDisable;
|
||||
public int UpdatePerFrame;
|
||||
public int ScriptUpdateCounter;
|
||||
public string ScriptName;
|
||||
private string[] ChildTypes;
|
||||
public ScriptLoadableConfig[] childs;
|
||||
|
||||
public readonly static Dictionary<string, Func<ScriptLoadableConfig>> ConfigGeneraters = new()
|
||||
{
|
||||
{ nameof(ScriptLoadableConfig), ()=>new ScriptLoadableConfig() },
|
||||
};
|
||||
|
||||
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);
|
||||
ScriptUpdateCounter = BinarySerializeUtility.ReadInt(reader);
|
||||
ScriptName = BinarySerializeUtility.ReadString(reader);
|
||||
ChildTypes = BinarySerializeUtility.DeserializeStringArray(reader);
|
||||
int childCount = ChildTypes.Length;
|
||||
childs = new ScriptLoadableConfig[childCount];
|
||||
for (int i = 0; i < childCount; i++)
|
||||
{
|
||||
childs[i] = ConfigGeneraters[ChildTypes[i]].Invoke();
|
||||
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.WriteInt(writer, ScriptUpdateCounter);
|
||||
BinarySerializeUtility.WriteString(writer, ScriptName);
|
||||
BinarySerializeUtility.SerializeArray(writer, ChildTypes);
|
||||
foreach (var child in childs)
|
||||
{
|
||||
child.Serialize(writer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public partial class ScriptableObject : IScriptableObject
|
||||
{
|
||||
/// <summary>
|
||||
@@ -111,12 +178,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 +193,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;
|
||||
}
|
||||
}
|
||||
@@ -155,6 +226,7 @@ namespace Demo
|
||||
public ScriptableObject Parent;
|
||||
public readonly List<ScriptableObject> Childs = new();
|
||||
|
||||
private RootObject rootObjectCache = null;
|
||||
/// <summary>
|
||||
/// 获取根脚本对象
|
||||
/// </summary>
|
||||
@@ -162,12 +234,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;
|
||||
if (Parent is RootObject result)
|
||||
rootObjectCache = result;
|
||||
else
|
||||
rootObjectCache = Parent.GetRoot();
|
||||
}
|
||||
return rootObjectCache;
|
||||
}
|
||||
|
||||
|
||||
@@ -250,13 +326,23 @@ 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会是空的
|
||||
GetRoot().PushLoadedScriptObject(this);
|
||||
if (parent != null)
|
||||
{
|
||||
MyHierarchyItem = parent.MyHierarchyItem.GetHierarchyItem().CreateSubPropertyItem(1)[0];
|
||||
@@ -332,6 +418,7 @@ namespace Demo
|
||||
// 获取文件
|
||||
var file = new ToolFile(GetRoot().SourcePath);
|
||||
file = file | path;
|
||||
GetRoot().LoadedScriptSet.Add(file);
|
||||
// 找不到脚本
|
||||
if (file.Exists() == false)
|
||||
{
|
||||
@@ -539,7 +626,8 @@ namespace Demo
|
||||
}
|
||||
// 释放资源
|
||||
{
|
||||
this.ScriptableObjectContents.Clear();
|
||||
if (this.ScriptableObjectContents.IsCreated)
|
||||
this.ScriptableObjectContents.Dispose();
|
||||
}
|
||||
IsScriptApply = true;
|
||||
}
|
||||
@@ -699,31 +787,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 +820,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,7 @@ 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 +16,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()
|
||||
@@ -99,13 +36,23 @@ namespace Demo
|
||||
|
||||
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 ??= new Dictionary<string, Func<ScriptableObject>>(GameObjectInstantiate
|
||||
// .Union(DDTInstantiate)
|
||||
// .Union(TickUpdatementInstantiate)
|
||||
// .Union(MaterialUpdatementInstantiate)
|
||||
// .Union(SplineInstantiate)
|
||||
// .Union(JudgementInstantiate)
|
||||
// .Union(SingleVolumeInstantiate));
|
||||
if (s_ScriptableObjectInstantiate == null)
|
||||
{
|
||||
s_ScriptableObjectInstantiate = new();
|
||||
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));
|
||||
}
|
||||
}
|
||||
return s_ScriptableObjectInstantiate;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -212,31 +159,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 +200,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,13 +1,36 @@
|
||||
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
|
||||
{
|
||||
public static SubWorld Make()
|
||||
{
|
||||
@@ -23,7 +46,7 @@ namespace Demo.Game
|
||||
var ir = SceneManager.LoadSceneAsync(Editor.EditorController.SceneName, LoadSceneMode.Additive);
|
||||
ir.completed += x =>
|
||||
{
|
||||
SubWorldGameController = (from controller in FindObjectsOfType<GameController>()
|
||||
SubWorldGameController = (from controller in FindObjectsByType<GameController>(FindObjectsSortMode.None)
|
||||
where controller.RootSourcePath == project
|
||||
select controller).First();
|
||||
ConventionUtility.StartCoroutine(SubWorldGameController.GameInitBySubWorld(GetRoot().InputCatch));
|
||||
@@ -46,4 +69,4 @@ namespace Demo.Game
|
||||
this.project = project;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,11 +3,109 @@ using Demo.Editor.UI;
|
||||
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]
|
||||
|
||||
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,37 @@
|
||||
using Convention;
|
||||
using Demo.Game.Attr;
|
||||
using NUnit.Framework.Internal;
|
||||
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 override void Deserialize(BinaryReader reader)
|
||||
{
|
||||
IsZooming = BinarySerializeUtility.ReadBool(reader);
|
||||
ZoomCurve = (MathExtension.EaseCurveType)BinarySerializeUtility.ReadInt(reader);
|
||||
base.Deserialize(reader);
|
||||
}
|
||||
|
||||
public override void Serialize(BinaryWriter writer)
|
||||
{
|
||||
BinarySerializeUtility.WriteBool(writer, IsZooming);
|
||||
BinarySerializeUtility.WriteInt(writer, (int)ZoomCurve);
|
||||
base.Serialize(writer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Scriptable]
|
||||
public class ParticleJudgement : IJudgementHookObject, IAssetBundleLoader
|
||||
{
|
||||
public static ParticleJudgement Make()
|
||||
|
||||
@@ -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 LookAtAnchor : Updatement<int>
|
||||
{
|
||||
public static LookAtAnchor Make()
|
||||
@@ -17,14 +19,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,7 +44,6 @@ namespace Demo.Game
|
||||
[Convention.RScript.Variable.Attr.Method]
|
||||
public void Add(float time, ScriptableObject target)
|
||||
{
|
||||
LookAtCache.Add(target);
|
||||
ManualAddEntry(time, LookAtCache.Count - 1, default);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,39 @@
|
||||
using Convention;
|
||||
using Demo.Game.Attr;
|
||||
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
|
||||
{
|
||||
public static MaterialUpdatement Make()
|
||||
|
||||
@@ -1,21 +1,36 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using Convention;
|
||||
using Dreamteck.Splines;
|
||||
using Unity.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Demo.Game
|
||||
{
|
||||
public interface IDependOnSplineRenderer
|
||||
namespace ConfigType
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public static class DependOnSplineRendererUtility
|
||||
{
|
||||
public static BasicSplineRenderer LoadSplineRendererTool(this IDependOnSplineCore self, string path)
|
||||
public class BasicSplineRendererConfig : UpdatementVec2Config
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,19 +109,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,11 +1,39 @@
|
||||
using Convention;
|
||||
using Demo.Game.Attr;
|
||||
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>
|
||||
{
|
||||
public static SplineTubeRenderer Make()
|
||||
|
||||
@@ -1,10 +1,42 @@
|
||||
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
|
||||
{
|
||||
public static SplineAnchor Make()
|
||||
{
|
||||
@@ -22,16 +54,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,18 @@ 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)
|
||||
/// <param name="path">对象路径, 不存在时则立刻加载</param>
|
||||
[Convention.RScript.Variable.Attr.Method]
|
||||
void LoadSpline(SplineCore core)
|
||||
{
|
||||
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;
|
||||
MySplineCore = core;
|
||||
}
|
||||
}
|
||||
|
||||
[Scriptable]
|
||||
public class SplineCore : ScriptableObject
|
||||
{
|
||||
protected override bool IsSelfEnableUpdate => false;
|
||||
|
||||
@@ -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;
|
||||
@@ -12,7 +46,7 @@ namespace Demo.Game
|
||||
public static SplineNode Make()
|
||||
{
|
||||
var node = new GameObject("", typeof(Node)).AddComponent<SplineNode>();
|
||||
node.m_MyNode = node.GetOrAddComponent<Node>();
|
||||
node.m_MyNode = node.GetOrAddComponent<Node>();
|
||||
return node;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -1,13 +1,33 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using Convention;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Demo.Game
|
||||
{
|
||||
public abstract class BasicSplineJustFollow : Updatement<float>
|
||||
namespace ConfigType
|
||||
{
|
||||
public SplineCore MySplineCore;
|
||||
public class BasicSplineJustFollowConfig : ScriptLoadableConfig
|
||||
{
|
||||
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
|
||||
{
|
||||
public SplineCore MySplineCore { get; set; }
|
||||
|
||||
protected override float Lerp(float begin, float end, float t)
|
||||
{
|
||||
@@ -33,15 +53,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,13 @@
|
||||
using System.Collections;
|
||||
using Convention;
|
||||
using Convention.WindowsUI.Variant;
|
||||
using Demo.Game.Attr;
|
||||
using Dreamteck.Splines;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Demo.Game
|
||||
{
|
||||
[Scriptable]
|
||||
public class SplineMovement : BasicSplineJustFollow
|
||||
{
|
||||
public static SplineMovement Make()
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Convention;
|
||||
using Convention.WindowsUI.Variant;
|
||||
using Demo.Game.Attr;
|
||||
using Dreamteck.Splines;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Demo.Game
|
||||
{
|
||||
[Scriptable]
|
||||
public class SplinePointerObject : BasicSplineJustFollow
|
||||
{
|
||||
public static SplinePointerObject Make()
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Convention;
|
||||
using Demo.Game.Attr;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using Convention;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Demo.Game
|
||||
@@ -8,6 +9,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,12 +1,14 @@
|
||||
using Convention;
|
||||
using Convention.WindowsUI.Variant;
|
||||
using Demo.Game.Attr;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Convention;
|
||||
using Convention.WindowsUI.Variant;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Demo.Game
|
||||
{
|
||||
[Scriptable]
|
||||
public class TickMovement : Updatement<Vector3>
|
||||
{
|
||||
public static TickMovement Make()
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
using System;
|
||||
using Convention;
|
||||
using Demo.Game.Attr;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Demo.Game
|
||||
{
|
||||
[Scriptable]
|
||||
public class TickRotation : Updatement<Vector3>
|
||||
{
|
||||
public static TickRotation Make()
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
using System;
|
||||
using Convention;
|
||||
using Demo.Game.Attr;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Demo.Game
|
||||
{
|
||||
[Scriptable]
|
||||
public class TickScaling : Updatement<Vector3>
|
||||
{
|
||||
public static TickScaling Make()
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Convention;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
@@ -8,6 +9,23 @@ using UnityEngine.Rendering.Universal;
|
||||
|
||||
namespace Demo.Game
|
||||
{
|
||||
namespace ConfigType
|
||||
{
|
||||
// BaseVolume 配置(抽象基类Config)
|
||||
public class BaseVolumeConfig : ScriptLoadableConfig
|
||||
{
|
||||
public override void Deserialize(BinaryReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
}
|
||||
|
||||
public override void Serialize(BinaryWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class BaseVolume : ScriptableObject
|
||||
{
|
||||
[Resources, SerializeField] private Volume m_volume;
|
||||
@@ -60,6 +78,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,10 @@
|
||||
using Demo.Game.Attr;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering.Universal;
|
||||
|
||||
namespace Demo.Game
|
||||
{
|
||||
[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:
|
||||
48
Assets/Scripts/Volume/Updatement/BaseVolumeUpdatement.cs
Normal file
48
Assets/Scripts/Volume/Updatement/BaseVolumeUpdatement.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using Convention;
|
||||
using Demo.Game.Attr;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Demo.Game
|
||||
{
|
||||
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 : BaseVolumeConfig
|
||||
{
|
||||
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