浏览代码

New GunController class

/2019.3-marc
Marc Tanenbaum 5 年前
当前提交
8c22f451
共有 2 个文件被更改,包括 66 次插入0 次删除
  1. 55
      Assets/GunController.cs
  2. 11
      Assets/GunController.cs.meta

55
Assets/GunController.cs


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.Playables;
public class GunController : MonoBehaviour
{
public InputAction fireAction;
public GameObject gun;
private PlayableDirector gunDirector;
// Start is called before the first frame update
void Start()
{
InitGuns();
// Have it run your code when the Action is triggered.
fireAction.performed += FireGuns;
// Start listening for control changes.
fireAction.Enable();
}
// Update is called once per frame
void Update()
{
// if (Input.GetAxis("fire") > 1)
// {
// DeployGuns();
// }
}
void InitGuns()
{
gunDirector = gun.GetComponent<PlayableDirector>();
gunDirector.time = 0f;
gunDirector.Stop();
Debug.LogFormat("InitGuns {0}", gunDirector.time);
}
void DeployGuns()
{
gunDirector.Play();
}
void FireGuns(InputAction.CallbackContext ctx)
{
Debug.Log("FIRE!!!!");
gunDirector.Play();
}
}

11
Assets/GunController.cs.meta


fileFormatVersion: 2
guid: 6eb3475d2a3ec441cb8e3ba032309d3a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存