예제 #1
0
 /// <summary>Refreshes the asset database.</summary>
 /// <param name="options">Asset import options (default: ImportAssetOptions.Default, optional).</param>
 public static void RefreshAssetDatabase(ImportAssetOptions options = ImportAssetOptions.Default)
 {
     if (isEditorMode)
     {
         AssetDatabase.Refresh(options);
     }
 }
예제 #2
0
 // Token: 0x060000EC RID: 236 RVA: 0x00008C90 File Offset: 0x00006E90
 public static bool Reimport(List <string> paths, int confirmcount, ImportAssetOptions importoptions)
 {
     if (confirmcount > 0 && paths.Count >= confirmcount)
     {
         StringBuilder stringBuilder = new StringBuilder(128);
         int           num           = 0;
         foreach (string str in paths)
         {
             if (num < 3)
             {
                 stringBuilder.AppendLine("'" + str + "'");
             }
             else if (num == 3)
             {
                 stringBuilder.AppendLine("...");
             }
             num++;
         }
         string text = "Reimport asset?";
         if (paths.Count > 1)
         {
             text = string.Format("Reimport {0} assets?", paths.Count);
         }
         if (!EditorUtility.DisplayDialog(text, stringBuilder.ToString(), "Reimport", "Cancel"))
         {
             return(false);
         }
     }
     foreach (string text2 in paths)
     {
         AssetDatabase.ImportAsset(text2, importoptions);
     }
     AssetDatabase.Refresh();
     return(true);
 }
예제 #3
0
        /// <summary>
        /// Import asset in editor from full path. This is an helper over <see cref="AssetDatabase.ImportAsset(string, ImportAssetOptions)"/> which takes a relative path.
        /// </summary>
        /// <param name="path">Full path to asset.</param>
        /// <param name="importAssetOptions">Import asset options.</param>
        public static void ImportAsset(string path, ImportAssetOptions importAssetOptions = ImportAssetOptions.Default)
        {
            string relPath = MakeRelativePath(Application.dataPath, path);

            if (relPath != null)
            {
                AssetDatabase.ImportAsset(relPath, importAssetOptions);
            }
        }
예제 #4
0
    public static void Reimport(string filter, ImportAssetOptions option = ImportAssetOptions.Default)
    {
        List <string> filteredPaths = GetAssetPaths(filter);

        foreach (string path in filteredPaths)
        {
            AssetDatabase.ImportAsset(path, option);
        }
    }
예제 #5
0
 /// <summary>
 /// Does asset reimport.
 /// </summary>
 /// <param name="path">Path.</param>
 /// <param name="options">Options.</param>
 public static void DoAssetReimport(string path, ImportAssetOptions options)
 {
     try
     {
         AssetDatabase.StartAssetEditing();
         AssetDatabase.ImportAsset(path, options);
     } finally
     {
         AssetDatabase.StopAssetEditing();
     }
 }
예제 #6
0
 public static void ForceRefresh(ImportAssetOptions options)
 {
     if (isStartAssetEditing)
     {
         AssetDatabase.StopAssetEditing();
     }
     AssetDatabase.Refresh(options);
     if (isStartAssetEditing)
     {
         AssetDatabase.StartAssetEditing();
     }
 }
예제 #7
0
        public static void ImportAsset(string path, ImportAssetOptions options = ImportAssetOptions.Default)
        {
#if UNITY_2021_2_OR_NEWER
            // Unity 2021.2+ fixes a bug in older Unity versions that required calling AssetDatabase.SaveAssets() before ImportAsset()
            // See <https://issuetracker.unity3d.com/issues/duplicating-asset-replaces-it-with-one-of-its-sub-assets-if-the-asset-is-created-in-a-version-before-fix>
            // TODO: Update this when fix is backported
#else
            AssetDatabase.SaveAssets();
#endif

            AssetDatabase.ImportAsset(path, options);
        }
            public void Refresh(ImportAssetOptions options = ImportAssetOptions.Default)
            {
                logger.Verbose("Refreshing assets...");

                foreach (var asset in importedAssets)
                {
                    string metaPath = Path.ChangeExtension(asset, ".meta");

                    if (!file.Exists(metaPath))
                    {
                        file.Copy(asset, metaPath);
                    }
                }
            }
예제 #9
0
        /// <summary>
        /// 管理対象のリソースを再インポート
        /// </summary>
        public void ReImportResources()
        {
            ImportAssetOptions options = ImportAssetOptions.ForceUpdate | ImportAssetOptions.ImportRecursive;

            foreach (Object folder in CustomInportSpriteFolders)
            {
                AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(folder), options);
            }
            foreach (Object folder in CustomInportAudioFolders)
            {
                AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(folder), options);
            }
            AssetDatabase.Refresh();
        }
