- 博客(48)
- 收藏
- 关注
原创 创建和获取桌面文档
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
211
原创 修改物体材质状态及颜色
foreach (Transform child in GetComponentsInChildren<Transform>(true)) { if (child.gameObject.GetComponent<Renderer>() != null) { if (child.gameObject.GetComponent<Renderer>().materials != n.
2022-03-18 15:50:51
364
原创 text空格换行
// "\u3000"空格 "\n"换行 text.text=text.text+ "\u3000"+_name; text.text=text.text+ "\n" + _name;
2021-01-05 11:31:44
240
原创 改变材质,改变材质颜色,改变材质透明状态
两个代码,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
584
1
原创 button监听
//监听按钮事件 GetComponent<Button>().onClick.AddListener(() => {/*事件*/ OnClickShot(); });
2019-12-09 15:55:12
182
原创 物体出现在目标物体的某个方向
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
144
原创 物体旋转到指定角度
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
906
原创 延时执行事件
private void OnTriggerEnter(Collider other) { if (other.gameObject.name == "Sphere") { Invoke("Load", 2);//延迟2秒物体消失 } } void Load() { this.g...
2019-03-29 17:35:54
425
原创 HTCVIVE手柄振动
using System;using System.Collections;using System.Collections.Generic;using UnityEngine;/// <summary>/// 手柄控制器脚本/// </summary>///public enum HandleControllerShakeType{ Defu...
2019-03-29 14:57:26
311
原创 htcvive手柄控制器
using System.Collections;using System.Collections.Generic;using UnityEngine;public class ShouBingKongZhiQi : MonoBehaviour { SteamVR_TrackedObject trackdeObject; //控制器 p...
2019-03-29 14:55:36
355
原创 手柄移动速度检测
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
730
原创 物体朝向某一个点移动
在update里面运行float step = speed * Time.deltaTime; //物体朝向木一个点移动 gameObject.transform.localPosition = Vector3.MoveTowards(gameObject.transform.localPosition, new Vector3(149....
2019-03-06 09:42:01
1123
原创 移动震动
using System.Collections;using System.Collections.Generic;using UnityEngine;public class YiDongZhenDong : MonoBehaviour { public Transform Trans_Move; //判断的物...
2019-03-06 09:34:34
195
原创 给物体添加摄像机
1 创建一个新的摄像机挂在物体上2.创建一个RenderTexture 挂在摄像机上3.创建一个UI RAW Image图片,将RenderTexture贴图放上去完成
2019-02-19 17:25:02
219
1
原创 材质球图片的运动
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
217
原创 开门
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
171
原创 按键短按长按
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
1413
原创 判断物体自身位置是否发生变化,是,手柄震动
using System.Collections;using System.Collections.Generic;using UnityEngine;public class YiDongZhenDong : MonoBehaviour { public Transform Trans_Move; //判...
2019-01-09 17:41:43
1090
原创 物体朝向某一个物体
void Update() { if (Eye != null) { this.transform.LookAt(Eye.transform); this.transform.Translate(Vector3.forward * Time.deltaTime * Speed); } ...
2019-01-03 11:14:16
443
原创 协程
private void Update() { if (i == true) { i = false; //等待三秒跳转铝包带 StartCoroutine(WaitEvent(3.0f)); // 括号中的数字就是等待的时间,按秒算 } ...
2018-12-21 10:37:59
140
原创 手柄震动
using System;using System.Collections;using System.Collections.Generic;using UnityEngine;/// <summary>/// 手柄控制器脚本/// </summary>/// public enum HandleControllerShakeType{ Defu...
2018-11-30 16:19:23
966
1
原创 头盔检测手柄距离显示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
311
原创 物体自身旋转
void Update () { if (LoGo != null) {//物体以世界坐标自身旋转 LoGo.transform.Rotate(LoGo.transform.up * Time.deltaTime * Speed); } }void Update () { if (LoGo ...
2018-10-15 09:11:18
509
原创 两点间生成直线
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
1326
1
原创 调用某物体的子物体和子物体孙物体
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
262
原创 子物体的控制
//子物体的隐藏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
277
原创 用枚举与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
184
原创 音效的管理和调用
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
196
原创 判断当前音效是否播放完毕
public class ZhuaZuoYePiao : MonoBehaviour { public bool IsOnce = true; public GameObject daimaoren; public GameObject zuoyepiao; void OnTriggerEnter(Collider other) { ...
2018-05-08 17:36:48
9605
1
原创 抓取代码
public class ZhuaZuoYePiao : MonoBehaviour { public bool IsOnce = true; public GameObject daimaoren; public GameObject zuoyepiao; void OnTriggerEnter(Collider other) { ...
2018-05-08 17:35:06
910
原创 触碰检测
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
331
原创 动画插入事件脚本
using System.Collections;using System.Collections.Generic;using UnityEngine;/// <summary>/// 移动动画事件/// </summary>public class MoveScript : MonoBehaviour { public GameObject BiaoGan; ...
2018-04-27 18:05:21
240
原创 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
608
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人