diff --git a/Assets/Fungus/Prefabs/Game.prefab b/Assets/Fungus/Prefabs/Game.prefab index 03ee0d00..def640b4 100644 Binary files a/Assets/Fungus/Prefabs/Game.prefab and b/Assets/Fungus/Prefabs/Game.prefab differ diff --git a/Assets/Fungus/Prefabs/PageStyle(NoBox).prefab b/Assets/Fungus/Prefabs/PageStyle(NoBox).prefab new file mode 100644 index 00000000..233e040c Binary files /dev/null and b/Assets/Fungus/Prefabs/PageStyle(NoBox).prefab differ diff --git a/Assets/Fungus/Prefabs/PageStyle(NoBox).prefab.meta b/Assets/Fungus/Prefabs/PageStyle(NoBox).prefab.meta new file mode 100644 index 00000000..2f58e00c --- /dev/null +++ b/Assets/Fungus/Prefabs/PageStyle(NoBox).prefab.meta @@ -0,0 +1,4 @@ +fileFormatVersion: 2 +guid: 25812898d7e74407b94d0216027d5876 +NativeFormatImporter: + userData: diff --git a/Assets/Fungus/Prefabs/PageStyle.prefab b/Assets/Fungus/Prefabs/PageStyle.prefab new file mode 100644 index 00000000..631331ae Binary files /dev/null and b/Assets/Fungus/Prefabs/PageStyle.prefab differ diff --git a/Assets/Fungus/Prefabs/PageStyle.prefab.meta b/Assets/Fungus/Prefabs/PageStyle.prefab.meta new file mode 100644 index 00000000..282a55af --- /dev/null +++ b/Assets/Fungus/Prefabs/PageStyle.prefab.meta @@ -0,0 +1,4 @@ +fileFormatVersion: 2 +guid: cdd7a3dba1d864bb78106f6d917a70ae +NativeFormatImporter: + userData: diff --git a/Assets/Fungus/Scripts/Commands.cs b/Assets/Fungus/Scripts/Commands.cs index c5a58fbe..7b05475b 100644 --- a/Assets/Fungus/Scripts/Commands.cs +++ b/Assets/Fungus/Scripts/Commands.cs @@ -124,6 +124,28 @@ namespace Fungus } } + /** + * Sets the currently active Page Style for rendering Pages. + */ + public class SetPageStyleCommand : CommandQueue.Command + { + PageStyle pageStyle; + + public SetPageStyleCommand(PageStyle _pageStyle) + { + pageStyle = _pageStyle; + } + + public override void Execute(CommandQueue commandQueue, Action onComplete) + { + Game.GetInstance().activePageStyle = pageStyle; + if (onComplete != null) + { + onComplete(); + } + } + } + /** * Sets the title text displayed at the top of the active page. */ diff --git a/Assets/Fungus/Scripts/Game.cs b/Assets/Fungus/Scripts/Game.cs index d3e5cef4..793565b4 100644 --- a/Assets/Fungus/Scripts/Game.cs +++ b/Assets/Fungus/Scripts/Game.cs @@ -27,6 +27,11 @@ namespace Fungus */ public Room activeRoom; + /** + * The style to apply when displaying Pages. + */ + public PageStyle activePageStyle; + /** * Automatically display links between connected Rooms. */ @@ -96,6 +101,13 @@ namespace Fungus commandQueue = gameObject.AddComponent(); cameraController = gameObject.AddComponent(); + AudioSource audioSource = gameObject.AddComponent(); + audioSource.playOnAwake = false; + audioSource.loop = true; + + // Create a default page style if none exists + + if (activeRoom == null) { // Pick first room found if none is specified diff --git a/Assets/Fungus/Scripts/GameController.cs b/Assets/Fungus/Scripts/GameController.cs index 0b7892b7..ba655e27 100644 --- a/Assets/Fungus/Scripts/GameController.cs +++ b/Assets/Fungus/Scripts/GameController.cs @@ -104,18 +104,6 @@ namespace Fungus #endregion #region Page Methods - - /** - * Sets the title text displayed at the top of the active Page. - * The title text is only displayed when there is some story text or options to be shown. - * This method returns immediately but it queues an asynchronous command for later execution. - * @param titleText The text to display as the title of the Page. - */ - public void Title(string titleText) - { - CommandQueue commandQueue = Game.GetInstance().commandQueue; - commandQueue.AddCommand(new TitleCommand(titleText)); - } /** * Sets the currently active Page for story text display. @@ -129,7 +117,31 @@ namespace Fungus CommandQueue commandQueue = Game.GetInstance().commandQueue; commandQueue.AddCommand(new SetPageCommand(page)); } - + + /** + * Sets the currently active style for displaying Pages. + * Once this command executes, all Pages will display using the new style. + * This method returns immediately but it queues an asynchronous command for later execution. + * @param pageStyle The style object to make active + */ + public void SetPageStyle(PageStyle pageStyle) + { + CommandQueue commandQueue = Game.GetInstance().commandQueue; + commandQueue.AddCommand(new SetPageStyleCommand(pageStyle)); + } + + /** + * Sets the title text displayed at the top of the active Page. + * The title text is only displayed when there is some story text or options to be shown. + * This method returns immediately but it queues an asynchronous command for later execution. + * @param titleText The text to display as the title of the Page. + */ + public void Title(string titleText) + { + CommandQueue commandQueue = Game.GetInstance().commandQueue; + commandQueue.AddCommand(new TitleCommand(titleText)); + } + /** * Writes story text to the currently active Page. * A 'continue' button is displayed when the text has fully appeared. diff --git a/Assets/Fungus/Scripts/Page.cs b/Assets/Fungus/Scripts/Page.cs index 47fadc2d..f71c575c 100644 --- a/Assets/Fungus/Scripts/Page.cs +++ b/Assets/Fungus/Scripts/Page.cs @@ -14,19 +14,9 @@ namespace Fungus [ExecuteInEditMode] public class Page : MonoBehaviour { + /// Rectangular bounds used to display page text public Bounds pageBounds = new Bounds(Vector3.zero, new Vector3(0.25f, 0.25f, 0f)); - // The font size for title, say and option text is calculated by multiplying the screen height - // by the corresponding font scale. Text appears the same size across all device resolutions. - public float titleFontScale = 1f / 20f; - public float sayFontScale = 1f / 25f; - public float optionFontScale = 1f / 25f; - - public GUIStyle titleStyle; - public GUIStyle sayStyle; - public GUIStyle optionStyle; - public GUIStyle boxStyle; - string titleText = ""; string originalStoryText = ""; @@ -57,15 +47,6 @@ namespace Fungus List