예제 #10
0
    public static void PackageDemo()
    {
        string[] assetPaths = new string[]
        {
            "Assets/URLClient/Demo"
        };

        ImportAssetOptions importOpts = ImportAssetOptions.Default;

        importOpts |= ImportAssetOptions.ForceSynchronousImport;
        importOpts |= ImportAssetOptions.ImportRecursive;
        AssetDatabase.Refresh(importOpts);

        string packagePath = "unity-urlclient-demo.unitypackage";
        ExportPackageOptions exportOpts = ExportPackageOptions.Recurse;

        AssetDatabase.ExportPackage(assetPaths, packagePath, exportOpts);
    }
            public void ImportAsset(string fullPath, ImportAssetOptions options = ImportAssetOptions.Default)
            {
                if (!file.Exists(fullPath))
                {
                    logger.Verbose($"Importing asset fail (not exist)...\n({fullPath})");
                    return;
                }

                if (importedAssets.Contains(fullPath))
                {
                    logger.Verbose($"Importing asset fail (contained)...\n({fullPath})");
                    return;
                }

                file.Copy(fullPath, Path.ChangeExtension(fullPath, ".meta"));
                importedAssets.Add(fullPath);
                logger.Verbose($"Importing asset...\n({fullPath})");
            }
예제 #12
0
		/// <summary>
		/// Import the asset at the given path.
		/// </summary>
		/// <param name="assetPath"></param>
		/// <param name="options"></param>
		public static void ImportAsset(string assetPath, HEU_ImportAssetOptions heuOptions)
		{
#if UNITY_EDITOR
			ImportAssetOptions unityOptions = ImportAssetOptions.Default;
			switch(heuOptions)
			{
				case HEU_ImportAssetOptions.Default:						unityOptions = ImportAssetOptions.Default; break;
				case HEU_ImportAssetOptions.ForceUpdate:					unityOptions = ImportAssetOptions.ForceUpdate; break;
				case HEU_ImportAssetOptions.ForceSynchronousImport:			unityOptions = ImportAssetOptions.ForceSynchronousImport; break;
				case HEU_ImportAssetOptions.ImportRecursive:				unityOptions = ImportAssetOptions.ImportRecursive; break;
				case HEU_ImportAssetOptions.DontDownloadFromCacheServer:	unityOptions = ImportAssetOptions.DontDownloadFromCacheServer; break;
				case HEU_ImportAssetOptions.ForceUncompressedImport:		unityOptions = ImportAssetOptions.ForceUncompressedImport; break;
				default: Debug.LogWarningFormat("Unsupported import options: {0}", heuOptions); break;
			}

			AssetDatabase.ImportAsset(assetPath, unityOptions);
#else
			Debug.LogWarning(HEU_Defines.HEU_USERMSG_NONEDITOR_NOT_SUPPORTED);
#endif
		}
예제 #13
0
    public static void PackageCore()
    {
        string[] assetPaths = new string[]
        {
            "Assets/Plugins/URLClient",
            "Assets/Plugins/URLClient.bundle",
            "Assets/Plugins/iOS",
            "Assets/Plugins/Android",
            "Assets/Editor/URLClient"
        };

        ImportAssetOptions importOpts = ImportAssetOptions.Default;

        importOpts |= ImportAssetOptions.ForceSynchronousImport;
        importOpts |= ImportAssetOptions.ImportRecursive;
        AssetDatabase.Refresh(importOpts);

        string packagePath = "unity-urlclient.unitypackage";
        ExportPackageOptions exportOpts = ExportPackageOptions.Recurse;

        AssetDatabase.ExportPackage(assetPaths, packagePath, exportOpts);
    }
