Skip to content

Instantly share code, notes, and snippets.

@flushpot1125
Last active August 6, 2017 08:33
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 flushpot1125/7091d111d0af449c8946102a70177e23 to your computer and use it in GitHub Desktop.
Save flushpot1125/7091d111d0af449c8946102a70177e23 to your computer and use it in GitHub Desktop.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using HoloToolkit.Unity.SpatialMapping;
public class ObjectManipulator : MonoBehaviour {
private GameObject CGModelObj;
private AudioSource CGModelAudioSource;
[SerializeField]
SpatialMappingManager sManager;
private bool CGModelAudioFlag = false;
void Start(){
CGModelObj = GameObject.Find("CGModel");
CGModelAudioSource = CGModelObj.GetComponent<AudioSource>();
}
void Update() {
//メッシュ情報の表示/非表示
if (Input.GetKeyDown(KeyCode.K)) {
if (sManager.DrawVisualMeshes == false) {
sManager.DrawVisualMeshes =true;
} else {
sManager.DrawVisualMeshes = false;
}
}
CGModelObj.transform.position = new Vector3(CGModelObj.transform.position.x + Input.GetAxis("Horizontal") / 50, CGModelObj.transform.position.y, CGModelObj.transform.position.z + Input.GetAxis("Vertical") / 50);
//CGModelを動かしている間だけ効果音を再生。CGモデルの駆動音再現につかえる
if (((Input.GetAxis("Horizontal") != 0) || (Input.GetAxis("Vertical") != 0)) && (CGModelAudioFlag== true)) {
CGModelAudioSource.Play();
CGModelAudioFlag = false;
} else if (((Input.GetAxis("Horizontal") == 0) && (Input.GetAxis("Vertical") == 0)) && (bulldozerAudioFlag == false)) {
CGModelAudioSource.Stop();
CGModelAudioFlag = true;
} else {
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment