编写Unity工具类

脚本功能设定:游戏GM工具(根据物品ID、数量向服务器发送信息,获取本地所需物品道具)


using UnityEngine;
using System.Collections;
using UnityEditor;
using System.Collections.Generic;
using System.Linq;
using Tianyu;

public class GMUtil : EditorWindow
{
    string[] toolbarStr = new string[] { "标准添加道具", "搜索添加道具" };//标题栏名称
    int toolbarOption = 0;//默认显示也签ID

    List<ItemNodeState> allItemNodeList;
    List<HeroNode> allHeroNodeList;

    bool isAddedListener = false;
    bool isRemovedListener = false;

    //注册消息监听
    private void OnEnable()
    {
        MessageMediator.AddListener<CReadPacket>(MessageMediatType.gm_add_player_data_ret, ReceiveServGMMsg);
    }
    
    //销毁消息监听
    private void OnDisable()
    {
        MessageMediator.RemoveListener<CReadPacket>(MessageMediatType.gm_add_player_data_ret, ReceiveServGMMsg);
    }
    
    //Window面板绘制
    static GMUtil window;
    [MenuItem("Tools/GM工具 #&Q")]
    static void Main()
    {
        window = (GMUtil)EditorWindow.GetWindow(typeof(GMUtil), false, "GM工具");
        window.Show();
    }

    private void OnGUI()
    {
        if(!Application.isPlaying || SceneManage.Instance.SceneID != EnumSceneID.UI_MajorCity01)
        {
            GUILayout.Label("请进入主城后再使用GM工具");
            return;
        }
        else
        {
  
            //初始化获取所有物品表信息
            if (isAddedListener == false)
            {
                isAddedListener = true;
            }
            if (allItemNodeLis
  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值