forked from Shardstone/trail-into-darkness
First commit on my server, yey!
This commit is contained in:
35
Assets/Code/Platform/DesktopPlatform.cs
Normal file
35
Assets/Code/Platform/DesktopPlatform.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using Nox.Input;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AddressableAssets;
|
||||
|
||||
namespace Nox.Platform {
|
||||
public class DesktopPlatform : IPlatform {
|
||||
private readonly AssetReference assetReference;
|
||||
|
||||
private DesktopPlatformSettings desktopPlatformSettings;
|
||||
|
||||
public DesktopPlatform(AssetReference assetReference) {
|
||||
this.assetReference = assetReference;
|
||||
}
|
||||
|
||||
public PlatformSettings PlatformSettings => desktopPlatformSettings;
|
||||
public IEnumerator Initialize(object applicationData) {
|
||||
var handle = Addressables.LoadAssetAsync<DesktopPlatformSettings>(assetReference);
|
||||
yield return new WaitUntil(() => handle.IsDone);
|
||||
desktopPlatformSettings = handle.Result;
|
||||
Debug.Log($"Device Platform {desktopPlatformSettings.devicePlatform} initialized");
|
||||
InitializeInput();
|
||||
}
|
||||
|
||||
public IInput InitializeInput() {
|
||||
var inputHandler = new DesktopInput(desktopPlatformSettings);
|
||||
inputHandler.Initialize();
|
||||
return inputHandler;
|
||||
}
|
||||
public void Tick() { }
|
||||
public void Dispose() { }
|
||||
|
||||
public void OnApplicationQuit() { }
|
||||
}
|
||||
}
|
||||
2
Assets/Code/Platform/DesktopPlatform.cs.meta
Normal file
2
Assets/Code/Platform/DesktopPlatform.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 12257b10c3e51434690692262f91c5e2
|
||||
7
Assets/Code/Platform/DesktopPlatformSettings.cs
Normal file
7
Assets/Code/Platform/DesktopPlatformSettings.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Nox.Platform {
|
||||
[CreateAssetMenu(fileName = "DesktopPlatformSettings", menuName = "Nox/Database/Platform/DesktopPlatformSettings")]
|
||||
public class DesktopPlatformSettings : PlatformSettings {
|
||||
}
|
||||
}
|
||||
2
Assets/Code/Platform/DesktopPlatformSettings.cs.meta
Normal file
2
Assets/Code/Platform/DesktopPlatformSettings.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0cc0353d3bc1c4e459d99f4a43fd0d99
|
||||
25
Assets/Code/Platform/IPlatform.cs
Normal file
25
Assets/Code/Platform/IPlatform.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using Nox.Input;
|
||||
using System.Collections;
|
||||
|
||||
namespace Nox.Platform {
|
||||
|
||||
/// <summary>
|
||||
/// Add here your platforms as needed
|
||||
/// </summary>
|
||||
public enum DevicePlatform {
|
||||
Desktop,
|
||||
UnityEditor
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Factory interface for platform selection and initialization
|
||||
/// </summary>
|
||||
public interface IPlatform {
|
||||
PlatformSettings PlatformSettings { get; }
|
||||
IEnumerator Initialize(object applicationData);
|
||||
IInput InitializeInput();
|
||||
void Tick();
|
||||
void Dispose();
|
||||
void OnApplicationQuit();
|
||||
}
|
||||
}
|
||||
2
Assets/Code/Platform/IPlatform.cs.meta
Normal file
2
Assets/Code/Platform/IPlatform.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bc04131d1b2a34bd598c49aac51798ce
|
||||
11
Assets/Code/Platform/PlatformSettings.cs
Normal file
11
Assets/Code/Platform/PlatformSettings.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using Nox.Game;
|
||||
using Nox.Input;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Nox.Platform {
|
||||
public abstract class PlatformSettings : ScriptableObject {
|
||||
public DevicePlatform devicePlatform;
|
||||
public InputSettings inputSettings;
|
||||
public GameObject cameraPrefab;
|
||||
}
|
||||
}
|
||||
2
Assets/Code/Platform/PlatformSettings.cs.meta
Normal file
2
Assets/Code/Platform/PlatformSettings.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 43a7da5fc809941d08a8085b930a43f7
|
||||
33
Assets/Code/Platform/UnityEditorPlatform.cs
Normal file
33
Assets/Code/Platform/UnityEditorPlatform.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using Nox.Input;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AddressableAssets;
|
||||
|
||||
namespace Nox.Platform {
|
||||
public class UnityEditorPlatform : IPlatform {
|
||||
private readonly AssetReference assetReference;
|
||||
private UnityEditorPlatformSettings editorPlatformSettings;
|
||||
|
||||
public UnityEditorPlatform(AssetReference assetReference) {
|
||||
this.assetReference = assetReference;
|
||||
}
|
||||
public PlatformSettings PlatformSettings => editorPlatformSettings;
|
||||
public IEnumerator Initialize(object applicationData) {
|
||||
var handle = Addressables.LoadAssetAsync<UnityEditorPlatformSettings>(assetReference);
|
||||
yield return new WaitUntil(() => handle.IsDone);
|
||||
editorPlatformSettings = handle.Result;
|
||||
Debug.Log($"Device Platform {editorPlatformSettings.devicePlatform} initialized");
|
||||
InitializeInput();
|
||||
}
|
||||
|
||||
public IInput InitializeInput() {
|
||||
var inputHandler = new EditorInput(editorPlatformSettings);
|
||||
inputHandler.Initialize();
|
||||
return inputHandler;
|
||||
}
|
||||
public void Tick() { }
|
||||
public void Dispose() { }
|
||||
|
||||
public void OnApplicationQuit() { }
|
||||
}
|
||||
}
|
||||
2
Assets/Code/Platform/UnityEditorPlatform.cs.meta
Normal file
2
Assets/Code/Platform/UnityEditorPlatform.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1018321491bd24e558f83b130106ee31
|
||||
8
Assets/Code/Platform/UnityEditorPlatformSettings.cs
Normal file
8
Assets/Code/Platform/UnityEditorPlatformSettings.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Nox.Platform {
|
||||
[CreateAssetMenu(fileName = "UnityEditorPlatformSettings", menuName = "Nox/Database/Platform/UnityEditorPlatformSettings")]
|
||||
public class UnityEditorPlatformSettings: PlatformSettings{
|
||||
|
||||
}
|
||||
}
|
||||
2
Assets/Code/Platform/UnityEditorPlatformSettings.cs.meta
Normal file
2
Assets/Code/Platform/UnityEditorPlatformSettings.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 991c17f0fe58d4538bcae7b792ccf6bc
|
||||
Reference in New Issue
Block a user