Scripts
weixin_39562523
这个作者很懒,什么都没留下…
展开
-
创建和获取桌面文档
using System.Collections;using System.Collections.Generic;using UnityEngine;using System;public class ceshi : MonoBehaviour{ string ss = "你是谁"; // Start is called before the first frame update void Start() { //创建桌面文档 .原创 2022-03-30 16:55:40 · 157 阅读 · 0 评论 -
text空格换行
// "\u3000"空格 "\n"换行 text.text=text.text+ "\u3000"+_name; text.text=text.text+ "\n" + _name;原创 2021-01-05 11:31:44 · 190 阅读 · 0 评论 -
改变材质,改变材质颜色,改变材质透明状态
两个代码,1。材质原代码,放入项目。2.调用方法,挂在物体上01:::using System.Collections;using System.Collections.Generic;using UnityEngine;public class MaterialModify : MonoBehaviour{ public enum RenderingMode...原创 2020-03-18 09:23:05 · 495 阅读 · 0 评论 -
button监听
//监听按钮事件 GetComponent<Button>().onClick.AddListener(() => {/*事件*/ OnClickShot(); });原创 2019-12-09 15:55:12 · 124 阅读 · 0 评论 -
判断当前音效是否播放完毕
public class ZhuaZuoYePiao : MonoBehaviour { public bool IsOnce = true; public GameObject daimaoren; public GameObject zuoyepiao; void OnTriggerEnter(Collider other) { ...原创 2018-05-08 17:36:48 · 9410 阅读 · 1 评论 -
物体朝向某一个点移动
在update里面运行float step = speed * Time.deltaTime; //物体朝向木一个点移动 gameObject.transform.localPosition = Vector3.MoveTowards(gameObject.transform.localPosition, new Vector3(149....原创 2019-03-06 09:42:01 · 1030 阅读 · 0 评论 -
手柄移动速度检测
using System.Collections;using System.Collections.Generic;using UnityEngine;public class ShouBingSuDuJianCe : MonoBehaviour { public Vector3 LastVec; float time = 0; public float...原创 2019-03-29 14:53:48 · 592 阅读 · 0 评论 -
htcvive手柄控制器
using System.Collections;using System.Collections.Generic;using UnityEngine;public class ShouBingKongZhiQi : MonoBehaviour { SteamVR_TrackedObject trackdeObject; //控制器 p...原创 2019-03-29 14:55:36 · 284 阅读 · 0 评论 -
HTCVIVE手柄振动
using System;using System.Collections;using System.Collections.Generic;using UnityEngine;/// <summary>/// 手柄控制器脚本/// </summary>///public enum HandleControllerShakeType{ Defu...原创 2019-03-29 14:57:26 · 250 阅读 · 0 评论 -
延时执行事件
private void OnTriggerEnter(Collider other) { if (other.gameObject.name == "Sphere") { Invoke("Load", 2);//延迟2秒物体消失 } } void Load() { this.g...原创 2019-03-29 17:35:54 · 390 阅读 · 0 评论 -
物体旋转到指定角度
public float Speed; Quaternion targetAngels; public GameObject gam; // Use this for initialization void Start () { targetAngels = Quaternion.Euler(90, 0, 0); } ...原创 2019-04-04 14:42:26 · 856 阅读 · 0 评论 -
物体出现在目标物体的某个方向
this.gameObject.transform.LookAt(VR_Camera.transform); this.gameObject.transform.position = VR_Camera.transform.position + VR_Camera.transform.forward * L; this.gameObject.tran...原创 2019-04-04 16:04:00 · 116 阅读 · 0 评论 -
移动震动
using System.Collections;using System.Collections.Generic;using UnityEngine;public class YiDongZhenDong : MonoBehaviour { public Transform Trans_Move; //判断的物...原创 2019-03-06 09:34:34 · 139 阅读 · 0 评论 -
材质球图片的运动
using System.Collections;using System.Collections.Generic;using UnityEngine;public class PaTiJianTou : MonoBehaviour { [Range(0f, 1f)] public float speed_x = 0; [Range(0f, 1f)] ...原创 2019-02-15 14:07:47 · 173 阅读 · 0 评论 -
调用某物体的子物体和子物体孙物体
public class UI_RingtButton : MonoBehaviour { public GameObject ZheZhao; public GameObject Right_Canvas; public void JiChu_Button() { foreach(Transform child in Right_C...原创 2018-08-24 12:52:33 · 234 阅读 · 0 评论 -
子物体的控制
//子物体的隐藏foreach(Transform child in this.GetComponent<Transform>()){if (child.name == "要隐藏的名字"){ if (child.gameObject.activeSelf == false){child.gameObject.SetActive(false);}else...原创 2018-08-14 08:54:55 · 221 阅读 · 0 评论 -
用枚举与switch...case...将事件的有序进行
using System.Collections;using System.Collections.Generic;using UnityEngine;public enum Daozhacaozuo{ Default,}public class DaoZhaCaoZuo : MonoBehaviour { public static DaoZha...原创 2018-05-08 17:50:46 · 152 阅读 · 0 评论 -
音效的管理和调用
using System.Collections;using System.Collections.Generic;using UnityEngine;public enum AudioClipType{ zhuoqian, zhuazuoyepiao, duzuoyepiao, qianzikaimen}public class SoundController : Mon...原创 2018-05-08 17:40:23 · 163 阅读 · 0 评论 -
抓取代码
public class ZhuaZuoYePiao : MonoBehaviour { public bool IsOnce = true; public GameObject daimaoren; public GameObject zuoyepiao; void OnTriggerEnter(Collider other) { ...原创 2018-05-08 17:35:06 · 860 阅读 · 0 评论 -
触碰检测
using System.Collections;using System.Collections.Generic;using UnityEngine;public class ShuiHuScripts : MonoBehaviour { public ModelXianShi xianShi; public GameObject shuihuTS; void OnTrigge...原创 2018-04-27 18:07:15 · 295 阅读 · 0 评论 -
动画插入事件脚本
using System.Collections;using System.Collections.Generic;using UnityEngine;/// <summary>/// 移动动画事件/// </summary>public class MoveScript : MonoBehaviour { public GameObject BiaoGan; ...原创 2018-04-27 18:05:21 · 209 阅读 · 0 评论 -
vr头盔检测碰撞
using System.Collections;using System.Collections.Generic;using UnityEngine;public class EyeColliderScript : MonoBehaviour { public GameObject qishi_TS; public GameObject zuoyepiao_TS; public...原创 2018-04-27 18:03:51 · 565 阅读 · 0 评论 -
两点间生成直线
using System.Collections;using System.Collections.Generic;using UnityEngine;public class LiangDianJianDeLianXian : MonoBehaviour { public GameObject WuTi01; public GameObject WuTi02;...原创 2018-09-12 18:29:25 · 1233 阅读 · 1 评论 -
物体自身旋转
void Update () { if (LoGo != null) {//物体以世界坐标自身旋转 LoGo.transform.Rotate(LoGo.transform.up * Time.deltaTime * Speed); } }void Update () { if (LoGo ...原创 2018-10-15 09:11:18 · 457 阅读 · 0 评论 -
头盔检测手柄距离显示ui
using System.Collections;using System.Collections.Generic;using UnityEngine;public class ShouBingUIJianCe : MonoBehaviour { public Transform Head;//头 public Transform Hand;//手 publi...原创 2018-11-06 11:24:37 · 283 阅读 · 0 评论 -
开门
using System.Collections;using System.Collections.Generic;using UnityEngine;public class GuiMen : MonoBehaviour { public GameObject LeftShoubing; private Vector3 GuiMenMuBiao;...原创 2019-01-22 18:34:04 · 133 阅读 · 0 评论 -
按键短按长按
using System.Collections;using System.Collections.Generic;using UnityEngine;public class ShouBingMuLu : MonoBehaviour{ public GameObject MuLu; public GameObject MuLu02; public floa...原创 2019-01-22 18:26:21 · 1343 阅读 · 0 评论 -
判断物体自身位置是否发生变化,是,手柄震动
using System.Collections;using System.Collections.Generic;using UnityEngine;public class YiDongZhenDong : MonoBehaviour { public Transform Trans_Move; //判...原创 2019-01-09 17:41:43 · 952 阅读 · 0 评论 -
物体朝向某一个物体
void Update() { if (Eye != null) { this.transform.LookAt(Eye.transform); this.transform.Translate(Vector3.forward * Time.deltaTime * Speed); } ...原创 2019-01-03 11:14:16 · 408 阅读 · 0 评论 -
随机
随机方法名就是Random.Range()原创 2018-12-22 14:59:31 · 108 阅读 · 0 评论 -
协程
private void Update() { if (i == true) { i = false; //等待三秒跳转铝包带 StartCoroutine(WaitEvent(3.0f)); // 括号中的数字就是等待的时间,按秒算 } ...原创 2018-12-21 10:37:59 · 103 阅读 · 0 评论 -
手柄震动
using System;using System.Collections;using System.Collections.Generic;using UnityEngine;/// <summary>/// 手柄控制器脚本/// </summary>/// public enum HandleControllerShakeType{ Defu...原创 2018-11-30 16:19:23 · 861 阅读 · 1 评论 -
数组管理隐藏
using System.Collections;using System.Collections.Generic;using UnityEngine;public class ModelXianShi : MonoBehaviour { public GameObject[] Modle01; //第一组出现消失模型数组 //每次执行一次,而且先执行 private v...原创 2018-04-27 15:31:48 · 281 阅读 · 0 评论