博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Pvr_ControllerModuleInit代码分析
阅读量:5875 次
发布时间:2019-06-19

本文共 3196 字,大约阅读时间需要 10 分钟。

1 using System; 2 using UnityEngine; 3 using System.Collections; 4 using Pvr_UnitySDKAPI; 5  6  7 namespace Pvr_UnitySDKAPI 8 { 9     public enum ControllerVariety//定义枚举类型的控制种类变量10     {11         Controller0,12         Controller1,13     }14 }   15 16 public class Pvr_ControllerModuleInit : MonoBehaviour17 {18     19     public ControllerVariety Variety;20     public bool IsCustomModel = false;//是否是定制的模型21     [SerializeField]22     private GameObject dot;//游戏对象-点23     [SerializeField]24     private GameObject rayLine;//游戏对象射线25     [SerializeField]26     private GameObject controller;//邮箱对象控制器27     private int controllerDof = -1;28     private int mainHand = 0;29     private bool moduleState = true; //模块状态30 31     void Awake()32     {33         Pvr_ControllerManager.PvrServiceStartSuccessEvent += ServiceStartSuccess;34         Pvr_ControllerManager.SetControllerAbilityEvent += CheckControllerStateOfAbility;35         Pvr_ControllerManager.ControllerStatusChangeEvent += CheckControllerStateForGoblin;36     }37     void OnDestroy()38     {39         Pvr_ControllerManager.PvrServiceStartSuccessEvent -= ServiceStartSuccess;40         Pvr_ControllerManager.SetControllerAbilityEvent -= CheckControllerStateOfAbility;41         Pvr_ControllerManager.ControllerStatusChangeEvent -= CheckControllerStateForGoblin;42     }43 44     private void ServiceStartSuccess()45     {46         mainHand = Controller.UPvr_GetMainHandNess();//设置主手柄47         if (Variety == ControllerVariety.Controller0)48         {49             StartCoroutine(ShowAndHideRay(mainHand == 0 && Pvr_ControllerManager.controllerlink.controller0Connected));50             51         }52         if (Variety == ControllerVariety.Controller1)53         {54             StartCoroutine(ShowAndHideRay(mainHand == 1 && Pvr_ControllerManager.controllerlink.controller1Connected));55         }56     }57 58     private void CheckControllerStateForGoblin(string state)59     {60         if (Variety == ControllerVariety.Controller0)61         {62             StartCoroutine(ShowAndHideRay(Convert.ToBoolean(Convert.ToInt16(state))));63         }64     }65 66     private void CheckControllerStateOfAbility(string data)67     {68         mainHand = Controller.UPvr_GetMainHandNess();69         if (Variety == ControllerVariety.Controller0)70         {71             StartCoroutine(ShowAndHideRay(mainHand == 0 && Pvr_ControllerManager.controllerlink.controller0Connected));72 73         }74         if (Variety == ControllerVariety.Controller1)75         {76             StartCoroutine(ShowAndHideRay(mainHand == 1 && Pvr_ControllerManager.controllerlink.controller1Connected));77         }78     }79     80     private IEnumerator ShowAndHideRay(bool state)81     {82         yield return null;83         yield return null;84         if (moduleState)85         {86             dot.SetActive(state);87             rayLine.SetActive(state);88         }89     }90 91     public void ForceHideOrShow(bool state)92     {93         dot.SetActive(state);94         rayLine.SetActive(state);95         controller.SetActive(state);96         moduleState = state;97     }98 }

 

转载于:https://www.cnblogs.com/krystalstar/p/9643789.html

你可能感兴趣的文章
全国各地电信DNS服务器地址
查看>>
jquery 拖动改变div 容器大小
查看>>
解决并清除SQL被注入<script>恶意病毒代码的语句
查看>>
Linux资源控制-CPU和内存
查看>>
对makefile中 $? 的理解
查看>>
HTML5 WebStorage
查看>>
TclError: no display name and no $DISPLAY environment variable
查看>>
Unity的AssetDatabase路径格式
查看>>
jrebel使用
查看>>
JavaScript prototype 属性
查看>>
RedHat系统的Yum安装
查看>>
IntelliJ IDEA CE Maven 使用方法
查看>>
WCF开发的几个频骤
查看>>
php提示Fatal error: Call to undefined function imagecreate()
查看>>
ubuntu-基本命令篇-10-文件管理
查看>>
单点登录(SSO)—简介
查看>>
Spring构造方法注入类型歧义
查看>>
为什么 Java 不提供无符号类型呢?
查看>>
使用iTextSharp在Asp.Net中操作PDF系列文章 目录
查看>>
《Java 2 图形设计卷Ⅱ- SWING》第6章 实用工具
查看>>