public void LoadScriptableSingleton()
        {
            DerivedClassA a;

            a = ScriptableSingleton.GetInstance <DerivedClassA>();

            Assert.IsNotNull(a);
        }
        public void EditScriptableSingleton()
        {
            DerivedClassA a;

            a = ScriptableSingleton.GetInstance <DerivedClassA>();

            string randomstring = Generate.String(20);

            a.Test = randomstring;

            AssetDatabase.SaveAssets();

            a = ScriptableSingleton.GetInstance <DerivedClassA>();

            Assert.AreEqual(a.Test, randomstring);
        }
Ejemplo n.º 3
0
        public static bool ConvertAsset(string dir, string filter, string save_dir)
        {
            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }
            string[] strList = Directory.GetFiles(dir, filter, SearchOption.TopDirectoryOnly);
            for (int i = 0; i < strList.Length; ++i)
            {
                var txtPath = strList[i];
                var name    = Path.GetFileNameWithoutExtension(txtPath);
                try
                {
                    var         assetPath = save_dir + name + ".asset";
                    AssetBinary asset     = ScriptableSingleton <AssetBinary> .CreateInstance <AssetBinary>();

                    asset.m_DataBytes = File.ReadAllBytes(txtPath);

                    if (File.Exists(assetPath))
                    {
                        AssetBinary oldAsset = AssetDatabase.LoadAssetAtPath <AssetBinary>(assetPath);
                        oldAsset.m_DataBytes = asset.m_DataBytes;
                        EditorUtility.SetDirty(oldAsset);
                        AssetDatabase.SaveAssets();
                    }
                    else
                    {
                        AssetDatabase.CreateAsset(asset, assetPath);
                    }
                    Debug.LogFormat("<color=#00ff00>convert <color=#ffff00>{0}.asset</color> succeed !</color>", name);
                }
                catch (System.Exception e)
                {
                    Debug.LogErrorFormat(e.ToString());
                    Debug.LogErrorFormat("<color=#ff0000>convert <color=#ffff00>{0}.asset</color> failed !</color>", name);
                    return(false);
                }
            }
            return(true);
        }
 public void DeleteScriptableSingleton()
 {
     ScriptableSingleton.UnRegisterPath <DerivedClassA>();
     Assert.IsTrue(true);
 }