示例#1
0
    static void BuildZip()
    {
        utils.CompressDirProgress cdp = CompressDirProgress;
        utils.CompressDirFinish   cdf = CompressDirFinish;
        utils.CompressDir("Assets/StreamingAssets", "Assets/res.zip", cdp, cdf);
        string streamPath = Application.streamingAssetsPath;

        if (Directory.Exists(streamPath))
        {
            Directory.Delete(streamPath, true);
        }
        Directory.CreateDirectory(streamPath);
        File.Copy("Assets/res.zip", "Assets/StreamingAssets/res.zip");
        File.Delete("Assets/res.zip");
    }
示例#2
0
    void OnGUI()
    {
        bool _ok = false;

        read();
        GUILayout.Label("--- 行为测试 ---");
        GUILayout.BeginHorizontal();
        GUILayout.Label("速度", GUILayout.Width(60f));
        m_action_speed = EditorGUILayout.TextArea(m_action_speed, GUILayout.Width(160f));
        GUILayout.EndHorizontal();
        for (int i = 0; i < m_action_name.Count; ++i)
        {
            GUILayout.BeginHorizontal();
            GUILayout.Label(m_action_name[i], GUILayout.Width(160f));
            _ok = GUILayout.Button("确定", GUILayout.Width(60f));
            bool _del = GUILayout.Button("删除", GUILayout.Width(60f));
            GUILayout.EndHorizontal();

            if (_ok)
            {
                s_message _msg = new s_message();

                _msg.name = "action";
                _msg.m_object.Add(m_action_name[i]);
                _msg.m_object.Add(m_action_speed);
                AppFacade._instance.MessageManager.AddMessage(_msg);
            }

            if (_del)
            {
                m_action_name.RemoveAt(i);
                save();
                Repaint();
            }
        }
        m_action_name1 = EditorGUILayout.TextArea(m_action_name1);
        _ok            = GUILayout.Button("增加", GUILayout.Width(120f));

        if (_ok)
        {
            if (!m_action_name.Contains(m_action_name1))
            {
                m_action_name.Add(m_action_name1);
                save();
                Repaint();
            }
        }

        GUILayout.Label("--- 换装测试 ---");
        m_part_name = EditorGUILayout.TextArea(m_part_name);
        _ok         = GUILayout.Button("确定", GUILayout.Width(120f));

        if (_ok)
        {
            s_message _msg = new s_message();
            _msg.name = "change_part";
            _msg.m_object.Add(m_part_name);
            AppFacade._instance.MessageManager.AddMessage(_msg);
        }

        GUILayout.Label("--- 清理本地 ---");
        _ok = GUILayout.Button("清理", GUILayout.Width(120f));
        if (_ok)
        {
            PlayerPrefs.DeleteAll();
        }

        GUILayout.Label("--- 导出navmesh ---");
        _ok = GUILayout.Button("导出", GUILayout.Width(120f));

        if (_ok)
        {
            string outfile = Application.streamingAssetsPath + "\\nav.txt";
            if (!System.IO.Directory.Exists(Application.streamingAssetsPath))
            {
                System.IO.Directory.CreateDirectory(Application.streamingAssetsPath);
            }
            GenNavMesh(outfile);
        }

        GUILayout.Label("--- 测试navmesh ---");
        _ok = GUILayout.Button("测试", GUILayout.Width(120f));

        if (_ok)
        {
            DrawMesh();
        }

        GUILayout.Label("--- gm命令 ---");
        m_gm_command = EditorGUILayout.TextArea(m_gm_command);
        _ok          = GUILayout.Button("发送", GUILayout.Width(120f));

        if (_ok)
        {
            s_message mes = new s_message();
            mes.name = "edit_gm_command";
            mes.m_object.Add(m_gm_command);
            AppFacade._instance.MessageManager.AddMessage(mes);
        }
        GUILayout.Label("--- 修改字体颜色 ---");
        m_font_color = EditorGUILayout.TextArea(m_font_color);
        _ok          = GUILayout.Button("修改", GUILayout.Width(120f));
        if (_ok)
        {
            UnityEngine.Object selectedObject = Selection.activeObject;
            if (selectedObject == null)
            {
                return;
            }
            string     path  = AssetDatabase.GetAssetPath(selectedObject);
            GameObject obj   = AssetDatabase.LoadMainAssetAtPath(path) as GameObject;
            UILabel[]  us    = obj.transform.GetComponentsInChildren <UILabel>();
            string[]   color = m_font_color.Split(' ');
            if (color.Length < 3)
            {
                return;
            }
            float r = float.Parse(color[0]);
            float g = float.Parse(color[1]);
            float b = float.Parse(color[2]);
            for (int j = 0; j < us.Length; ++j)
            {
                us[j].color = new Color(r / 255, g / 255, b / 255, 1);
            }
            AssetDatabase.Refresh();
            AssetDatabase.SaveAssets();
        }
        GUILayout.Label("--- 压缩 ---");
        _ok = GUILayout.Button("压缩", GUILayout.Width(120f));

        if (_ok)
        {
            utils.CompressDirProgress cdp = CompressDirProgress;
            utils.CompressDirFinish   cdf = CompressDirFinish;
            utils.CompressDir("Assets/StreamingAssets", "Assets/res.zip", cdp, cdf);
        }

        GUILayout.Label("--- 解压 ---");
        _ok = GUILayout.Button("解压", GUILayout.Width(120f));

        if (_ok)
        {
            utils.DecompressDirProgress ddp = DecompressDirProgress;
            utils.DecompressDirFinish   ddf = DecompressDirFinish;
            //utils.DecompressDir("Assets/StreamingAssets/res.zip", "d:/aaa", ddp, ddf);
        }
    }