Skip to content

Commit

Permalink
fix: Simplify IDReferenceTable retrieval logic
Browse files Browse the repository at this point in the history
  • Loading branch information
IShix-g committed Aug 19, 2024
1 parent e3b742f commit a33bc20
Show file tree
Hide file tree
Showing 5 changed files with 199 additions and 24 deletions.
4 changes: 1 addition & 3 deletions Assets/Plugins/IDReference/Runtime/IDReferenceProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ public static IEnumerable<IDReferenceTable> GetTables()

public static IDReferenceTable GetTable(string tableID)
{
var table = idReferenceTables.FirstOrDefault(x => x.TableID == tableID);
Assert.IsNotNull(table, $"[ID reference provider] Nonexistent ID:{tableID}");
return table;
return idReferenceTables.FirstOrDefault(x => x.TableID == tableID);
}

/// <summary>
Expand Down
5 changes: 0 additions & 5 deletions Assets/Tests/IDReferenceSetting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@ public sealed class IDReferenceSetting
static IDReferenceTable itemTable;

static IDReferenceSetting()
{
EditorApplication.delayCall += Initialize;
}

static void Initialize()
{
characterTable = new IDReferenceTable("Character", disableRemoveButton: false, disableDropDownAddID: false, required: new []{ new IDReference("Mob モブ", "Mob") });
storyTable = new IDReferenceTable("Story", disableRemoveButton: true, disableDropDownAddID: true);
Expand Down
83 changes: 77 additions & 6 deletions Assets/Tests/IDReferenceTest.unity
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,11 @@ RenderSettings:
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0.37311915, g: 0.3807396, b: 0.35872662, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
m_ObjectHideFlags: 0
serializedVersion: 11
serializedVersion: 12
m_GIWorkflowMode: 1
m_GISettings:
serializedVersion: 2
Expand Down Expand Up @@ -98,7 +97,7 @@ LightmapSettings:
m_TrainingDataDestination: TrainingData
m_LightProbeSampleCountMultiplier: 4
m_LightingDataAsset: {fileID: 0}
m_UseShadowmask: 1
m_LightingSettings: {fileID: 1950371647}
--- !u!196 &4
NavMeshSettings:
serializedVersion: 2
Expand All @@ -118,6 +117,8 @@ NavMeshSettings:
manualTileSize: 0
tileSize: 256
accuratePlacement: 0
maxJobWorkers: 0
preserveTilesOutsideBounds: 0
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
Expand Down Expand Up @@ -200,6 +201,7 @@ Transform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 1, z: -10}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
Expand All @@ -211,6 +213,11 @@ PrefabInstance:
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 1147514551928605961, guid: a78ea247639cd4221a5d55d432d47ae0,
type: 3}
propertyPath: characterID
value: IDRef-Character-hwvyt
objectReference: {fileID: 0}
- target: {fileID: 1912912616023538711, guid: a78ea247639cd4221a5d55d432d47ae0,
type: 3}
propertyPath: m_Name
Expand Down Expand Up @@ -300,6 +307,7 @@ Transform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 1
Expand All @@ -316,7 +324,69 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 0d3eecc628e9e4cca84a1e80e29c35ab, type: 3}
m_Name:
m_EditorClassIdentifier:
characterID: IDRef-Character-iwp05
characterID: IDRef-Character-23g32
--- !u!850595691 &1950371647
LightingSettings:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Settings.lighting
serializedVersion: 4
m_GIWorkflowMode: 1
m_EnableBakedLightmaps: 1
m_EnableRealtimeLightmaps: 0
m_RealtimeEnvironmentLighting: 1
m_BounceScale: 1
m_AlbedoBoost: 1
m_IndirectOutputScale: 1
m_UsingShadowmask: 1
m_BakeBackend: 1
m_LightmapMaxSize: 1024
m_BakeResolution: 40
m_Padding: 2
m_LightmapCompression: 3
m_AO: 0
m_AOMaxDistance: 1
m_CompAOExponent: 1
m_CompAOExponentDirect: 0
m_ExtractAO: 0
m_MixedBakeMode: 2
m_LightmapsBakeMode: 1
m_FilterMode: 1
m_LightmapParameters: {fileID: 15204, guid: 0000000000000000f000000000000000, type: 0}
m_ExportTrainingData: 0
m_TrainingDataDestination: TrainingData
m_RealtimeResolution: 2
m_ForceWhiteAlbedo: 0
m_ForceUpdates: 0
m_FinalGather: 0
m_FinalGatherRayCount: 256
m_FinalGatherFiltering: 1
m_PVRCulling: 1
m_PVRSampling: 1
m_PVRDirectSampleCount: 32
m_PVRSampleCount: 512
m_PVREnvironmentSampleCount: 256
m_PVREnvironmentReferencePointCount: 2048
m_LightProbeSampleCountMultiplier: 4
m_PVRBounces: 2
m_PVRMinBounces: 2
m_PVREnvironmentMIS: 1
m_PVRFilteringMode: 1
m_PVRDenoiserTypeDirect: 1
m_PVRDenoiserTypeIndirect: 1
m_PVRDenoiserTypeAO: 1
m_PVRFilterTypeDirect: 0
m_PVRFilterTypeIndirect: 0
m_PVRFilterTypeAO: 0
m_PVRFilteringGaussRadiusDirect: 1
m_PVRFilteringGaussRadiusIndirect: 5
m_PVRFilteringGaussRadiusAO: 2
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
m_PVRFilteringAtrousPositionSigmaIndirect: 2
m_PVRFilteringAtrousPositionSigmaAO: 1
m_PVRTiledBaking: 0
--- !u!1001 &3612930196326534748
PrefabInstance:
m_ObjectHideFlags: 0
Expand All @@ -337,7 +407,7 @@ PrefabInstance:
- target: {fileID: 1147514551928605961, guid: 81a53f3540503443f943a89e28431607,
type: 3}
propertyPath: characterID
value: IDRef-Character-iwp05
value: IDRef-Character-fswz7
objectReference: {fileID: 0}
- target: {fileID: 1912912616023538711, guid: 81a53f3540503443f943a89e28431607,
type: 3}
Expand Down Expand Up @@ -411,6 +481,7 @@ Transform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 2
Expand All @@ -427,7 +498,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 0d3eecc628e9e4cca84a1e80e29c35ab, type: 3}
m_Name:
m_EditorClassIdentifier:
characterID: IDRef-Character-fswz7
characterID: IDRef-Character-iwp05
--- !u!1 &8459608127411491298
GameObject:
m_ObjectHideFlags: 0
Expand Down
121 changes: 121 additions & 0 deletions ProjectSettings/SceneTemplateSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
{
"templatePinStates": [],
"dependencyTypeInfos": [
{
"userAdded": false,
"type": "UnityEngine.AnimationClip",
"defaultInstantiationMode": 0
},
{
"userAdded": false,
"type": "UnityEditor.Animations.AnimatorController",
"defaultInstantiationMode": 0
},
{
"userAdded": false,
"type": "UnityEngine.AnimatorOverrideController",
"defaultInstantiationMode": 0
},
{
"userAdded": false,
"type": "UnityEditor.Audio.AudioMixerController",
"defaultInstantiationMode": 0
},
{
"userAdded": false,
"type": "UnityEngine.ComputeShader",
"defaultInstantiationMode": 1
},
{
"userAdded": false,
"type": "UnityEngine.Cubemap",
"defaultInstantiationMode": 0
},
{
"userAdded": false,
"type": "UnityEngine.GameObject",
"defaultInstantiationMode": 0
},
{
"userAdded": false,
"type": "UnityEditor.LightingDataAsset",
"defaultInstantiationMode": 0
},
{
"userAdded": false,
"type": "UnityEngine.LightingSettings",
"defaultInstantiationMode": 0
},
{
"userAdded": false,
"type": "UnityEngine.Material",
"defaultInstantiationMode": 0
},
{
"userAdded": false,
"type": "UnityEditor.MonoScript",
"defaultInstantiationMode": 1
},
{
"userAdded": false,
"type": "UnityEngine.PhysicMaterial",
"defaultInstantiationMode": 0
},
{
"userAdded": false,
"type": "UnityEngine.PhysicsMaterial2D",
"defaultInstantiationMode": 0
},
{
"userAdded": false,
"type": "UnityEngine.Rendering.PostProcessing.PostProcessProfile",
"defaultInstantiationMode": 0
},
{
"userAdded": false,
"type": "UnityEngine.Rendering.PostProcessing.PostProcessResources",
"defaultInstantiationMode": 0
},
{
"userAdded": false,
"type": "UnityEngine.Rendering.VolumeProfile",
"defaultInstantiationMode": 0
},
{
"userAdded": false,
"type": "UnityEditor.SceneAsset",
"defaultInstantiationMode": 1
},
{
"userAdded": false,
"type": "UnityEngine.Shader",
"defaultInstantiationMode": 1
},
{
"userAdded": false,
"type": "UnityEngine.ShaderVariantCollection",
"defaultInstantiationMode": 1
},
{
"userAdded": false,
"type": "UnityEngine.Texture",
"defaultInstantiationMode": 0
},
{
"userAdded": false,
"type": "UnityEngine.Texture2D",
"defaultInstantiationMode": 0
},
{
"userAdded": false,
"type": "UnityEngine.Timeline.TimelineAsset",
"defaultInstantiationMode": 0
}
],
"defaultDependencyTypeInfo": {
"userAdded": false,
"type": "<default_scene_template_dependencies>",
"defaultInstantiationMode": 1
},
"newSceneOverride": 0
}
10 changes: 0 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,6 @@ public sealed class IDReferenceSetting
static IDReferenceTable characterTable;

static IDReferenceSetting()
{
EditorApplication.delayCall += Initialize;
}

static void Initialize()
{
characterTable = new IDReferenceTable("Character", false, false);
IDReferenceProvider.SetTable(characterTable);
Expand Down Expand Up @@ -123,11 +118,6 @@ It is useful to have it set up.
static IDReferenceTable characterTable;

static IDReferenceSetting()
{
EditorApplication.delayCall += Initialize;
}

static void Initialize()
{
characterTable = new IDReferenceTable("Character", false, false);
IDReferenceProvider.SetTable(characterTable);
Expand Down

0 comments on commit a33bc20

Please sign in to comment.