Skip to content

Instantly share code, notes, and snippets.

@scottgeye
Created September 9, 2020 05:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scottgeye/203ace5b52b958df97f43fa62c038c3f to your computer and use it in GitHub Desktop.
Save scottgeye/203ace5b52b958df97f43fa62c038c3f to your computer and use it in GitHub Desktop.
My Mixed Reality Apartment - Part II
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace OculusSampleFramework
{
public class PanelController : MonoBehaviour
{
public Color color1;
public Color color2;
public Color color3;
public Color color4;
public GameObject panel;
public GameObject movie;
public GameObject roof;
public Material skybox1;
public Material skybox2;
public Material skybox3;
public Material skybox4;
public Material wall;
private void processAnimation(GameObject obj)
{
Animator animator = obj.GetComponent<Animator>();
AnimatorStateInfo state = animator.GetCurrentAnimatorStateInfo(0);
if (state.IsName("IdleStart"))
{
animator.Play("AnimForward");
}
else if (state.IsName("IdleEnd"))
{
animator.Play("AnimBackward");
}
else if (state.IsName("AnimForward"))
{
animator.Play("AnimBackward", -1, (1 - state.normalizedTime));
}
else if (state.IsName("AnimBackward"))
{
animator.Play("AnimForward", -1, (1 - state.normalizedTime));
}
}
private void SetColor(Color color)
{
wall.color = color;
}
private void SetSkybox(Material skybox)
{
RenderSettings.skybox = skybox;
}
public void RunPanelAnimatoin(InteractableStateArgs obj)
{
if (obj.NewInteractableState == InteractableState.ActionState)
{
processAnimation(panel);
}
}
public void RunMovieAnimatoin(InteractableStateArgs obj)
{
if (obj.NewInteractableState == InteractableState.ActionState)
{
processAnimation(movie);
}
}
public void RunRoofAnimatoin(InteractableStateArgs obj)
{
if (obj.NewInteractableState == InteractableState.ActionState)
{
processAnimation(roof);
}
}
public void SetSkybox1(InteractableStateArgs obj)
{
if (obj.NewInteractableState == InteractableState.ActionState)
{
SetSkybox(skybox1);
}
}
public void SetSkybox2(InteractableStateArgs obj)
{
if (obj.NewInteractableState == InteractableState.ActionState)
{
SetSkybox(skybox2);
}
}
public void SetSkybox3(InteractableStateArgs obj)
{
if (obj.NewInteractableState == InteractableState.ActionState)
{
SetSkybox(skybox3);
}
}
public void SetSkybox4(InteractableStateArgs obj)
{
if (obj.NewInteractableState == InteractableState.ActionState)
{
SetSkybox(skybox4);
}
}
public void SetWallColor1(InteractableStateArgs obj)
{
if (obj.NewInteractableState == InteractableState.ActionState)
{
SetColor(color1);
}
}
public void SetWallColor2(InteractableStateArgs obj)
{
if (obj.NewInteractableState == InteractableState.ActionState)
{
SetColor(color2);
}
}
public void SetWallColor3(InteractableStateArgs obj)
{
if (obj.NewInteractableState == InteractableState.ActionState)
{
SetColor(color3);
}
}
public void SetWallColor4(InteractableStateArgs obj)
{
if (obj.NewInteractableState == InteractableState.ActionState)
{
SetColor(color4);
}
}
void Update()
{
if (Input.GetKeyDown("m"))
{
processAnimation(movie);
}
if (Input.GetKeyDown("p"))
{
processAnimation(panel);
}
if (Input.GetKeyDown("r"))
{
processAnimation(roof);
}
if (Input.GetKeyDown("1"))
{
SetColor(color1);
}
if (Input.GetKeyDown("2"))
{
SetColor(color2);
}
if (Input.GetKeyDown("3"))
{
SetColor(color3);
}
if (Input.GetKeyDown("4"))
{
SetColor(color4);
}
if (Input.GetKeyDown("5"))
{
SetSkybox(skybox1);
}
if (Input.GetKeyDown("6"))
{
SetSkybox(skybox2);
}
if (Input.GetKeyDown("7"))
{
SetSkybox(skybox3);
}
if (Input.GetKeyDown("8"))
{
SetSkybox(skybox4);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment