摘要: 1,同一个脚本挂载在不同的对象上 1 public class Lesson1 : MonoBehaviour 2 { 3 // Start is called before the first frame update 4 5 6 //public GameObject Obj1; 7 publi 阅读全文
posted @ 2021-07-25 19:08 青梨 阅读(243) 评论(0) 推荐(0) 编辑
摘要: 1 void Start() 2 { 3 //获取当前对象 4 GameObject l1 = this.gameObject; 5 6 //获取指定对象 7 GameObject l2 = GameObject.Find("ls1"); 8 print(l1); 9 10 } 阅读全文
posted @ 2021-07-25 18:32 青梨 阅读(177) 评论(0) 推荐(0) 编辑
摘要: 1 void Start() 2 { 3 //所有对象挂载了相同的脚本 4 5 Lesson1 t1 = this.GetComponent("Lesson1") as Lesson1; 6 print(t1); 7 8 Lesson1 t2 = this.GetComponent(typeof(L 阅读全文
posted @ 2021-07-25 18:31 青梨 阅读(272) 评论(0) 推荐(0) 编辑
摘要: 1,获取当前挂载的对象名称 void Start() { //获取当前挂载的对象名称 print(gameObject.name); } 2,当前对象失活激活 void Start() { //当前对象失活 this.enabled = false; //当前对象激活 this.enabled = 阅读全文
posted @ 2021-07-25 17:08 青梨 阅读(833) 评论(0) 推荐(0) 编辑
摘要: 1 using System.Collections; 2 using System.Collections.Generic; 3 using UnityEngine; 4 5 /// <summary> 6 /// 抽屉数据 池子一列容器 7 /// </summary> 8 public cla 阅读全文
posted @ 2020-10-10 00:18 青梨 阅读(200) 评论(0) 推荐(0) 编辑
摘要: 这是缓存池脚本 1 using System.Collections; 2 using System.Collections.Generic; 3 using UnityEngine; 4 5 //缓存池模块 6 public class PoolMgr : BaseManager<PoolMgr> 阅读全文
posted @ 2020-10-08 00:09 青梨 阅读(215) 评论(0) 推荐(0) 编辑
摘要: using System.Collections; using System.Collections.Generic; using UnityEngine; public class BaseManager<T> where T:new() { public static T instane; pu 阅读全文
posted @ 2020-09-13 23:57 青梨 阅读(197) 评论(0) 推荐(0) 编辑
摘要: 事件中心模式 1,事件中心 1 Private Dictionary<string,UnityAction<object>> eventDic = new Dictionary<string, UnityAction<object>> 2,添加事件监听 1 /// <summary> 2 /// 添 阅读全文
posted @ 2020-08-30 22:20 青梨 阅读(285) 评论(0) 推荐(0) 编辑
摘要: using System.Collections; using System.Collections.Generic; using UnityEngine; public class PoolMar : MonoBehaviour { // Start is called before the fi 阅读全文
posted @ 2020-07-11 11:40 青梨 阅读(180) 评论(0) 推荐(0) 编辑
摘要: 1,引用xml 2,定义一个字段存储XML的路径 3,通过读取路径XML中的数据进行显示 阅读全文
posted @ 2019-04-02 00:03 青梨 阅读(189) 评论(0) 推荐(0) 编辑