Пример #1
0
        private void CreateScriptObject(MonoScript script)
        {
            var path  = Path.GetDirectoryName(AssetDatabase.GetAssetPath(script));
            var asset = EditorAssetHelper.CreateScriptableObjectAsset(script.GetClass(),
                                                                      string.Format("{0}/{1}.asset", path, script.name));

            AssetDatabase.Refresh();
            EditorAssetHelper.SelectObject(asset);
        }
Пример #2
0
        protected override void CustomOnGUI()
        {
            if (_msg != null)
            {
                EditorUIHelper.TitleField(_msg);
                EditorUIHelper.Space();
            }

            _search       = EditorUIHelper.SearchCancelTextField(_search);
            _searchFilter = EditorUIHelper.EnumPopup <EditorAssetHelper.SearchFilter>(_searchFilter, "SearchFilter");
            EditorUIHelper.TitleField("数量:", (_goList != null ? _goList.Count : 0).ToString());

            EditorUIHelper.Space();
            _ListScroll = EditorUIHelper.BeginScrollView(_ListScroll);
            {
                var count      = _goList != null ? _goList.Count : 0;
                var needSearch = !string.IsNullOrEmpty(_search);
                for (int i = 0; i < count; i++)
                {
                    var go = _goList[i];
                    if (needSearch && !go.name.Contains(_search))
                    {
                        continue;
                    }

                    if (!EditorAssetHelper.IsMatch(go, _searchFilter))
                    {
                        continue;
                    }

                    EditorUIHelper.DrawLine();
                    EditorUIHelper.BeginHorizontal();
                    {
                        EditorUIHelper.ObjectField(go, null, string.Empty, true);
                        EditorUIHelper.Button("选中", () => EditorAssetHelper.SelectObject(go));
                        var index = i;
                        EditorUIHelper.Button("移除", () => RemoveGo(index));
                    }
                    EditorUIHelper.EndHorizontal();
                }
            }
            EditorUIHelper.EndScrollView();
        }
Пример #3
0
        protected override void CustomOnGUI()
        {
            _searchText = EditorUIHelper.SearchCancelTextField(_searchText);

            EditorUIHelper.Space();
            EditorUIHelper.Button("InstanceID", () =>
            {
                int id;
                if (int.TryParse(_searchText, out id))
                {
                    EditorAssetHelper.SelectObject(EditorUtility.InstanceIDToObject(id));
                }
            });


            EditorUIHelper.Space();
            EditorUIHelper.Button("GUID", () =>
            {
                EditorAssetHelper.SelectObject(EditorAssetHelper.GUIDToObject(_searchText));
            });
        }
Пример #4
0
        private void ShowAssets()
        {
            if (_assetPaths == null)
            {
                _assetPaths = Operator.GetAssetPaths();
                if (!string.IsNullOrEmpty(_searchText))
                {
                    _assetPaths = _assetPaths.Where(s => s.Contains(_searchText)).ToList();
                }
            }

            var count = _assetPaths.Count;

            for (int i = 0; i < count; i++)
            {
                EditorUIHelper.Space(0.1f);
                EditorUIHelper.BeginSelectdColor(_selectedObjIndex == i);
                {
                    EditorUIHelper.BeginHorizontal(EditorUIHelper.TextAreaStyle);
                    {
                        var path = _assetPaths[i];

                        var i1 = i;
                        EditorUIHelper.Button(path, () =>
                        {
                            EditorAssetHelper.SelectObject(AssetDatabase.LoadMainAssetAtPath(path));
                            _selectedObjIndex = i1;
                        }, EditorUIHelper.TextFieldStyle);
                    }
                    EditorUIHelper.EndHorizontal();
                }
                EditorUIHelper.EndSelectedColor();
            }

            if (_selectedObjIndex >= 0)
            {
                ShowSettingPanel(Operator.GetImporterSetting(_assetPaths[_selectedObjIndex]));
            }
        }