Inheritance: MonoBehaviour
Example #1
0
    private void DrawMeshProperties(string filter, MeshSetting meshSetting, System.Action <string> addToPaths, System.Action <string> action)
    {
        if (GUILayout.Button("扫描", GUILayout.Width(50)))
        {
            _meshSetting = meshSetting;
            _meshSettingPaths.Clear();
            var guids = AssetDatabase.FindAssets(filter);
            var len   = guids.Length;

            for (var i = 0; i < len; i++)
            {
                var path = AssetDatabase.GUIDToAssetPath(guids[i]);

                if (!InFilterList(path) && InContainList(path) && addToPaths != null)
                {
                    addToPaths(path);
                }

                EditorUtility.DisplayProgressBar("处理中...", path, (float)(i + 1) / len);
            }

            EditorUtility.ClearProgressBar();

            if (_meshSettingPaths.Count < 1)
            {
                _window.ShowNotification(new GUIContent("无需处理"));
            }
        }

        if (_meshSetting == meshSetting && _meshSettingPaths.Count > 0)
        {
            GUILayout.Label(_meshSettingPaths.Count.ToString(), EditorStyles.textField, GUILayout.Width(50));

            if (GUILayout.Button("全部处理", GUILayout.Width(80)))
            {
                var len = _meshSettingPaths.Count;

                for (var i = 0; i < len; i++)
                {
                    var path = _meshSettingPaths[i];

                    if (action != null)
                    {
                        action(path);
                    }

                    EditorUtility.DisplayProgressBar("处理中...", path, (float)(i + 1) / len);
                }

                EditorUtility.ClearProgressBar();
                _meshSettingPaths.Clear();
            }

            if (GUILayout.Button("X", GUILayout.Width(20)))
            {
                _meshSettingPaths.Clear();
                _meshSetting = MeshSetting.None;
            }
        }
    }
 public static void CreateMesh(int shape)
 {
     App.Current.Dispatcher.Invoke((Action)(() =>
     {
         MeshSetting meshSetting = new MeshSetting();
         meshSetting.ShapeID = shape;
         meshSetting.Show();
         Application.Current.MainWindow = meshSetting;
     }));
 }
Example #3
0
    private void DrawMeshScrollList(MeshSetting meshSetting, System.Action <string> act)
    {
        if (_meshSetting == meshSetting && _meshSettingPaths.Count > 0)
        {
            _meshSettingScrollPos = GUILayout.BeginScrollView(_meshSettingScrollPos, EditorStyles.helpBox);

            for (var i = 0; i < _meshSettingPaths.Count; i++)
            {
                var path = _meshSettingPaths[i];
                GUILayout.BeginHorizontal(EditorStyles.textField, GUILayout.MinHeight(20f));

                if (GUILayout.Button(path, EditorStyles.label))
                {
                    EditorGUIUtility.PingObject(AssetDatabase.LoadAssetAtPath <Object>(path));
                }

                if (GUILayout.Button("处理", GUILayout.Width(50)))
                {
                    act?.Invoke(path);
                    _meshSettingPaths.RemoveAt(i);
                }

                if (GUILayout.Button("X", GUILayout.Width(20)))
                {
                    _meshSettingPaths.RemoveAt(i);

                    if (_meshSettingPaths.Count < 1)
                    {
                        _meshSetting = MeshSetting.None;
                    }
                }

                GUILayout.EndHorizontal();
            }

            GUILayout.EndScrollView();
        }
    }