mirror of
https://udrimavric.com/MAVRIC/Stratasys-Fortus-450mc-HL2.git
synced 2025-01-22 07:09:03 -05:00
Created Runtime Channels, Listeners, and Setters
This commit is contained in:
parent
2c1196e0f6
commit
9be4fe7c30
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7ba7cedd073e4a6f869fcb3fdba38fe2
|
||||
timeCreated: 1690556002
|
@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
public class RuntimeChannelSetter : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private bool setOnEnable = true;
|
||||
|
||||
[SerializeField] private UnityEvent callback;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
if (setOnEnable)
|
||||
{
|
||||
InvokeCallback();
|
||||
}
|
||||
}
|
||||
|
||||
[DisableInEditorMode, Button]
|
||||
public void InvokeCallback()
|
||||
{
|
||||
callback?.Invoke();
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d5e1fb4e3add65044a7e9fd8128e3c41
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0cd34c19fd60d33429d5636a81e873d4
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f7dd438c20543b34f8dd79728383d1cd
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,14 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 0327ca002d064b259a55b24ac5a8a9db, type: 3}
|
||||
m_Name: MRTKCamera
|
||||
m_EditorClassIdentifier:
|
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3651088cd3d295d4787de993e175dd9f
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,22 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
public abstract class RuntimeChannelSO<T> : ScriptableObject where T : Object
|
||||
{
|
||||
public UnityAction<T> OnEventRaised;
|
||||
|
||||
public T Value
|
||||
{
|
||||
get;
|
||||
protected set;
|
||||
}
|
||||
|
||||
[DisableInEditorMode, Button]
|
||||
public void RaiseEvent(T arg0)
|
||||
{
|
||||
OnEventRaised?.Invoke(Value = arg0);
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 44f544c3eae3f194b89da972f1038f0d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 229d29dbedb54cfd8e6602fd456a8e7f
|
||||
timeCreated: 1690552737
|
@ -0,0 +1,10 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace SO.Channels.RuntimeChannels
|
||||
{
|
||||
[CreateAssetMenu(menuName = "Channel/Runtime/Transform")]
|
||||
public class TransformRuntimeChannelSO : RuntimeChannelSO<Transform>
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0327ca002d064b259a55b24ac5a8a9db
|
||||
timeCreated: 1690552769
|
3
Assets/Stratasys-Fortus-450mc/Scripts/SO/Listeners.meta
Normal file
3
Assets/Stratasys-Fortus-450mc/Scripts/SO/Listeners.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 67eb5a97b9074dfba0d42142ec145c90
|
||||
timeCreated: 1690555237
|
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ca28fc4a6aaa4f82a431b8f7f3dd4da0
|
||||
timeCreated: 1690555244
|
@ -0,0 +1,14 @@
|
||||
using SO.Channels.RuntimeChannels;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
namespace SO.Listeners.Runtime
|
||||
{
|
||||
[System.Serializable]
|
||||
public class TransformUnityEvent : UnityEvent<Transform> {}
|
||||
|
||||
public class TransformRuntimeChannelListener : RuntimeChannelListener<Transform, TransformRuntimeChannelSO, TransformUnityEvent>
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a239f3ebd8bb403192451bfc3e06d087
|
||||
timeCreated: 1690555627
|
@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
namespace SO.Listeners
|
||||
{
|
||||
public abstract class RuntimeChannelListener<T, TChannel, TEvent> : MonoBehaviour
|
||||
where T : Object
|
||||
where TChannel : RuntimeChannelSO<T>
|
||||
where TEvent : UnityEvent<T>
|
||||
{
|
||||
[SerializeField] private bool readValueOnEnable = true;
|
||||
|
||||
[SerializeField] private TChannel channel;
|
||||
|
||||
[SerializeField] private TEvent callback;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
channel.OnEventRaised += InvokeResponse;
|
||||
|
||||
if (readValueOnEnable)
|
||||
{
|
||||
InvokeResponse(channel.Value);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
channel.OnEventRaised -= InvokeResponse;
|
||||
}
|
||||
|
||||
private void InvokeResponse(T arg0)
|
||||
{
|
||||
callback?.Invoke(arg0);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6a78bf08e18546ff88114d6d4cf9ae4f
|
||||
timeCreated: 1690555261
|
Loading…
Reference in New Issue
Block a user