コード例 #1
0
    public override void OnInspectorGUI()
    {
        GameAssets ga = (GameAssets)target;

        if (!GameSpecified())
        {
            if (GUILayout.Button("选择游戏"))
            {
                SelectGame();
            }
            return;
        }
        else
        {
            GUILayout.Label("当前游戏: " + ga.GameName);
            GUILayout.Label("当前目录: " + ga.GameFolder);
            GUILayout.Label("* 删除" + AssetPath + "以重新选择游戏");
        }

        GUILayout.Space(20);

        if (GUILayout.Button("刷新资源"))
        {
            ga.AllCocoFiles();
        }

        if (ga.PackagePairs != null && ga.PackagePairs.Length > 0)
        {
            for (int i = 0; i < ga.PackagePairs.Length; i++)
            {
                PackagePair pp = ga.PackagePairs[i];
                GUILayout.BeginHorizontal();
                pp.Obj = (GameObject)EditorGUILayout.ObjectField(pp.Name, pp.Obj, typeof(GameObject), false);
                if (pp.Obj == null)
                {
                    if (GUILayout.Button("创建"))
                    {
                        ga.CreatePackage(pp);
                    }
                }
                else
                {
                    if (GUILayout.Button("保存"))
                    {
                        var p = pp.Obj.GetComponent <Package>();
                        ga.SavePackage(p);
                    }
                }
                GUILayout.EndHorizontal();
            }
        }
        else
        {
            GUILayout.Label("找不到ejoy2d资源包");
        }
    }