Example #1
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;
        }
Example #2
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);
        }
Example #3
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));
 }