forked from cgvr/DeltaVR
deltavr multiplayer 2.0
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
namespace UnityEngine.XR.Content.Interaction
|
||||
{
|
||||
/// <summary>
|
||||
/// This class is responsible for creating the perler sockets grid and turning on/off the machine.
|
||||
/// </summary>
|
||||
public class PerlerMachineController : MonoBehaviour
|
||||
{
|
||||
static readonly string k_EmissionKeyword = "_EMISSION";
|
||||
|
||||
[SerializeField]
|
||||
[Tooltip("The emissive materials that will change state whenever the machine is turned on/off")]
|
||||
Material[] m_EmissiveMaterials;
|
||||
|
||||
bool m_MachineActive;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
DisableEmissiveMaterials();
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
void OnDestroy()
|
||||
{
|
||||
EnableEmissiveMaterials();
|
||||
}
|
||||
#endif
|
||||
|
||||
void DisableEmissiveMaterials()
|
||||
{
|
||||
foreach (var material in m_EmissiveMaterials)
|
||||
material.DisableKeyword(k_EmissionKeyword);
|
||||
}
|
||||
|
||||
void EnableEmissiveMaterials()
|
||||
{
|
||||
foreach (var material in m_EmissiveMaterials)
|
||||
material.EnableKeyword(k_EmissionKeyword);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Call this method to activate or deactivate the machine. This will also turn on/off its lights.
|
||||
/// Used by the BatterySlot GameObject socket.
|
||||
/// </summary>
|
||||
/// <param name="active">Value of <see langword="true"/> to activate the machine; <see langword="false"/> otherwise.</param>
|
||||
public void SetMachineActive(bool active)
|
||||
{
|
||||
// It's the same state?
|
||||
if (active == m_MachineActive)
|
||||
return;
|
||||
|
||||
// Change the machine light state
|
||||
m_MachineActive = active;
|
||||
if (m_MachineActive)
|
||||
EnableEmissiveMaterials();
|
||||
else
|
||||
DisableEmissiveMaterials();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9cc7fa0773a606e42930df5c728731e6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user