ShowWindow() public static méthode

public static ShowWindow ( string inAssets, string &assetsThatShouldBeSaved ) : void
inAssets string
assetsThatShouldBeSaved string
Résultat void
Exemple #1
0
        private static void OnWillSaveAssets(string[] assets, out string[] assetsThatShouldBeSaved, out string[] assetsThatShouldBeReverted, int explicitlySaveScene)
        {
            assetsThatShouldBeReverted = new string[0];
            assetsThatShouldBeSaved    = assets;
            bool flag = assets.Length > 0 && EditorPrefs.GetBool("VerifySavingAssets", false) && InternalEditorUtility.isHumanControllingUs;

            if (explicitlySaveScene != 0 && assets.Length == 1 && assets[0].EndsWith(".unity"))
            {
                flag = false;
            }
            if (flag)
            {
                AssetSaveDialog.ShowWindow(assets, out assetsThatShouldBeSaved);
            }
            else
            {
                assetsThatShouldBeSaved = assets;
            }
            foreach (Type current in AssetModificationProcessorInternal.AssetModificationProcessors)
            {
                MethodInfo method = current.GetMethod("OnWillSaveAssets", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
                if (method != null)
                {
                    object[] array = new object[]
                    {
                        assetsThatShouldBeSaved
                    };
                    if (AssetModificationProcessorInternal.CheckArguments(array, method))
                    {
                        string[] array2 = (string[])method.Invoke(null, array);
                        if (array2 != null)
                        {
                            assetsThatShouldBeSaved = array2;
                        }
                    }
                }
            }
            if (assetsThatShouldBeSaved == null)
            {
                return;
            }
            List <string> list = new List <string>();

            string[] array3 = assetsThatShouldBeSaved;
            for (int i = 0; i < array3.Length; i++)
            {
                string text = array3[i];
                if (!AssetDatabase.IsOpenForEdit(text))
                {
                    list.Add(text);
                }
            }
            assets = list.ToArray();
            if (assets.Length != 0 && !Provider.PromptAndCheckoutIfNeeded(assets, string.Empty))
            {
                Debug.LogError("Could not check out the following files in version control before saving: " + string.Join(", ", assets));
                assetsThatShouldBeSaved = new string[0];
                return;
            }
        }
Exemple #2
0
        private static void OnWillSaveAssets(string[] assets, out string[] assetsThatShouldBeSaved, out string[] assetsThatShouldBeReverted, int explicitlySaveScene)
        {
            assetsThatShouldBeReverted = new string[0];
            assetsThatShouldBeSaved    = assets;
            bool flag = assets.Length > 0 && EditorPrefs.GetBool("VerifySavingAssets", false) && InternalEditorUtility.isHumanControllingUs;

            if (explicitlySaveScene != 0 && assets.Length == 1 && assets[0].EndsWith(".unity"))
            {
                flag = false;
            }
            if (flag)
            {
                AssetSaveDialog.ShowWindow(assets, out assetsThatShouldBeSaved);
            }
            else
            {
                assetsThatShouldBeSaved = assets;
            }
            foreach (System.Type modificationProcessor in AssetModificationProcessorInternal.AssetModificationProcessors)
            {
                MethodInfo method = modificationProcessor.GetMethod("OnWillSaveAssets", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
                if (method != null)
                {
                    object[] objArray = new object[1]
                    {
                        (object)assetsThatShouldBeSaved
                    };
                    if (AssetModificationProcessorInternal.CheckArguments(objArray, method))
                    {
                        string[] strArray = (string[])method.Invoke((object)null, objArray);
                        if (strArray != null)
                        {
                            assetsThatShouldBeSaved = strArray;
                        }
                    }
                }
            }
            if (assetsThatShouldBeSaved == null)
            {
                return;
            }
            List <string> stringList = new List <string>();

            foreach (string assetOrMetaFilePath in assetsThatShouldBeSaved)
            {
                if (!AssetDatabase.IsOpenForEdit(assetOrMetaFilePath))
                {
                    stringList.Add(assetOrMetaFilePath);
                }
            }
            assets = stringList.ToArray();
            if (assets.Length == 0 || Provider.PromptAndCheckoutIfNeeded(assets, string.Empty))
            {
                return;
            }
            Debug.LogError((object)("Could not check out the following files in version control before saving: " + string.Join(", ", assets)));
            assetsThatShouldBeSaved = new string[0];
        }
        private static void OnWillSaveAssets(string[] assets, out string[] assetsThatShouldBeSaved, out string[] assetsThatShouldBeReverted, int explicitlySaveScene)
        {
            assetsThatShouldBeReverted = new string[0];
            assetsThatShouldBeSaved    = assets;
            bool flag = ((assets.Length > 0) && EditorPrefs.GetBool("VerifySavingAssets", false)) && InternalEditorUtility.isHumanControllingUs;

            if (((explicitlySaveScene != 0) && (assets.Length == 1)) && assets[0].EndsWith(".unity"))
            {
                flag = false;
            }
            if (flag)
            {
                AssetSaveDialog.ShowWindow(assets, out assetsThatShouldBeSaved);
            }
            else
            {
                assetsThatShouldBeSaved = assets;
            }
            foreach (System.Type type in AssetModificationProcessors)
            {
                MethodInfo method = type.GetMethod("OnWillSaveAssets", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static);
                if (method != null)
                {
                    object[] args = new object[] { assetsThatShouldBeSaved };
                    if (CheckArguments(args, method))
                    {
                        string[] strArray = (string[])method.Invoke(null, args);
                        if (strArray != null)
                        {
                            assetsThatShouldBeSaved = strArray;
                        }
                    }
                }
            }
            if (assetsThatShouldBeSaved != null)
            {
                List <string> list = new List <string>();
                foreach (string str in assetsThatShouldBeSaved)
                {
                    if (!AssetDatabase.IsOpenForEdit(str, StatusQueryOptions.ForceUpdate))
                    {
                        list.Add(str);
                    }
                }
                assets = list.ToArray();
                if ((assets.Length != 0) && !Provider.PromptAndCheckoutIfNeeded(assets, ""))
                {
                    Debug.LogError("Could not check out the following files in version control before saving: " + string.Join(", ", assets));
                    assetsThatShouldBeSaved = new string[0];
                }
            }
        }
        // Postprocess on all assets once an automatic import has completed
        // ReSharper disable once UnusedMember.Local - invoked from native code
        static void OnWillSaveAssets(string[] assets, out string[] assetsThatShouldBeSaved, out string[] assetsThatShouldBeReverted, bool explicitlySaveAsset)
        {
            assetsThatShouldBeReverted = new string[0];
            assetsThatShouldBeSaved    = assets;

            bool showSaveDialog = assets.Length > 0 && EditorPrefs.GetBool("VerifySavingAssets", false) && InternalEditorUtility.isHumanControllingUs;

            // If we are only saving a single scene or prefab and the user explicitly said we should, skip the dialog. We don't need
            // to verify this twice.
            if (explicitlySaveAsset && assets.Length == 1 && (assets[0].EndsWith(".unity") || assets[0].EndsWith(".prefab")))
            {
                showSaveDialog = false;
            }

            if (showSaveDialog)
            {
                AssetSaveDialog.ShowWindow(assets, out assetsThatShouldBeSaved);
            }
            else
            {
                assetsThatShouldBeSaved = assets;
            }

            foreach (var assetModificationProcessorClass in AssetModificationProcessors)
            {
                MethodInfo method = assetModificationProcessorClass.GetMethod("OnWillSaveAssets", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
                if (method != null)
                {
                    object[] args = { assetsThatShouldBeSaved };
                    if (!CheckArguments(args, method))
                    {
                        continue;
                    }

                    string[] result = (string[])method.Invoke(null, args);

                    if (result != null)
                    {
                        assetsThatShouldBeSaved = result;
                    }
                }
            }

            if (assetsThatShouldBeSaved == null)
            {
                return;
            }

            var assetsNotOpened = new List <string>();

            AssetDatabase.IsOpenForEdit(assetsThatShouldBeSaved, assetsNotOpened, StatusQueryOptions.ForceUpdate);
            assets = assetsNotOpened.ToArray();

            // Try to checkout if needed
            var notEditableAssets = new List <string>();

            if (assets.Length != 0 && !AssetDatabase.MakeEditable(assets, null, notEditableAssets))
            {
                // only save assets that can be made editable (not locked by someone else, etc.),
                // unless we are in the behavior mode that just overwrites everything anyway
                if (!EditorUserSettings.overwriteFailedCheckoutAssets)
                {
                    assetsThatShouldBeReverted = notEditableAssets.ToArray();
                    assetsThatShouldBeSaved    = assetsThatShouldBeSaved.Except(assetsThatShouldBeReverted).ToArray();
                }
            }
        }
        // Postprocess on all assets once an automatic import has completed
        static void OnWillSaveAssets(string[] assets, out string[] assetsThatShouldBeSaved, out string[] assetsThatShouldBeReverted, int explicitlySaveAsset)
        {
            assetsThatShouldBeReverted = new string[0];
            assetsThatShouldBeSaved    = assets;

            bool showSaveDialog = assets.Length > 0 && EditorPrefs.GetBool("VerifySavingAssets", false) && InternalEditorUtility.isHumanControllingUs;

            // If we are only saving a single scene or prefab and the user explicitly said we should, skip the dialog. We don't need
            // to verify this twice.
            if (explicitlySaveAsset != 0 && assets.Length == 1 && (assets[0].EndsWith(".unity") || assets[0].EndsWith(".prefab")))
            {
                showSaveDialog = false;
            }

            if (showSaveDialog)
            {
                AssetSaveDialog.ShowWindow(assets, out assetsThatShouldBeSaved);
            }
            else
            {
                assetsThatShouldBeSaved = assets;
            }

            foreach (var assetModificationProcessorClass in AssetModificationProcessors)
            {
                MethodInfo method = assetModificationProcessorClass.GetMethod("OnWillSaveAssets", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
                if (method != null)
                {
                    object[] args = { assetsThatShouldBeSaved };
                    if (!CheckArguments(args, method))
                    {
                        continue;
                    }

                    string[] result = (string[])method.Invoke(null, args);

                    if (result != null)
                    {
                        assetsThatShouldBeSaved = result;
                    }
                }
            }

            if (assetsThatShouldBeSaved == null)
            {
                return;
            }

            var assetsNotOpened = new List <string>();

            foreach (string asset in assetsThatShouldBeSaved)
            {
                if (!AssetDatabase.IsOpenForEdit(asset, StatusQueryOptions.ForceUpdate))
                {
                    assetsNotOpened.Add(asset);
                }
            }
            assets = assetsNotOpened.ToArray();

            // Try to checkout if needed. This may fail but is catched below.
            if (assets.Length != 0 && !Provider.PromptAndCheckoutIfNeeded(assets, ""))
            {
                Debug.LogError("Could not check out the following files in version control before saving: " +
                               string.Join(", ", assets));
                assetsThatShouldBeSaved = new string[0];
                return;
            }
        }
Exemple #6
0
        // Postprocess on all assets once an automatic import has completed
        static void OnWillSaveAssets(string[] assets, out string[] assetsThatShouldBeSaved, out string[] assetsThatShouldBeReverted, bool explicitlySaveAsset)
        {
            assetsThatShouldBeReverted = new string[0];
            assetsThatShouldBeSaved    = assets;

            bool showSaveDialog = assets.Length > 0 && EditorPrefs.GetBool("VerifySavingAssets", false) && InternalEditorUtility.isHumanControllingUs;

            // If we are only saving a single scene or prefab and the user explicitly said we should, skip the dialog. We don't need
            // to verify this twice.
            if (explicitlySaveAsset && assets.Length == 1 && (assets[0].EndsWith(".unity") || assets[0].EndsWith(".prefab")))
            {
                showSaveDialog = false;
            }

            if (showSaveDialog)
            {
                AssetSaveDialog.ShowWindow(assets, out assetsThatShouldBeSaved);
            }
            else
            {
                assetsThatShouldBeSaved = assets;
            }

            foreach (var assetModificationProcessorClass in AssetModificationProcessors)
            {
                MethodInfo method = assetModificationProcessorClass.GetMethod("OnWillSaveAssets", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
                if (method != null)
                {
                    object[] args = { assetsThatShouldBeSaved };
                    if (!CheckArguments(args, method))
                    {
                        continue;
                    }

                    string[] result = (string[])method.Invoke(null, args);

                    if (result != null)
                    {
                        assetsThatShouldBeSaved = result;
                    }
                }
            }

            if (assetsThatShouldBeSaved == null)
            {
                return;
            }

            var assetsNotOpened = new List <string>();

            foreach (string asset in assetsThatShouldBeSaved)
            {
                if (!AssetDatabase.IsOpenForEdit(asset, StatusQueryOptions.ForceUpdate))
                {
                    assetsNotOpened.Add(asset);
                }
            }
            assets = assetsNotOpened.ToArray();

            // Try to checkout if needed. This may fail but is caught below.
            var editableAssets = new string[assets.Length];

            if (assets.Length != 0 && !Provider.MakeEditable(assets, editableAssets))
            {
                // TODO: fix this behaviour to make save asset honour version control result
                // keep previous behaviour which is save all assets even if checkout fails
                // TODO: this needs to consider and handle saving assets which have not been
                // added to version control. They have to be added to version control before
                // calling MakeEditable.
                //assetsThatShouldBeSaved = editableAssets;
                return;
            }
        }