Exemple #1
0
        internal static void Save(IGroup group)
        {
            var assetPath = GetAssetPath(group.Id);
            var assetNew  = (ScriptableObject)group.Clone();

            AssetUtil.RefreshAssetAtPath(assetNew, assetPath);
        }
Exemple #2
0
        private static void UpdateConstants()
        {
            if (string.IsNullOrEmpty(Constants.DirectoryPathInAssets) ||
                !Directory.Exists(Constants.DirectoryPathInAssets))
            {
                UnityEngine.Debug.Log("Update constants!");

                var stackTrace    = new StackTrace(true);
                var directoryPath = stackTrace.GetFrames()[0].GetFileName()
                                    .Replace(string.Format("{0}.cs", typeof(DefineSymbolnitializer).Name), "");

                UnityEngine.Debug.Log(directoryPath);
                Constants.DirectoryPathInAssets           = AssetUtil.GetAssetPath(directoryPath);
                Constants.AssetDirectoryPathForPresets    = string.Concat(Constants.DirectoryPathInAssets, "Presets/");
                Constants.AbsoluteDirectoryPathForPresets = AssetUtil.GetAbsolutePath(Constants.AssetDirectoryPathForPresets);

                if (!Directory.Exists(Constants.AbsoluteDirectoryPathForPresets))
                {
                    Directory.CreateDirectory(Constants.AbsoluteDirectoryPathForPresets);
                }

                var template  = File.ReadAllText(directoryPath + "ConstantsTemplate.template");
                var constants = template
                                .Replace("{0}", Constants.DirectoryPathInAssets);
                constants = constants
                            .Replace("{1}", Constants.AssetDirectoryPathForPresets);
                constants = constants
                            .Replace("{2}", Constants.AbsoluteDirectoryPathForPresets);

                UnityEngine.Debug.Log("Constants was updated");

                File.WriteAllText(directoryPath + "Constants.cs", constants);
                AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);
            }
        }
Exemple #3
0
        private static List <T> LoadAllPresetsAtFolder <T>() where T : ScriptableObject, IGroup
        {
            var assets = AssetUtil.LoadAllAssetsAtPresetsFolder <T>("*.asset");

            var list = new List <T>();

            foreach (var asset in assets)
            {
                list.Add((T)asset.Clone());
            }

            return(list);
        }