Skip to content

Instantly share code, notes, and snippets.

@TakahiroMiyaura
Created June 19, 2017 11:11
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 TakahiroMiyaura/173a3fe30ee2f36463bf198686981d80 to your computer and use it in GitHub Desktop.
Save TakahiroMiyaura/173a3fe30ee2f36463bf198686981d80 to your computer and use it in GitHub Desktop.
HoloLensで始めるMRDesignLabs - ObjectCollection、各種ボタン、イベント制御を使う ref: http://qiita.com/miyaura/items/15294d34f4a109355d4d
// Copyright(c) 2017 Takahiro Miyaura
// Released under the MIT license
// http://opensource.org/licenses/mit-license.php
using System.Collections;
using System.Collections.Generic;
using HUX.Collections;
using HUX.Interaction;
using HUX.Receivers;
using UnityEngine;
public class CollectionChangeReceiver : InteractionReceiver
{
private ObjectCollection _objectCollection;
void Start()
{
_objectCollection = this.Targets[0].GetComponent<ObjectCollection>();
SetPlaneParams();
}
protected override void OnTapped(GameObject obj, InteractionManager.InteractionEventArgs eventArgs)
{
if (obj.name.Equals("ObjectCollectionCylinder"))
{
SetCylinderParams();
}
else if (obj.name.Equals("ObjectCollectionPlane"))
{
SetPlaneParams();
}
else if (obj.name.Equals("ObjectCollectionScatter"))
{
SetScatterParams();
}
else if (obj.name.Equals("ObjectCollectionSphere"))
{
SetSphereParams();
}
}
private void SetSphereParams()
{
_objectCollection.SurfaceType = ObjectCollection.SurfaceTypeEnum.Sphere;
_objectCollection.transform.localPosition = Vector3.zero;
_objectCollection.Radius = 2f;
_objectCollection.Rows = 3;
_objectCollection.UpdateCollection();
}
private void SetScatterParams()
{
_objectCollection.SurfaceType = ObjectCollection.SurfaceTypeEnum.Scatter;
_objectCollection.transform.localPosition = new Vector3(0f, 0f, 2f);
_objectCollection.Radius = 1f;
_objectCollection.UpdateCollection();
}
private void SetPlaneParams()
{
_objectCollection.SurfaceType = ObjectCollection.SurfaceTypeEnum.Plane;
_objectCollection.transform.localPosition = new Vector3(0f, 0f, 2f);
_objectCollection.Radius = 2f;
_objectCollection.Rows = 3;
_objectCollection.UpdateCollection();
}
private void SetCylinderParams()
{
_objectCollection.SurfaceType = ObjectCollection.SurfaceTypeEnum.Cylinder;
_objectCollection.transform.localPosition = Vector3.zero;
_objectCollection.Radius = 2f;
_objectCollection.Rows = 1;
_objectCollection.UpdateCollection();
}
}
// Copyright(c) 2017 Takahiro Miyaura
// Released under the MIT license
// http://opensource.org/licenses/mit-license.php
using System.Collections;
using System.Collections.Generic;
using HUX.Interaction;
using HUX.Receivers;
using UnityEngine;
using UnityEngine.SceneManagement;
public class SceneChangeReceiver : InteractionReceiver
{
protected override void OnTapped(GameObject obj, InteractionManager.InteractionEventArgs eventArgs)
{
SceneManager.LoadScene(obj.name);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment