generated from CareBoo/UPMTemplate-2020
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(abi): ✨ add
InterfaceImporter
for interface.json
files descr…
…ibing abi interfaces
- Loading branch information
1 parent
998fd5a
commit 1d6c7ad
Showing
8 changed files
with
69 additions
and
2 deletions.
There are no files selected for viewing
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
File renamed without changes.
21 changes: 21 additions & 0 deletions
21
Editor/Algorand.Unity.Editor/Importers/Abi/InterfaceImporter.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,21 @@ | ||
using System.IO; | ||
using UnityEditor.AssetImporters; | ||
using UnityEngine; | ||
|
||
namespace Algorand.Unity.Experimental.Abi.Editor | ||
{ | ||
[ScriptedImporter(1, "interface.json")] | ||
public class InterfaceImporter : ScriptedImporter | ||
{ | ||
public override void OnImportAsset(AssetImportContext ctx) | ||
{ | ||
var fileName = Path.GetFileNameWithoutExtension(ctx.assetPath); | ||
var json = File.ReadAllText(ctx.assetPath); | ||
var asset = ScriptableObject.CreateInstance<InterfaceAsset>(); | ||
asset.@interface = AlgoApiSerializer.DeserializeJson<Interface>(json); | ||
asset.name = fileName; | ||
ctx.AddObjectToAsset("interface", asset); | ||
ctx.SetMainObject(asset); | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
Editor/Algorand.Unity.Editor/Importers/Abi/InterfaceImporter.cs.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
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,16 @@ | ||
using UnityEngine; | ||
|
||
namespace Algorand.Unity.Experimental.Abi | ||
{ | ||
[HelpURL(DocUrl.Api + "Algorand.Unity.Experimental.Abi.InterfaceAsset.html")] | ||
[CreateAssetMenu(menuName = "Algorand/Experimental/Abi/Interface")] | ||
public class InterfaceAsset : ScriptableObject | ||
{ | ||
public Interface @interface; | ||
|
||
public static implicit operator Interface(InterfaceAsset asset) | ||
{ | ||
return asset.@interface; | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
Runtime/Algorand.Unity/Experimental/Abi/InterfaceAsset.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.