自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(67)
  • 收藏
  • 关注

原创 自动寻路知识点

using System.Collections;using System.Collections.Generic;using UnityEngine;using UnityEngine.AI;/**文件描述:*创始人:*创建时间:*修改时间:*版本:1.0*/public class Enemy : MonoBehaviour { public Transform[] waypoints; float timer = 0; float waitTime = 3f

2022-06-12 14:54:56 113 1

原创 导航知识点

using System.Collections;using System.Collections.Generic;using UnityEngine;using UnityEngine.AI;/**文件描述:*创始人:*创建时间:*修改时间:*版本:1.0*/public class Robot : MonoBehaviour { Animator an; NavMeshAgent agent; public Transform cube; void St

2022-06-12 14:40:41 119

原创 NGUI,地图放大缩小

using System.Collections;using System.Collections.Generic;using UnityEngine;/**文件描述:*创始人:*创建时间:*修改时间:*版本:1.0*/public class Minimap2 : MonoBehaviour { Camera minimapCamera; UIButton btn, btn2; void Start () { minimapCamera = Game

2022-06-10 12:22:58 567

原创 NGUI,选择性别男女

UIToggle toggle,toggle2; bool flag=false; void Start () { toggle = transform.GetChild(0).GetComponent(); toggle2 = transform.GetChild(1).GetComponent(); toggle.onChange.Add(new EventDelegate(this, "Chang"

2022-06-09 21:51:28 110

原创 NGUI,飘血

using System.Collections;using System.Collections.Generic;using UnityEngine;/**文件描述:*创始人:*创建时间:*修改时间:*版本:1.0*/public class Test5 : MonoBehaviour { GameObject go; HUDText ht; void Start () { go = GameObject.Find("GameObject");

2022-06-09 21:29:30 106

原创 NGUI,冷却效果

bool flag=false; void Start () { cool= transform.GetChild(2).transform.GetChild(0).GetComponent(); } void Update() { if (Input.GetKeyDown(KeyCode.A)&&flag==false) { flag = true; cool.

2022-06-09 16:48:42 75

原创 NGUI,背包拖拽,以及随机克隆图片知识点

using System.Collections;using System.Collections.Generic;using UnityEngine;/**文件描述:*创始人:*创建时间:*修改时间:*版本:1.0*/public class Knapsackltem : UIDragDropItem{ int count = 1; public UILabel numTxt;//预设体上面的文本 public void Add()//添加物品的数量方法 {

2022-06-09 11:14:56 120

原创 NGUI,聊天滚动框,UI TextList

UITextList list; void Start() { list = transform.GetChild(3).GetComponent(); } int i = 1; void Update() { if (Input.GetMouseButtonDown(0)) { list.Add(i.ToString()); i++;

2022-06-08 16:25:39 102

原创 NGUI,下拉列表Popup List知识点

using System.Collections;using System.Collections.Generic;using UnityEngine;/**文件描述:*创始人:*创建时间:*修改时间:*版本:1.0*/public class Test3 : MonoBehaviour { UIPopupList pp; UITextList list; void Start () { list = transform.GetChild(0).tra

2022-06-08 11:53:36 185

原创 NGUI进度条知识点

using System.Collections;using System.Collections.Generic;using UnityEngine;/**文件描述:*创始人:*创建时间:*修改时间:*版本:1.0*/public class Test2 : MonoBehaviour { UILabel per; UISlider slider; float timer = 0, value = 0; void Start () { per

2022-06-08 11:24:15 106

原创 NGUI按钮知识点

using System.Collections;using System.Collections.Generic;using UnityEngine;/**文件描述:*创始人:*创建时间:*修改时间:*版本:1.0*/public class Test : MonoBehaviour { UIButton btn; UIInput nameTxt; void Start () { btn = transform.GetChild(2).GetCompo

2022-06-08 11:05:00 93

原创 CS-GameResources知识点

public const string Player = "Player"; public const string Enemy2 = "DogPos"; public const string PlayerIdle = "Idle"; public const string PlayerFire = "Fire"; public const string PlayerMelee = "Melee"; public const string PlayerReload =

2022-06-05 14:48:45 122

原创 CS-AudioManager知识点

public static AudioManager au; AudioClip[] clips; AudioSource audios; void Start () { au = this; audios = GetComponent();//获取音频资源组件 clips = Resources.LoadAll("Audios");//获取所有音频 //ChooseCli...

2022-06-05 14:47:08 102

原创 CS-GameManager知识点

public static GameManager game; public int EnemyHP=1,PlayerHP=5,PlayerScore=0; public bool ReStart=false; GameObject Panel2; int number; Transform dogPos; GameObject dogPosS; Text text,textScore; Button btn; GameObject

2022-06-05 14:41:39 408

原创 CS-Enemy知识点

public enum EnemyState { Idle, Run, Attack, Death } EnemyState E = EnemyState.Idle; void Get(EnemyState E) { switch (E) { case EnemyState.Idle: an.Play(Game

2022-06-05 14:38:58 119

原创 CS-Player知识点

public enum PlayerState{ Idle, Fire, Melee, Reload}public class Player : MonoBehaviour { PlayerState P = PlayerState.Idle; void Get(PlayerState P) { switch (P) { case PlayerState.Idle:

2022-06-05 14:33:28 1705

原创 CS前后移动转向知识点

Vector3 dir = Vector3.zero; //通过键盘控制玩家移动 float h = Input.GetAxis("Horizontal"); float v = Input.GetAxis("Vertical"); if (Mathf.Abs(v) > 0 || Mathf.Abs(h) > 0)//判断人是否动了 绝对值h与v大于0 { //播放脚步声 Aud

2022-06-02 21:20:05 172

原创 点乘叉乘知识点

public Transform A; void Update () { float d= Vector3.Dot(transform.forward,A.position-transform.position); Vector3 a = Vector3.Cross(transform.forward,A.position-transform.position); if (d>=0&&a.y>0) ...

2022-05-30 15:29:47 82

原创 Math四元数知识点

//public Transform qiu; void Start () { //print(Mathf.Abs(-1));//绝对值 //print(Mathf.Ceil(3.5f));//取最接近上限的整数 4 //print(Mathf.Floor(3.5f));//取最接近下限的整数 3 //print(Mathf.Clamp(2,1,10));//范围限制是:1--10 默认是2 //print(Ma...

2022-05-30 11:51:20 107

原创 射击游戏知识点

public static bool isShow = false;//特效 public int enemyHp = 3;//敌人血量 public int playerHp = 10;//玩家血量 public static GameManager gm;//unity单例写法 void Start () { gm = this; }if (Input.GetMouseButtonDown(0)) { ...

2022-05-29 22:52:51 409

原创 饿汉,懒汉单例模式知识点

//饿汉单例模式public class EHan { //1、私有构造方法 private EHan() { } //2、创建私有静态对象 private static EHan e = new EHan(); //3、定义公共静态方法 public static EHan Get() { return e; }}//懒汉单例模式public class LanHan { //1、私有构造方法 ...

2022-05-29 22:39:58 64

原创 Invoke与InvokeRepeating知识点

//点击鼠标左键,3秒后克隆一个游戏对象 GameObject player; void Start () { player = Resources.Load<GameObject>("Prefabs/Player"); } void Update () { if (Input.GetMouseButtonDown(0)) { //Invoke("CreatePlayer",3f);/...

2022-05-29 22:22:49 216

原创 角色控制器组件知识点

CharacterController cc;//角色控制器组件:自身会有碰撞器和刚体 float speed=2f; void Start () { cc = GetComponent<CharacterController>();//获取角色控制组件 } void Update () { float h = Input.GetAxis("Horizontal"); float v = Input.GetAxis(...

2022-05-29 22:17:05 110

原创 判断距离知识点

float timer = 0.167f;//计时器 void FindPlayer() { if (zhiZhu!=null) { //玩家距离蜘蛛10米 if (Vector3.Distance(transform.position, zhiZhu.position) <= 10)//自身的位置距离敌人的位置 { //玩家距离蜘蛛5米,自动攻击敌人...

2022-05-29 21:57:55 70

原创 枚举与动画知识点

Unity游戏public enum PlayerState//枚举 { Idle, Walk, Run, Shoot } PlayerState ps = PlayerState.Idle;//默认状态void GetState(PlayerState p) { switch (p) { case PlayerState.Idle: ...

2022-05-29 21:51:40 155

原创 ref与out知识点

void Start () { //int a = 1, b = 2; //print("交换前 a=" + a + ",b=" + b); //Swap(ref a, ref b);//需要赋值 //print("交换后 a=" + a + ",b=" + b); int a,b; Swap(out a,out b);//不需要赋值 print("交换后 a=" + a + ",b=" + b...

2022-05-29 21:47:51 169

原创 摄像机跟随知识点

Transform player; Vector3 dir; void Start () { player = GameObject.FindWithTag("Player").transform; dir = transform.position - player.position;//朝向玩家的方向 } void Update () { transform.position = dir + player.position;/...

2022-05-29 18:30:42 64

原创 射线知识点

//Debug.DrawLine(transform.position, transform.position + transform.forward, Color.red);//绘制一条红色的射线 起点-终点//Debug.DrawRay(transform.position, transform.forward, Color.green);//绘制一条绿色的射线 起点-方向/从原点发射一条射线 //原点 //自身坐标 ...

2022-05-29 15:55:39 110

原创 动态加载与音频知识点

GameObject qiu; AudioSource audios;//音频 AudioClip clip; //Rigidbody ri; void Start () { qiu = Resources.Load<GameObject>("Prefabs/qiu");//动态加载游戏对象(预设体) /*audios = qiu.gameObject.AddComponent<AudioSource&...

2022-05-29 15:51:51 125

原创 消防知识点

void OnTriggerEnter(Collider other)//碰撞到立方体墙 { if (other.CompareTag("Wall")) { GameManager.isStop = false;//停止 //跳车 transform.position = new Vector3(transform.position.x - 6, transform.position.y, t...

2022-05-27 22:43:15 64

原创 石头剪刀布知识点

public Image[] imgs; Image coumputerImg, playerImg; Text result; Button jianDao, shiTou, bu; void Start() { coumputerImg = transform.GetChild(2).GetComponent<Image>();//电脑 playerImg = transform.GetChild(3).GetComp...

2022-05-26 23:42:26 56

原创 坦克大战知识点

子弹类 float speed = 3f; Transform pos; void Start () { pos=GameObject.Find("aa").transform; } void Update () { transform.Translate( Vector3.forward * Time.deltaTime * speed); } void OnTriggerEnter(Collider oth...

2022-05-18 13:19:09 142

原创 飞机大战知识点

Time.timeScale = 0;//游戏暂停Time.timeScale = 1;//游戏重新开始Destroy(other.gameObject);//碰撞的销毁Destroy(this.gameObject,0.1f);//自己销毁 GameManager.playerScore += 1;//调用积分加1r.velocity = Vector3.back * 3f;//velocity:速度r.angularVelocity = Random.insideUni...

2022-05-17 16:11:37 258

原创 物理引擎知识点

//刚体控制物体移动Rigidbody r;void Start () {r = GetComponent<Rigidbody>();//获取刚体对象}void Update () { //用键盘控制物体移动 float x = Input.GetAxis("Horizontal");//GetAxis:轴 float y = Input.GetAxis("Vertical"); Vector3 pos = new Vector...

2022-05-17 16:07:40 83

原创 常用核心类知识点

//移动 //属性 transform.position = new Vector3(2, 0, 0); transform.position = Vector3.right * 2; //方法 transform.Translate(2, 0, 2); transform.Translate(new Vector3(2, 2, 2)); transform.Translate(V...

2022-05-17 16:04:03 212

原创 导航系统。

using System.Collections;using System.Collections.Generic;using UnityEngine;using UnityEngine.AI;/**文件描述:*创始人:*创建时间:*修改时间:*版本:1.0*/public class Robot : MonoBehaviour { Animator an; NavMeshAgent agent; public Transform cube; void...

2022-05-03 11:50:52 47

原创 JSON解析与存储

void Start() { PlayerCun Cun = new PlayerCun(); Cun.Name = "黄六"; Cun.Password = "123"; Get5(Cun); } void Get () { // Application.dataPath:Asstes string path = Application.dataPath+ "/JSON/Player.t...

2022-04-07 10:08:31 145

原创 UI-Image冷却与掉血

Image Xue,gongji1, gongji2, gongji3; bool f = false; bool f2 = false; bool f3 = false;void Start(){Xue = GameObject.Find("Canvas").transform.GetChild(3).GetComponent<Image>(); gongji1 = GameObject.Find("Canvas").transform.GetC...

2022-03-22 09:39:33 41

原创 Unity背包

int count = 1; public UILabel numTxt;//预设体上面的文本 public void Add()//添加物品的数量方法 { count++;//一直累加 numTxt.text = count.ToString();//赋值给文本 } protected override void OnDragDropRelease(GameObject surface) { base.On...

2022-03-17 21:44:45 3183

原创 unity人物转方向

float h = Input.GetAxis("Horizontal"); float v = Input.GetAxis("Vertical"); Vector3 pos = Vector3.zero; //按下键盘使玩家走动/. if (h != 0 || v != 0) { //转方向 if (h < ...

2022-03-14 14:04:51 5877

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除