-
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.
* events for when custom assets are loaded
- Loading branch information
1 parent
21ff061
commit 841019b
Showing
17 changed files
with
180 additions
and
80 deletions.
There are no files selected for viewing
This file was deleted.
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
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,8 @@ | ||
using UnityEngine; | ||
|
||
namespace OWML.Common | ||
{ | ||
public class AudioAsset : ModAsset<AudioSource> | ||
{ | ||
} | ||
} |
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,5 +1,4 @@ | ||
using System; | ||
using UnityEngine; | ||
|
||
namespace OWML.Common | ||
{ | ||
|
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,12 +1,10 @@ | ||
using UnityEngine; | ||
|
||
namespace OWML.Common | ||
namespace OWML.Common | ||
{ | ||
public interface IModAssets | ||
{ | ||
GameObject Load3DObject(ModBehaviour modBehaviour, string objectFilename, string imageFilename); | ||
MeshFilter LoadMesh(ModBehaviour modBehaviour, string objectFilename); | ||
MeshRenderer LoadTexture(ModBehaviour modBehaviour, string imageFilename); | ||
AudioSource LoadAudio(ModBehaviour modBehaviour, string audioFilename); | ||
ObjectAsset Load3DObject(ModBehaviour modBehaviour, string objectFilename, string imageFilename); | ||
MeshAsset LoadMesh(ModBehaviour modBehaviour, string objectFilename); | ||
TextureAsset LoadTexture(ModBehaviour modBehaviour, string imageFilename); | ||
AudioAsset LoadAudio(ModBehaviour modBehaviour, string audioFilename); | ||
} | ||
} |
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,8 @@ | ||
using UnityEngine; | ||
|
||
namespace OWML.Common | ||
{ | ||
public class MeshAsset : ModAsset<MeshFilter> | ||
{ | ||
} | ||
} |
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,33 @@ | ||
using System; | ||
using UnityEngine; | ||
|
||
namespace OWML.Common | ||
{ | ||
public class ModAsset<T> : MonoBehaviour | ||
{ | ||
public event Action<T> OnLoaded; | ||
|
||
public T Asset { get; private set; } | ||
|
||
public void SetAsset(T asset) | ||
{ | ||
Asset = asset; | ||
if (OnLoaded == null) | ||
{ | ||
ModBehaviour.ModHelper.Console.WriteLine("Invoking OnLoaded with no subscribers :("); | ||
} | ||
OnLoaded?.Invoke(asset); | ||
} | ||
|
||
private void Start() | ||
{ | ||
DontDestroyOnLoad(gameObject); | ||
} | ||
|
||
public T1 AddComponent<T1>() where T1 : Component | ||
{ | ||
return gameObject.AddComponent<T1>(); | ||
} | ||
|
||
} | ||
} |
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,8 @@ | ||
using UnityEngine; | ||
|
||
namespace OWML.Common | ||
{ | ||
public class ObjectAsset : ModAsset<GameObject> | ||
{ | ||
} | ||
} |
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,8 @@ | ||
using UnityEngine; | ||
|
||
namespace OWML.Common | ||
{ | ||
public class TextureAsset : ModAsset<MeshRenderer> | ||
{ | ||
} | ||
} |
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
Oops, something went wrong.