예제 #14
0
    public static void PackageCore()
    {
        string[] assetPaths = new string[]
        {
            "Assets/Countly/Editor",
            "Assets/Plugins/Countly",
            "Assets/Plugins/iOS/UnityCountly.mm",
            "Assets/Plugins/Android/Countly.jar"
        };

        string packagePath = "unity-countly.unitypackage";

        ImportAssetOptions importOpts = ImportAssetOptions.Default;

        importOpts |= ImportAssetOptions.ForceSynchronousImport;
        importOpts |= ImportAssetOptions.ImportRecursive;
        AssetDatabase.Refresh(importOpts);

        ExportPackageOptions exportOpts = ExportPackageOptions.Recurse;

        AssetDatabase.ExportPackage(assetPaths, packagePath, exportOpts);
    }
    public static void ForceImportAssetIfLocked(string a_rAssetPath, ImportAssetOptions a_eImportOptions)
    {
        bool bWasLocked     = ms_bLocked;
        bool bPreviousValue = ms_bEnabled;

        if (bWasLocked)
        {
            Uni2DAssetPostprocessor.Unlock( );
        }

        Uni2DAssetPostprocessor.Enabled = true;
        {
            AssetDatabase.ImportAsset(a_rAssetPath, a_eImportOptions);
        }

        if (bWasLocked)
        {
            Uni2DAssetPostprocessor.LockTo(bPreviousValue);
        }
        else
        {
            Uni2DAssetPostprocessor.Enabled = bPreviousValue;
        }
    }
    public static void ForceImportAssetIfLocked( string a_rAssetPath, ImportAssetOptions a_eImportOptions )
    {
        bool bWasLocked     = ms_bLocked;
        bool bPreviousValue = ms_bEnabled;

        if( bWasLocked )
        {
            Uni2DAssetPostprocessor.Unlock( );
        }

        Uni2DAssetPostprocessor.Enabled = true;
        {
            AssetDatabase.ImportAsset( a_rAssetPath, a_eImportOptions );
        }

        if( bWasLocked )
        {
            Uni2DAssetPostprocessor.LockTo( bPreviousValue );
        }
        else
        {
            Uni2DAssetPostprocessor.Enabled = bPreviousValue;
        }
    }
        public static void SaveMesh()
        {
            GameObject go = Selection.activeGameObject;

            SkinnedMeshRenderer[] skinnedMeshRenderers = go.GetComponentsInChildren <SkinnedMeshRenderer>();
            foreach (SkinnedMeshRenderer render in skinnedMeshRenderers)
            {
                if (render.sharedMesh == null)
                {
                    continue;
                }
                Mesh mesh = render.sharedMesh;
                if (!File.Exists("Assets/_Test/" + mesh.name + ".asset"))
                {
                    Mesh newmesh = (Mesh)Mesh.Instantiate(mesh);
                    AssetDatabase.CreateAsset(newmesh, "Assets/_Test/" + mesh.name + ".asset");
                }

                foreach (Material material in render.materials)
                {
                    if (!File.Exists("Assets/_Test/" + material.name.Replace(" (Instance)", "") + ".mat"))
                    {
                        AssetDatabase.CreateAsset(material, "Assets/_Test/" + material.name.Replace(" (Instance)", "") + ".mat");
                    }

                    if (material.mainTexture != null)
                    {
                        Texture2D t = (Texture2D)material.mainTexture;
//						t = (Texture2D) Texture2D.Instantiate(t);
//						Texture2D newTexture2D = ne
//						newTexture2D.SetPixels32(t.GetPixels32());
//						newTexture2D.Apply();
                        //						var bytes = newTexture2D.EncodeToPNG();
//						AssetDatabase.CreateAsset(t, "Assets/_Test/" + t.name + "png.asset");
//						File.WriteAllBytes("Assets/_Test/" + material.mainTexture.name + ".png", bytes);

                        Shader shader = Shader.Find("Sprites/Default");
                        SaveRenderTextureToPNG(t, shader, "Assets/_Test/", t.name.Replace(" (Instance)", ""));
                    }
                }
            }



            Animation[] animations = go.GetComponentsInChildren <Animation>();
            foreach (Animation animation in animations)
            {
                foreach (AnimationState state in animation)
                {
                    if (state != null && state.clip != null)
                    {
                        AnimationClip clip = (AnimationClip)AnimationClip.Instantiate(state.clip);
                        if (!File.Exists("Assets/_Test/" + clip.name.Replace("(Clone)", "") + ".anim"))
                        {
                            AssetDatabase.CreateAsset(clip, "Assets/_Test/" + clip.name.Replace("(Clone)", "") + ".anim");
                        }
                    }
                }
            }



            SpriteRenderer[] spriteRenderers = go.GetComponentsInChildren <SpriteRenderer>();
            foreach (SpriteRenderer spriteRenderer in spriteRenderers)
            {
                if (spriteRenderer.sprite != null)
                {
                    Shader    shader = Shader.Find("Sprites/Default");
                    Texture2D t      = (Texture2D)spriteRenderer.sprite.texture;
                    SaveRenderTextureToPNG(t, shader, "Assets/_Test/", t.name.Replace(" (Instance)", ""));
                    string path = "Assets/_Test/" + t.name.Replace(" (Instance)", "") + ".png";

                    ImportAssetOptions options = ImportAssetOptions.Default;
                    AssetDatabase.ImportAsset(path);
                    TextureImporter importer = (TextureImporter)TextureImporter.GetAtPath(path);
                    importer.textureType = TextureImporterType.Sprite;

                    TextureImporterSettings tis = new TextureImporterSettings();
                    importer.ReadTextureSettings(tis);
                    tis.ApplyTextureType(TextureImporterType.Sprite, false);
                    importer.SetTextureSettings(tis);
                    AssetDatabase.ImportAsset(path);
                }
            }
        }
