1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- /// <summary>
- /// 胶带控制案例
- /// </summary>
- public class JD_Controller_Example : MonoBehaviour
- {
- public ChivaVR_JD_ShaderController[] controllers;
- // Update is called once per frame
- void Update()
- {
- if (Input.GetKeyDown(KeyCode.Z))
- {
- SetJDType(JDLineType.lineoff);
- }
- if (Input.GetKeyDown(KeyCode.X))
- {
- SetJDType(JDLineType.lineon_JDJuan);
- }
- if (Input.GetKeyDown(KeyCode.C))
- {
- SetJDType(JDLineType.lineon_NoJDJuan);
- }
- SetJDAngle(Input.GetAxis("Horizontal"));
- SetJDDirectionAngle(Input.GetAxis("Vertical"));
- }
- /// <summary>
- /// 设置胶带类型
- /// </summary>
- /// <param name="type"></param>
- public void SetJDType(JDLineType type)
- {
- foreach (var item in controllers)
- {
- item.SetJDLineType(type);
- }
- }
- /// <summary>
- /// 设置胶带缠绕角度
- /// </summary>
- /// <param name="delta"></param>
- public void SetJDAngle(float delta)
- {
- foreach (var item in controllers)
- {
- //可直接设置目标角度
- item.SetJDValue((item.value + delta));
- }
- }
- /// <summary>
- /// 伸出部分旋转角度
- /// </summary>
- /// <param name="delta"></param>
- public void SetJDDirectionAngle(float delta)
- {
- foreach (var item in controllers)
- {
- item.SetJDDirectionAngle((item.backAngle + delta));
- }
- }
- }
|