unity添加GM命令按钮

unity添加GM命令按钮,第1张

using com.game.vo

using Com.Game.Module.Chat

using System.Collections

using System.Collections.Generic

using UnityEditor

using UnityEngine

public class GM : MonoBehaviour {

    //[MenuItem("GM/super_long")]

    //static void ShowWindow()

    //{

    //    ChatMode.Instance.SendPublicMsg((byte)ChatType.World, "#super_long")

    //}

    [MenuItem("GM/1")]

    static void ShowWindow1()

    {

        ChatMode.Instance.SendPublicMsg((byte)ChatType.World, "#gold 10000000")

        ChatMode.Instance.SendPublicMsg((byte)ChatType.World, "#diam 10000000")

        ChatMode.Instance.SendPublicMsg((byte)ChatType.World, "#lvl 500")

        for (int i = 1i <= 10i++)

        {

            int id = 100009090 + i * 1000000 + MeVo.instance.job * 100000

            ChatMode.Instance.SendPublicMsg((byte)ChatType.World, "#goods " + id)

        }

        ChatMode.Instance.SendPublicMsg((byte)ChatType.World, "#tk 100007")

        ChatMode.Instance.SendPublicMsg((byte)ChatType.World, "#mv 10000")

        //ChatMode.Instance.SendPublicMsg((byte)ChatType.World, "#chapter 6")

        //ChatMode.Instance.SendPublicMsg((byte)ChatType.World, "#kick")

}

[MenuItem("GM/2")]

static void ShowWindow2()

{

    ChatMode.Instance.SendPublicMsg((byte)ChatType.World, "#sc_start")

    }

[MenuItem("GM/3")]

static void ShowWindow3()

{

ChatMode.Instance.SendPublicMsg((byte)ChatType.World, "#bubble_boss")

}

}

可以的。

首先新建Canvas对象,新建子对象Image/Text,当然还有Button,点击Button,在右边面板修改按钮颜色(样式),下面ButtonScript里面修改按钮处于不同状态(正常/有鼠标经过/禁用/按下)的颜色。Button有一个子对象Text,就是按钮上的文字。修改文字大小内容等。回到Button对象,在Inspector面板中,下面有一个OnClick小面板,点击加号添加一个。然后添加按钮要处理的对象。比如添加了DirectionalLight.这个对象有很多公共方法供调用。在GameObject系列下面有一个SetActive,作为演示,添加这个方法。取消Bool参数的勾选。

添加好后,每次按下这个按钮,DirectionalLight都“不亮了”,同样的,我们也可以用按钮来作为动画的触发器。把带有Animator的对象拖上去,然后设置Function为SetTrigger(string),再输入Trigger变量的名称。把Controller对象拖上去,然后在Function里面就可以找到这个脚本了,选择自己写的SetLight函数就可以了。这样就使按钮运行了自己写的代码。


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/bake/11709043.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-18
下一篇2023-05-18

发表评论

登录后才能评论

评论列表(0条)

    保存