예제 #18
0
        public static void ImportAsset(string path)
        {
            ImportAssetOptions options = ImportAssetOptions.Default;

            AssetDatabase.ImportAsset(path, options);
        }
예제 #19
0
 public static extern void ImportAsset(string path, [DefaultValue("ImportAssetOptions.Default")] ImportAssetOptions options);
예제 #20
0
        public static void Refresh()
        {
            ImportAssetOptions options = ImportAssetOptions.Default;

            AssetDatabase.Refresh(options);
        }
예제 #21
0
 public static extern void Refresh([DefaultValue("ImportAssetOptions.Default")] ImportAssetOptions options);
예제 #22
0
 public static void RefreshDelayed(ImportAssetOptions options)
 {
 }
예제 #23
0
 //  再インポート(強制インポート)
 public void Reimport(ImportAssetOptions options = ImportAssetOptions.Default)
 {
     AssetDatabase.ImportAsset(AssetPath, options);
 }
예제 #24
0
파일: SPTools.cs 프로젝트: penspanic/Mawang
 /// <summary>
 /// Does asset reimport.
 /// </summary>
 /// <param name="path">Path.</param>
 /// <param name="options">Options.</param>
 public static void DoAssetReimport(string path, ImportAssetOptions options)
 {
     try
     {
         AssetDatabase.StartAssetEditing();
         AssetDatabase.ImportAsset(path, options);
     }
     finally
     {
         AssetDatabase.StopAssetEditing();
     }
 }
예제 #25
0
 public void ImportAsset(ImportAssetOptions Options)
 {
     AssetDatabase.ImportAsset(path, Options);
 }
예제 #26
0
            public void ImportAsset(string fullPath, ImportAssetOptions options = ImportAssetOptions.Default)
            {
                string assetPath = ABConverter.PathUtils.FullPathToAssetPath(fullPath);

                UnityEditor.AssetDatabase.ImportAsset(assetPath, options);
            }
예제 #27
0
        // Returns true if files were updated
        public static bool CheckForUpdates(bool bForce = false, bool bFromMenu = false, bool bSynchronous = false)
        {
            HelperDelegates.IgorJobConfig_SetWasMenuTriggered(bFromMenu);

            if (CheckForOneTimeForcedUpgrade())
            {
                MoveConfigsFromOldLocation();

                bForce = true;
            }

            if (!bDontUpdate || bForce)
            {
                UpdatedContent.Clear();

                bool bMajorUpgrade = false;

                if (!HelperDelegates.bIsValid)
                {
                    UpdateCore();

                    bMajorUpgrade = true;
                }

                bool bNeedsRebuild = bMajorUpgrade || SelfUpdate(out bMajorUpgrade);

                bNeedsRebuild = bMajorUpgrade || UpdateCore() || bNeedsRebuild;
                bNeedsRebuild = bMajorUpgrade || UpdateModules() || bNeedsRebuild;

                if (CheckForOneTimeForcedUpgrade())
                {
                    RemoveOldDirectory();

                    bNeedsRebuild = true;
                }

                if (bNeedsRebuild)
                {
                    HelperDelegates.IgorJobConfig_SetBoolParam("restartingfromupdate", true);

                    string UpdatedContentString = "The following Igor content was ";

                    if (bAlwaysUpdate)
                    {
                        UpdatedContentString += "forcibly ";
                    }

                    UpdatedContentString += "updated via ";

                    if (bLocalDownload)
                    {
                        UpdatedContentString += "local copy from " + LocalPrefix;
                    }
                    else
                    {
                        UpdatedContentString += "remote copy from GitHub";
                    }

                    UpdatedContentString += ", refreshing AssetDatabase:\n";

                    foreach (var content in UpdatedContent)
                    {
                        UpdatedContentString += content + "\n";
                    }

                    Debug.Log("Igor Log: " + UpdatedContentString);

                    ImportAssetOptions options = bSynchronous ? ImportAssetOptions.ForceSynchronousImport : ImportAssetOptions.Default;
                    AssetDatabase.Refresh(options);
                }

                return(bNeedsRebuild);
            }

            return(false);
        }
예제 #28
0
 public void Refresh(ImportAssetOptions options = ImportAssetOptions.Default)
 {
     UnityEditor.AssetDatabase.Refresh(options);
 }