Created
June 19, 2017 11:11
-
-
Save TakahiroMiyaura/173a3fe30ee2f36463bf198686981d80 to your computer and use it in GitHub Desktop.
HoloLensで始めるMRDesignLabs - ObjectCollection、各種ボタン、イベント制御を使う ref: http://qiita.com/miyaura/items/15294d34f4a109355d4d
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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(); | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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