Tips

  • 按下回车后取消焦点:

    Notify当前控件,

    Method中关联RemoveFocus方法

  • 在代码中处理动画:

    代码:public TweenScale myTween;

    关联:关联改动画所在的gameobject。

  • 代码处理perfab:

    代码: public GameObject something;

    关联:关联指定的prefab。

  • 保持该类不被摧毁:DontDestroyOnLoad(this.gameObject);

    放在Awake(){}

  • 有动画的界面从无到有,先设置gameObject.SetActive(true);然后播放动画

    有动画的界面从有到无,先播放动画,延迟设置gameObject.SetActive(false);示例注解:

  • 启用/禁用按钮

    void DisableButton()

    {

    saleButton.SetState(UIButtonColor.State.Disabled, true);

    saleButton.GetComponent<Collider>().enabled = false;

    }

    void EnableButton()

    {

    saleButton.SetState(UIButtonColor.State.Normal, true);

    saleButton.GetComponent<Collider>().enabled = true;

    }

  • 控件获取
    • 获取一个页面控件需要声明维GameObject

  1. 用代码获取该控件

  2. 初始状态设置为false;

       

  • 动画获取
    • 声明动画

  1. 获取动画,该脚本绑定在包含动画的物体上

       

  • Random.Range(min : float, max : float)

    取值范围前后都包含

       

  • //Assets路径"Application.dataPath"

    string filepath = Application.dataPath + @"/my.xml";

       

  • Scale VS widthheight

    scale缩放,会改变本身及子物体

    Widthheight只会改变本身

       

  • System.Drawing.dll位置:C:Program FilesUnityEditorDataMonolibmono2.0System.Drawing.dll

   

  • File.WriteAllBytes(Application.dataPath + "/shexiang/" + Time.time + ".jpg", byt);

    保存文件

       

  • 点击空白地方?不需要内容

    按照button常规做法,设置Sprite为一个半透明的图片,设置透明度为1~2。

    透明度为0会不能点击。

       

  • Unable to list target platforms. Please make sure the android sdk path is correct. See the Console for more details.

    原因:Unity和最新的安卓sdk兼容有问题。需要更新还原安卓sdk的tool

    网址:https://developer.android.com/studio/index.html#tos-header 下载tool替换掉原来的

       

  • RequireComponent: A脚本加上[RequireComponent (typeof (B))],则为GO添加A的时候,会自动添加B,避免组装错吴.A依赖B存在.

       

原文地址:https://www.cnblogs.com/workhai/p/7521991.html