Skip to content

Commit

Permalink
update new sample for data verification
Browse files Browse the repository at this point in the history
  • Loading branch information
cathei committed Aug 13, 2022
1 parent 0f81dd0 commit ae8d0c6
Show file tree
Hide file tree
Showing 14 changed files with 205 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public static class PackageGenerationTools
const string PackagePath = "Packages/com.cathei.bakingsheet";
const string SamplePath = "Assets/Samples";

[MenuItem("Tools/Generate Package")]
[MenuItem("BakingSheet/Generate Package")]
public static void GeneratePackage()
{
// GITHUB_REF = refs/heads/v1.X.X
Expand All @@ -37,7 +37,7 @@ public static void GeneratePackage()
Debug.Log($"Generating Unity Package Completed: {savePath} {sampleSavePath}");
}

[MenuItem("Tools/Generate Package (AssetStore)")]
[MenuItem("BakingSheet/Generate Package (AssetStore)")]
public static void GeneratePackageCombined()
{
var info = UnityEditor.PackageManager.PackageInfo.FindForAssetPath(PackagePath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public override JsonSerializerSettings GetSettings(Microsoft.Extensions.Logging.
}
}

[MenuItem("Tools/Import From Google")]
[MenuItem("BakingSheet/Sample/Import From Google")]
public static async void ConvertFromGoogle()
{
var jsonPath = Path.Combine(Application.streamingAssetsPath, "Google");
Expand Down
8 changes: 8 additions & 0 deletions UnityProject/Assets/Samples/006 - Data Verification.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "BakingSheet.Samples.Verification.Editor",
"rootNamespace": "",
"references": [
"BakingSheet",
"BakingSheet.Samples",
"BakingSheet.Editor"
],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
using System;
using System.IO;
using UnityEditor;
using UnityEngine;
using ILogger = Microsoft.Extensions.Logging.ILogger;

namespace Cathei.BakingSheet.Examples
{
public static class VerificationTools
{
class VerificationSheet : Sheet<VerificationSheet.Row>
{
public class Row : SheetRow
{
[Resource] public string ResourcePath { get; set; }
}
}

class SheetContainer : SheetContainerBase
{
public SheetContainer(ILogger logger) : base(logger) { }

public VerificationSheet Verification { get; set; }
}

[MenuItem("BakingSheet/Sample/Verify Sheet")]
public static void VerifySheet()
{
var sheetContainer = new SheetContainer(new UnityLogger());

// you can generate sheet with code
sheetContainer.Verification = new VerificationSheet
{
new VerificationSheet.Row
{
Id = "Row1",
ResourcePath = "SamplePrefab1"
},
new VerificationSheet.Row
{
Id = "Row2",
ResourcePath = "SamplePrefab2"
},
new VerificationSheet.Row
{
Id = "Row3",
ResourcePath = "SamplePrefab3"
},
};

// SheetContainer.Bake will call PostLoad implicitly
// However you need to call PostLoad manually if you're generating sheet with code
sheetContainer.PostLoad();

// call SheetVerifier instances you want to process
sheetContainer.Verify(new ResourceAssetVerifier());

Debug.Log("End of sheet verification");
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &5741794240766330556
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 746415233758999732}
m_Layer: 0
m_Name: SamplePrefab1
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &746415233758999732
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5741794240766330556}
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_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &5741794240766330556
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 746415233758999732}
m_Layer: 0
m_Name: SamplePrefab2
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &746415233758999732
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5741794240766330556}
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_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public override string Verify(ResourceAttribute attribute, string path)
if (string.IsNullOrEmpty(path))
return null;

path = Path.Combine(attribute.Prefix, path);
path = Path.Combine(attribute.Prefix ?? "", path);

var obj = Resources.Load(path);
if (obj != null)
Expand Down

0 comments on commit ae8d0c6

Please sign in to comment.