예제 #1
0
        internal static KataruSettings Load(bool createIfMissing = false)
        {
            KataruSettings settings = Resources.Load <KataruSettings>(SettingsFile);

            Debug.Log($@"KataruSettings.Load(SettingsFile: '{SettingsFile}')");
#if UNITY_EDITOR
            if (createIfMissing && settings == null)
            {
                Debug.LogWarning($"Could not find settings at '{SettingsFile}', creating defaults...");
                if (!Directory.Exists(SettingsDirectory))
                {
                    Directory.CreateDirectory(SettingsDirectory);
                }

                settings              = ScriptableObject.CreateInstance <KataruSettings>();
                settings.storyPath    = "Kataru/Editor/Story";
                settings.bookmarkPath = "Kataru/Bookmark.yml";
                settings.targetPath   = "Kataru/story.bin";
                settings.savePath     = "Kataru/bookmark.bin";
                settings.codegenPath  = "Assets/Scripts/Kataru/Constants.Generated.cs";
                AssetDatabase.CreateAsset(settings, SettingsDirectory + "/Resources/" + SettingsFile);
                AssetDatabase.SaveAssets();
            }
#endif
            return(settings);
        }
예제 #2
0
        /// <summary>
        /// Initialize the story, bookmark and internal runner.
        /// This method should only be called once.
        /// </summary>
        public static void Init()
        {
            isInitialized = false;
            var settings = KataruSettings.Get(createIfMissing: true);

            targetPath   = Application.streamingAssetsPath + "/" + settings.targetPath;
            bookmarkPath = Application.streamingAssetsPath + "/" + settings.bookmarkPath;
            savePath     = Application.persistentDataPath + "/" + settings.savePath;
            codegenPath  = settings.codegenPath;

            Debug.Log(
                $@"Kataru.Init(StoryPath: '{targetPath}', 
                BookmarkPath: '{bookmarkPath}', 
                SavePath: '{savePath}')");

#if UNITY_EDITOR
            if (!File.Exists(targetPath))
            {
                Debug.LogWarning("Missing target. Retriggering compilation...");
                storyPath = Application.dataPath + "/" + settings.storyPath;

                Compile(storyPath, bookmarkPath, targetPath, codegenPath);
            }
#endif

            isRunning = false;
            isWaiting = false;

            // Only load the story on Init.
            FFI.LoadStory(targetPath);

            isInitialized = true;
        }
예제 #3
0
 public static KataruSettings Get(bool createIfMissing = false)
 {
     if (instance != null)
     {
         return(instance);
     }
     instance = Load(createIfMissing);
     return(instance);
 }
예제 #4
0
        public static SettingsProvider CreateKataruSettingsProvider()
        {
            KataruSettings.Load();
            var provider = new KataruSettingsProvider("Project/Kataru Settings", SettingsScope.Project);

            // Automatically extract all keywords from the Styles.
            provider.keywords = GetSearchKeywordsFromGUIContentProperties <Styles>();
            return(provider);
        }
예제 #5
0
        /// <summary>
        /// The OnAssetsModified method is called whenever an Asset has been changed in the project.
        /// This methods determines if any Preset has been added, removed, or moved
        /// and updates the CustomDependency related to the changed folder.
        /// </summary>
        protected override void OnAssetsModified(string[] changedAssets, string[] addedAssets, string[] deletedAssets, AssetMoveInfo[] movedAssets)
        {
            var settings = KataruSettings.Get();

            if (settings == null)
            {
                return;
            }

            storyPath    = "Assets/" + settings.storyPath;
            bookmarkPath = "Assets/StreamingAssets/" + settings.bookmarkPath;
            targetPath   = "Assets/StreamingAssets/" + settings.targetPath;
            codegenPath  = settings.codegenPath;

            if (!KataruWasModified(changedAssets, addedAssets, deletedAssets, movedAssets))
            {
                return;
            }

            // Run validation
            Runner.Compile(storyPath, bookmarkPath, targetPath, codegenPath);
        }
예제 #6
0
 public override void OnActivate(string searchContext, VisualElement rootElement)
 {
     // This function is called when the user clicks on the MyCustom element in the Settings window.
     serializedSettings = new SerializedObject(KataruSettings.Get(createIfMissing: true));
 }