Beispiel #1
0
        private static void CreateAssetLibrary()
        {
            AssetLibraryAsset asset = ScriptableObject.CreateInstance <AssetLibraryAsset>();

            int identity = AssetLibrariesListGen.GetIdentity();

            asset.Ordinal = identity;

            string path             = AssetDatabase.GetAssetPath(Selection.activeObject);
            string name             = "/AssetLibrary" + ((identity == 0) ? "" : identity.ToString());
            string assetPathAndName = AssetDatabase.GenerateUniqueAssetPath(path + name + ".asset");


            asset.AssetLibrary.Folders[1].Assets = new List <AssetInfo>
            {
                new AssetInfo
                {
                    id     = 1,
                    name   = "Material",
                    Object = AssetDatabase.LoadAssetAtPath <Material>("Assets/New Material.mat")
                }
            };


            AssetDatabase.CreateAsset(asset, assetPathAndName);
            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();

            Selection.activeObject = asset;

            AssetLibrariesListGen.UpdateList(identity + 1);
        }
Beispiel #2
0
 private void OnValidate()
 {
     if (Event.current != null && Event.current.commandName == "Duplicate")
     {
         int identity = AssetLibrariesListGen.GetIdentity();
         Ordinal = identity;
         EditorCoroutine.Start(CoUpdateList(identity));
     }
 }
        private static void CreateAssetLibrary()
        {
            AssetLibraryAsset asset = ScriptableObject.CreateInstance <AssetLibraryAsset>();

            int identity = AssetLibrariesListGen.GetIdentity();

            asset.Ordinal = identity;

            string path             = AssetDatabase.GetAssetPath(Selection.activeObject);
            string name             = "/AssetLibrary" + ((identity == 0) ? "" : identity.ToString());
            string assetPathAndName = AssetDatabase.GenerateUniqueAssetPath(path + name + ".asset");

            AssetDatabase.CreateAsset(asset, assetPathAndName);
            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();

            //Selection.activeObject = asset;

            AssetLibrariesListGen.UpdateList(identity + 1);
        }