-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
730100c
commit 0d0e65f
Showing
8 changed files
with
107 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
Samples~/CreateAndDelete/CodeSmileAssetDatabaseExamples.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright (C) 2021-2024 Steffen Itterheim | ||
// Refer to included LICENSE file for terms and conditions. | ||
|
||
using CodeSmileEditor; | ||
using System; | ||
using System.IO; | ||
using UnityEditor; | ||
using UnityEngine; | ||
|
||
public static class CodeSmileAssetDatabaseExamples | ||
{ | ||
private const String TestFolder = "Assets/_sub_folder_"; | ||
|
||
/// <summary> | ||
/// For more usage examples please refer to the numerous Unit Tests: | ||
/// Packages/CodeSmile AssetDatabase/Tests/Editor/*.cs | ||
/// </summary> | ||
/// <remarks>API reference: https://codesmile-0000011110110111.github.io/de.codesmile.assetdatabase</remarks> | ||
[MenuItem("Window/CodeSmile/AssetDatabase Examples/Create and Delete Asset")] | ||
private static void CreateAndDeleteAsset() | ||
{ | ||
var path = $"{TestFolder}/TestAsset.asset"; | ||
var asset = new Asset(ScriptableObject.CreateInstance<TestAsset>(), path); | ||
|
||
var instance = asset.MainObject; | ||
var assetPath = asset.AssetPath; | ||
Debug.Log($"Asset '{instance}' created at '{assetPath}'"); | ||
|
||
var message = asset.GetMain<TestAsset>().Message; | ||
Debug.Log($"Asset says: '{message}'"); | ||
|
||
asset.Delete(); | ||
Debug.Log($"Asset deleted: {asset.IsDeleted}"); | ||
|
||
// a folder is an asset, too! | ||
var folder = new Asset(TestFolder); | ||
folder.Delete(); | ||
|
||
Debug.Log($"Testfolder removed: {!Directory.Exists(TestFolder)}"); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
Samples~/CreateAndDelete/CodeSmileAssetDatabaseExamples.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
18 changes: 18 additions & 0 deletions
18
Samples~/CreateAndDelete/CodeSmileEditor.AssetDatabase.Examples.asmdef
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"name": "CodeSmileEditor.AssetDatabase.Examples", | ||
"rootNamespace": "", | ||
"references": [ | ||
"GUID:38cc5939e6694a64d8d6ea3aaca03495" | ||
], | ||
"includePlatforms": [ | ||
"Editor" | ||
], | ||
"excludePlatforms": [], | ||
"allowUnsafeCode": false, | ||
"overrideReferences": false, | ||
"precompiledReferences": [], | ||
"autoReferenced": true, | ||
"defineConstraints": [], | ||
"versionDefines": [], | ||
"noEngineReferences": false | ||
} |
7 changes: 7 additions & 0 deletions
7
Samples~/CreateAndDelete/CodeSmileEditor.AssetDatabase.Examples.asmdef.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// Copyright (C) 2021-2024 Steffen Itterheim | ||
// Refer to included LICENSE file for terms and conditions. | ||
|
||
using System; | ||
using UnityEngine; | ||
|
||
public class TestAsset : ScriptableObject | ||
{ | ||
public String Message = "To be, or not to be: that is not a question."; | ||
|
||
private void OnEnable() => name = "Test ScriptableObject"; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
{ | ||
"name": "de.codesmile.assetdatabase", | ||
"displayName": "CodeSmile AssetDatabase", | ||
"description": "Accessible 'clean code' version of Unity's ~20 year old AssetDatabase class and related functionality.\n\nPublished under multiple licenses:\n- GPL 3.0 for personal & educational use\n- Custom licensing for Asset Publishers & Sponsors (<a href=\"mailto:[email protected]\">contact me</a>)\n- Asset Store Terms and EULA for most other uses", | ||
"version": "1.8.3", | ||
"description": "The AssetDatabase in enjoyable, consistent, concise, convenient, comprehensible, safe, documented form.\n\nAvailable under multiple licenses:\n- GPL 3.0 for personal & educational use\n- Asset Store Terms and EULA for commercial use", | ||
"version": "1.8.4", | ||
"unity": "2021.3", | ||
"unityRelease": "3f1", | ||
"author": { | ||
|
@@ -16,5 +16,12 @@ | |
"dependencies": { | ||
"com.unity.test-framework": "1.4.1" | ||
}, | ||
"relatedPackages": {} | ||
"relatedPackages": {}, | ||
"samples": [ | ||
{ | ||
"displayName": "Create and Delete Asset", | ||
"description": "Basic asset lifetime example.", | ||
"path": "Samples~/CreateAndDelete" | ||
} | ||
] | ||
} |