zoukankan      html  css  js  c++  java
  • unity inspector 自动装载Commont和Prefab属性

    在使用unity的过程中,经常遇到这样的问题:每次都需要手动为序列化属性拖拽赋值。像这样:

    试着找了找,真的找到了一份代码,但是缺少自动装载Prefab的功能。之后我花了点时间添加这个功能。

    使用方法:

     1   [Autohook]
     2     public Button SendBtn;
     3     [Autohook]
     4     public Button StartBtn;
     5     [Autohook]
     6     public Button LeaveBtn;
     7     [Autohook]
     8     public Text RoomDateText;
     9     [Autohook]
    10     public ScrollRect PlayerList;
    11 
    12     [Autohook]
    13     public GameObject PlayerBarPrefab;
    14     [Autohook]
    15     public GameObject RoomBarPrefab;

    Autohook会自动在子节点中寻找对应的名称。

    如果要自动赋值Prefab,类型必须为GameObject,并且有Prefab后缀。

    例如: [Autohook] public GameObject RoomBarPrefab; 

    这一句会在Prefabs的目录下寻找RoomBar这个prefab,并赋值到此。

    代码包:

    链接: https://pan.baidu.com/s/1ITUicf2pbt9EoqWhgoCojg 提取码: hwvs

  • 相关阅读:
    常用的20个正则表达式
    关于position:fixed;的居中问题
    Html table 合并单元格
    JS异步加载的三种方式
    DOM事件代码小结
    用js写一个回车键盘事件
    JavaScript 常用方法总结
    可拖拽进度条
    js数组拍平
    js验证码倒计时
  • 原文地址:https://www.cnblogs.com/backinfile/p/12359861.html
Copyright © 2011-2022 走看看