-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathActionManager.cs
executable file
·61 lines (51 loc) · 1.55 KB
/
ActionManager.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Designium.ARDKHandson1.Sample1
{
public class ActionManager : MonoBehaviour
{
[SerializeField]
private GameObject ballPrefab;
[SerializeField]
private Camera mainCamera;
void Start()
{
}
void Update()
{
#if UNITY_EDITOR
//
// UnityEditorで動かしてるとき
//
if(Input.GetMouseButtonDown(0)){
//
// 画面がクリックされた時の処理
//
FireBall();
}
#else
//
// ビルドして実機で動かしてるとき
//
if(Input.touchCount>0){
Touch touch0 = Input.GetTouch(0);
if(touch0.phase == TouchPhase.Began){
//
// 画面がタッチされた時の処理
//
FireBall();
}
}
#endif
}
/// <summary>
/// ボールオブジェクトを生成して飛ばします。
/// </summary>
private void FireBall(){
float power = 2.0f;//ボールを飛ばす強さ
GameObject ballObject = GameObject.Instantiate(ballPrefab, mainCamera.transform.position, Quaternion.identity);
ballObject.GetComponent<Rigidbody>().AddForce(mainCamera.transform.forward* power);
}
}
}