Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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