Beispiel #1
0
    private void CurrentAssetBundlesGUI()
    {
        //  //区域的视图范围:左上角位置固定在上一个区域的底部,宽度固定(240),高度为窗口高度的一半再减去空隙(15),上下都有空隙
        _currentABViewRect  = new Rect(5, (int)position.height / 2 + 10, 240, (int)position.height / 2 - 15);
        _currentABScollRect = new Rect(5, (int)position.height / 2 + 10, 240, _currentABViewHeight);

        _currentABScroll = GUI.BeginScrollView(_currentABViewRect, _currentABScroll, _currentABScollRect);
        GUI.BeginGroup(_currentABScollRect, box);


        _currentABViewHeight = 5;
        if (_currentAB != -1)
        {
            AssetBundleBuildInfo build = _assetBundle.AssetBundles[_currentAB];
            for (int i = 0; i < build.Assets.Count; ++i)
            {
                //同理,遍历到当前选中的资源对象,在原地画蓝色高亮背景框
                if (_currentABAsset == i)
                {
                    GUI.Box(new Rect(10, _currentABViewHeight, 200, 15), "", _LRSelect);
                    GUIContent content = EditorGUIUtility.ObjectContent(null, build.Assets[i].AssetType);
                    content.text = build.Assets[i].AssetName;
                    GUI.Label(new Rect(20, _currentABViewHeight, 205, 15), content);
                    //绘制减号按钮
                    if (GUI.Button(new Rect(180, _currentABViewHeight, 20, 15), "", _OLMinus))
                    {
                        build.RemoveAsset(build.Assets[i]);
                        _currentABAsset = -1;
                    }
                }
                else
                {
                    //原地绘制Button控件,当点击时,此资源对象被选中
                    GUIContent content = EditorGUIUtility.ObjectContent(null, build.Assets[i].AssetType);
                    content.text = build.Assets[i].AssetName;
                    if (GUI.Button(new Rect(5, _currentABViewHeight, 205, 15), content))
                    {
                        _currentABAsset = i;
                    }
                }


                _currentABViewHeight += 20;
            }
        }

        _currentABViewHeight += 5;
        if (_currentABViewHeight < _currentABViewRect.height)
        {
            _currentABViewHeight = (int)_currentABViewRect.height;
        }
        GUI.EndGroup();
        GUI.EndScrollView();
    }
Beispiel #2
0
    private void CurrentAssetBundlesGUI()
    {
        _currentABViewRect   = new Rect(5, (int)position.height / 2 + 10, 240, (int)position.height / 2 - 15);
        _currentABScrollRect = new Rect(5, (int)position.height / 2 + 10, 240, _currentABViewHeight);
        _currentABScroll     = GUI.BeginScrollView(_currentABViewRect, _currentABScroll, _currentABScrollRect);
        GUI.BeginGroup(_currentABScrollRect, _box);

        _currentABViewHeight = 5;
        //这里是我们加入的内容,判断条件:只有当前选中任意AB包对象后,此区域的内容才生效(_currentAB != -1)
        if (_currentAB != -1)
        {
            //遍历build.Assets(当前选中的AB包对象的资源列表)
            AssetBundleBuildInfo build = _assetBundle.AssetBundles[_currentAB];
            for (int i = 0; i < build.Assets.Count; i++)
            {
                //同理,遍历到当前选中的资源对象,在原地画蓝色高亮背景框
                if (_currentABAsset == i)
                {
                    GUI.Box(new Rect(0, _currentABViewHeight, 240, 15), "", _LRSelect);
                }
                //原地绘制Button控件,当点击时,此资源对象被选中
                GUIContent content = EditorGUIUtility.ObjectContent(null, build.Assets[i].AssetType);
                content.text = build.Assets[i].AssetName;
                if (GUI.Button(new Rect(5, _currentABViewHeight, 205, 15), content, _prefabLabel))
                {
                    _currentABAsset = i;
                }
                //在Button控件右方绘制减号Button控件,当点击时,删除此资源对象在当前选中的AB包中
                if (GUI.Button(new Rect(215, _currentABViewHeight, 20, 15), "", _oLMinus))
                {
                    build.RemoveAsset(build.Assets[i]);
                    _currentABAsset = -1;
                }
                _currentABViewHeight += 20;
            }
        }

        _currentABViewHeight += 5;
        if (_currentABViewHeight < _currentABViewRect.height)
        {
            _currentABViewHeight = (int)_currentABViewRect.height;
        }

        GUI.EndGroup();
        GUI.EndScrollView();
    }