UnityEditor.AssetSaveDialog.ShowWindow C# (CSharp) Method

ShowWindow() public static method

public static ShowWindow ( string inAssets, string &assetsThatShouldBeSaved ) : void
inAssets string
assetsThatShouldBeSaved string
return void
        public static void ShowWindow(string[] inAssets, out string[] assetsThatShouldBeSaved)
        {
            int num = 0;
            foreach (string str in inAssets)
            {
                if (str.EndsWith("meta"))
                {
                    num++;
                }
            }
            int num3 = inAssets.Length - num;
            if (num3 == 0)
            {
                assetsThatShouldBeSaved = inAssets;
            }
            else
            {
                string[] assets = new string[num3];
                string[] strArray3 = new string[num];
                num3 = 0;
                num = 0;
                foreach (string str2 in inAssets)
                {
                    if (str2.EndsWith("meta"))
                    {
                        strArray3[num++] = str2;
                    }
                    else
                    {
                        assets[num3++] = str2;
                    }
                }
                AssetSaveDialog windowDontShow = EditorWindow.GetWindowDontShow<AssetSaveDialog>();
                windowDontShow.titleContent = EditorGUIUtility.TextContent("Save Assets");
                windowDontShow.SetAssets(assets);
                windowDontShow.ShowUtility();
                windowDontShow.ShowModal();
                assetsThatShouldBeSaved = new string[windowDontShow.m_AssetsToSave.Count + num];
                windowDontShow.m_AssetsToSave.CopyTo(assetsThatShouldBeSaved, 0);
                strArray3.CopyTo(assetsThatShouldBeSaved, windowDontShow.m_AssetsToSave.Count);
            }
        }

Usage Example

Example #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;
            }
        }
All Usage Examples Of UnityEditor.AssetSaveDialog::ShowWindow