随笔分类 - Unity3D
摘要:transform.position = Vector3.Lerp(start.transform.position, end.transform.position, Mathf.SmoothStep(0f, 1f, Mathf.PingPong(Time.time / 3f, 1f)));
阅读全文
摘要:public GameObject InstanceGameobject(string _path, Transform _parent) { GameObject obj = Resources.Load(_path, typeof(GameObject)) as GameObject; GameObject go = Instantiate(obj)...
阅读全文
摘要:1:虚拟端发布出来要带着配置文件。 2:控制端也应该带着配置文件,将虚拟端整体放入控制端的_Data文件夹下。 3:注意文件名只能以英文命名。 //“控制端调用虚拟端”脚本截图 4:发布后,文件放置如下: //虚拟端全部放在控制端的Boiling_Data文件夹中,如下图所示:
阅读全文
摘要:Mould.transform.localPosition = new Vector3(Mathf.MoveTowards(Mould.transform.localPosition.x, -30f, Time.deltaTime * 2f), Mould.transform.localPosition.y, Mould.transform.localPosition.z);
阅读全文
摘要:using UnityEngine; using System.Collections; using UnityEngine.UI; public class DirectionMove : MonoBehaviour { public GameObject WestMoveTog;//西移 public GameObject EastMoveTog;//东移 pub...
阅读全文
摘要:单例模式(也叫单件模式)的作用就是保证在整个应用程序的生命周期中, 任何一个时刻,单例类的实例都只存在一个(当然也可以不存在)。 单例模式脚本,非静态方法需要挂载,否则会报空; 脚本需挂载
阅读全文
摘要:using UnityEngine; using System.Collections; public class ChangeMatericals : MonoBehaviour { public Material IniMaterical;// 替换前材质(原材质) public Material ChangeMaterical;//替换后的材质(半透明材质) p...
阅读全文
摘要:共同点: 发生碰撞的两个物体应满足的条件: NO1:两物体都应该有碰撞体 NO2:其中一个带刚体; NO3:检测触发信息的脚本需绑定在带刚体的物体上 不同点: 2D碰撞检测加2D碰撞体和2D刚体; 3D碰撞检测加3D碰撞体和3D刚体; 3D碰撞检测: 1.MonoBehaviour.OnCollis
阅读全文
摘要://添加一个圆柱体 //添加多个Cube //切记:脚本不能绑定在圆柱体上,会因为不断调用自身而造成死循环。
阅读全文
摘要:public Image BgImage; //从Inspector的文件夹中获取图片 BgImage.sprite = Resources.Load("Pic02/Basic RecogniseWinPic/" + message, typeof(Sprite)) as Sprite;
阅读全文
摘要:1、MonoBehaviour.Update 更新 当MonoBehaviour启用时,其Update在每一帧被调用。 2、MonoBehaviour.FixedUpdate 固定更新 当MonoBehaviour启用时,其 FixedUpdate在每一帧被调用。 处理Rigidbody时,需要用F
阅读全文
摘要://将脚本绑定在需要被限定范围的物体上 using UnityEngine; using System.Collections; public class ControlLimited : MonoBehaviour { float dis; //移动的最大距离 [SerializeField] private float MoveMaxDistance = 50;//最大拖...
阅读全文
摘要:MoveTowards: void Update () MoveTowards: void Update () void Update () { float step = speed * Time.deltaTime; gameObject.transform.localPosition = Vec
阅读全文
摘要://ViewChanged脚本需绑定在主相机上 using UnityEngine;using System.Collections;using UnityEngine.UI;using UnityEngine.EventSystems; public class ViewChanged : Mon
阅读全文
摘要:转自:http://blog.csdn.net/meegomeego/article/details/38439593 一、近距离查看游戏对象 在Hierarchy视图中选择游戏对象,然后在Scene视图中按快捷键“F”来近距离查看该游戏对象。 二、游戏对象不在主摄像头中? Hierarchy中双击
阅读全文
摘要:public GameObject obj; void OnCollisionEnter(Collision col) { //获取当前碰撞到的物体 obj=col.gameObject; }
阅读全文
摘要://脚本绑定在其父物体上(下落的物体 添加刚体)
阅读全文
摘要:using UnityEngine; using System.Collections; using UnityEngine.EventSystems; public class EventTriggerListener : UnityEngine.EventSystems.EventTrigger { public delegate void VoidDelegate(GameOb...
阅读全文
摘要:注:Paotai为大炮,所挂载的脚本为Move. using UnityEngine;using System.Collections; public class Move : MonoBehaviour{ public Transform TargetMove;//作为炮口的瞄准目标 privat
阅读全文

浙公网安备 33010602011771号