chrisgregan
11 years ago
21 changed files with 664 additions and 0 deletions
@ -0,0 +1,5 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 0e618b0f068f34d8b961e88006dec084 |
||||
folderAsset: yes |
||||
DefaultImporter: |
||||
userData: |
@ -0,0 +1,10 @@
|
||||
Main Page {#mainpage} |
||||
========= |
||||
|
||||
Fungus is an open source library for Unity 3D for creating interactive fiction / visual novel style games. It has been designed to be easy to use and customize, and is a useful tool for people learning to make games in Unity 3D for the first time. |
||||
|
||||
It was created and is maintained by Chris Gregan from [Snozbot.com](http://www.snozbot.com/). |
||||
|
||||
- See the [GameController](@ref Fungus.GameController) class for a full list of supported commands. |
||||
- See http://www.snozbot.com/fungus for more information about the Fungus project. |
||||
|
@ -0,0 +1,4 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 2bcd0aa5f547d4dc2bcc89ac1c935544 |
||||
DefaultImporter: |
||||
userData: |
@ -0,0 +1,30 @@
|
||||
|
||||
The Game Component |
||||
=================== |
||||
|
||||
The [Game](@ref Fungus.Game) class is the main controller component for every Fungus game. |
||||
- It is a singleton class, so there can be only one instance of it in any Unity scene. |
||||
- It can be accessed anywhere in your code using [Game.GetInstance()](@ref Fungus.Game.GetInstance). |
||||
|
||||
The main responsibility of the [Game](@ref Fungus.Game) class is to keep track of the current game state. This includes: |
||||
- Currently active Room object |
||||
- Currently active Page object |
||||
- Currently active PageStyle object |
||||
- Gameplay state values (e.g. inventory items) |
||||
|
||||
This class also manages global configuration parameters such as text writing speed, transition time between rooms, etc. |
||||
|
||||
- - - |
||||
|
||||
# Where can I find a full list of supported commands? |
||||
|
||||
- See the [GameController](@ref Fungus.GameController) class for a full list of available commands. |
||||
|
||||
- - - |
||||
|
||||
# How do I add a Game object to my scene? |
||||
|
||||
1. Create an instance of Fungus/Prefabs/Game.prefab. |
||||
2. When you add a Room to the scene, set the [Game.activeRoom](@ref Fungus.Game.activeRoom) property to use it as the starting Room. |
||||
|
||||
If no activeRoom is set then Fungus will start in an idle state. |
@ -0,0 +1,4 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 05e33a9c6e4644f73b551e2aed7ca80a |
||||
DefaultImporter: |
||||
userData: |
@ -0,0 +1,97 @@
|
||||
Using Rooms |
||||
=========== |
||||
|
||||
A [Room](@ref Fungus.Room) is a Game Object that contains a script that inherits from the [Room class](@ref Fungus.Room). Rooms are the main unit of organization in a Fungus game. They are similar to locations in a point and click adventure game. |
||||
|
||||
Rooms may be connected to each other via public Room properties. Connected Rooms are automatically shown in the Unity scene view via a connecting arrow. |
||||
Rooms may contain [Views](@ref Fungus.View), [Pages](@ref Fungus.Page), Sprites, [Buttons](@ref Fungus.Button) and any other type of Game Object required to construct the location. |
||||
|
||||
- - - |
||||
|
||||
# How do I add a Room to a scene? |
||||
|
||||
Note: Every Room in a Fungus game must have an attached script component which inherits from the [Room class](@ref Fungus.Room). This script controls all Fungus related behavior for that Room. |
||||
|
||||
1. Create an instance of the Fungus/Prefabs/Room.prefab in the Fungus library. This creates a standard Room, but with no Room script attached yet. |
||||
2. Create a new c# script in your project folder. Give it the same name as your Room. |
||||
3. Add a `using Fungus;` declaration at the top of the script to allow easy access to the Fungus library. |
||||
4. Add a `void OnEnter()` method. This will be called every time the player enters the room. |
||||
|
||||
## C# Code Example |
||||
|
||||
~~~~~~~~~~~~~~~~~~~~ |
||||
using UnityEngine; |
||||
using System.Collections; |
||||
using Fungus; |
||||
|
||||
public class MyRoom : Room |
||||
{ |
||||
void OnEnter() |
||||
{ |
||||
Say("Hello world!"); |
||||
} |
||||
} |
||||
~~~~~~~~~~~~~~~~~~~~ |
||||
|
||||
## Notes |
||||
- The default start() and update() methods are not typically used in Fungus games. Feel free to delete them. |
||||
- A documented example Room script is provided in Fungus/Scripts/RoomTemplate.cs in the Fungus library. |
||||
|
||||
- - - |
||||
|
||||
# How do I move between Rooms? |
||||
|
||||
1. Ensure there are at least two Room objects in your scene. |
||||
2. Add a public Room property to your Room script and setup the reference to the other Room in the inspector. |
||||
3. Use the [MoveToRoom](@ref Fungus.GameController.MoveToRoom) command to transition to the other Room. |
||||
|
||||
## C# code example |
||||
~~~~~~~~~~~~~~~~~~~~ |
||||
using UnityEngine; |
||||
using System.Collections; |
||||
using Fungus; |
||||
|
||||
public class MyRoom : Room |
||||
{ |
||||
public Room otherRoom; // Another Room |
||||
|
||||
void OnEnter() |
||||
{ |
||||
Wait(5); |
||||
MoveToRoom(otherRoom); // Current Room fades out, new Room fades in |
||||
} |
||||
} |
||||
~~~~~~~~~~~~~~~~~~~~ |
||||
|
||||
## Notes |
||||
- Use [Game.RoomFadeDuration](@ref Fungus.Game.roomFadeDuration) to control the fade transition time. |
||||
|
||||
- - - |
||||
|
||||
# How do I check if a Room has already been Visited? |
||||
|
||||
The [Room.visitCount](@ref Fungus.Room.visitCount) property tracks how many times the player has entered a Room. |
||||
|
||||
Use the [Room.IsFirstVisit](@ref Fungus.Room.IsFirstVisit) method to check if this is the first visit to the Room. |
||||
|
||||
## C# Code Example |
||||
~~~~~~~~~~~~~~~~~~~~ |
||||
using UnityEngine; |
||||
using System.Collections; |
||||
using Fungus; |
||||
|
||||
public class MyRoom : Room |
||||
{ |
||||
void OnEnter() |
||||
{ |
||||
if (IsFirstVisit()) |
||||
{ |
||||
Say("Welcome to the room stranger!"); |
||||
} |
||||
else |
||||
{ |
||||
Say("Nice to have you back!"); |
||||
} |
||||
} |
||||
} |
||||
~~~~~~~~~~~~~~~~~~~~ |
@ -0,0 +1,4 @@
|
||||
fileFormatVersion: 2 |
||||
guid: bcaf0762b10fd4c8d9e4cadc455adb8b |
||||
DefaultImporter: |
||||
userData: |
@ -0,0 +1,154 @@
|
||||
Writing Story Text With Pages |
||||
============================= |
||||
|
||||
The [Page](@ref Fungus.Page) component defines an area where the story textbox will appear on screen. |
||||
- A Page can display title text, say text and a list of options. |
||||
- Only one page is ever active at a time. |
||||
- The active Page automatically hides when there is no remaining story text or options to display. |
||||
|
||||
# How do I add a Page to a Room? |
||||
|
||||
1. Create an instance of Fungus/Prefabs/Page.prefab and make it a child of the View which it should appear inside. |
||||
2. Resize and position the Page as desired. |
||||
|
||||
- - - |
||||
|
||||
# How do I control which Page is used to display text? |
||||
|
||||
1. Ensure there are at least two Page objects in your Room. |
||||
2. Add public Page properties to your Room script and setup references to each Page in the Room. |
||||
3. Use the [SetPage](@ref Fungus.GameController.SetPage) command to control which Page will be used for text rendering. |
||||
|
||||
## C# code example |
||||
~~~~~~~~~~~~~~~~~~~~ |
||||
using UnityEngine; |
||||
using System.Collections; |
||||
using Fungus; |
||||
|
||||
public class MyRoom : Room |
||||
{ |
||||
public Page leftPage; // A Page on the left hand side of the Room |
||||
public Page rightPage; // A Page on the right hand side of the Room |
||||
|
||||
void OnEnter() |
||||
{ |
||||
SetPage(leftPage); |
||||
Say("This text will now display on the left page"); |
||||
SetPage(rightPage); |
||||
Say("This text will now display on the right page"); |
||||
} |
||||
} |
||||
~~~~~~~~~~~~~~~~~~~~ |
||||
|
||||
## Notes |
||||
- If there is only one Page in a Room, Fungus will automatically make this the active Page when entering the Room. |
||||
- If a View has a child Page object, Fungus will automatically make this the active Page after transitioning to that View (e.g. via [SetView](@ref Fungus.GameController.SetView))). |
||||
- If you find that text is not rendering on the Page you expect, you probably need to set the active Page explicitly using the method shown above. |
||||
|
||||
- - - |
||||
|
||||
# How do I write story text to the active Page? |
||||
|
||||
1. Use the [Title](@ref Fungus.GameController.Title) command to set the title text to be displayed at the top of the active page. |
||||
2. Use the [Say](@ref Fungus.GameController.Say) command to display a single line of story text and then wait for the player to press the continue button. |
||||
|
||||
## C# code example |
||||
~~~~~~~~~~~~~~~~~~~~ |
||||
using UnityEngine; |
||||
using System.Collections; |
||||
using Fungus; |
||||
|
||||
public class MyRoom : Room |
||||
{ |
||||
void OnEnter() |
||||
{ |
||||
Title("The Title"); // Sets the title text |
||||
Say("Hello"); // Writes the story text and waits for player to continue |
||||
} |
||||
} |
||||
~~~~~~~~~~~~~~~~~~~~ |
||||
|
||||
## Notes |
||||
- The [Page](@ref Fungus.Page) component defines the area where the story textbox will appear on screen. |
||||
- A Page can display title text, say text and a list of options. |
||||
- Only one Page is ever active at a time. |
||||
- The active Page automatically hides when there is no remaining story text or options to display. |
||||
- The appearance of the title and say text in the Page is controlled via the active [PageStyle](@ref Fungus.PageStyle) object. |
||||
|
||||
- - - |
||||
|
||||
# How do I create a multiple choice menu on the active Page? |
||||
|
||||
- Use the [AddOption](@ref Fungus.GameController.AddOption) command to add an option to the current options list. |
||||
- Use the [Choose](@ref Fungus.GameController.AddOption) command to display the current list of options and wait for the player to select an option. |
||||
|
||||
## C# code example |
||||
~~~~~~~~~~~~~~~~~~~~ |
||||
using UnityEngine; |
||||
using System.Collections; |
||||
using Fungus; |
||||
|
||||
public class MyRoom : Room |
||||
{ |
||||
void OnEnter() |
||||
{ |
||||
AddOption("Option 1", DoOption1); |
||||
AddOption("Option 2", DoOption2); |
||||
Choose("Pick an option"); |
||||
} |
||||
|
||||
// Delegate method for option 1 |
||||
void DoOption1() |
||||
{ |
||||
Say("Picked option 1"); |
||||
} |
||||
|
||||
// Delegate method for option 2 |
||||
void DoOption2() |
||||
{ |
||||
Say("Picked option 2"); |
||||
} |
||||
} |
||||
~~~~~~~~~~~~~~~~~~~~ |
||||
|
||||
## Notes |
||||
- The [AddOption](@ref Fungus.GameController.AddOption) command takes an optional delegate method to call when the player selects the option. |
||||
- If no delegate method is provided, the menu is dismissed and the next command in the queue is executed. |
||||
- The appearance of the option button is controlled via the active [PageStyle](@ref Fungus.PageStyle) object. |
||||
|
||||
- - - |
||||
|
||||
# How do I control the appearance of Page text? |
||||
|
||||
1. Find Fungus/Prefabs/PageStyle1.prefab in the Fungus library |
||||
2. Duplicate and rename this file (e.g. MyPageStyle.prefab) |
||||
3. Modify the style settings in the prefab to adjust the appearance. |
||||
4. Add a public PageStyle property to your Room script and setup a reference to your PageStyle prefab in the inspector. |
||||
5. Use the [SetPageStyle](@ref Fungus.GameController.SetPage) command to change the style used to render Pages. |
||||
|
||||
## C# code example |
||||
~~~~~~~~~~~~~~~~~~~~ |
||||
using UnityEngine; |
||||
using System.Collections; |
||||
using Fungus; |
||||
|
||||
public class MyRoom : Room |
||||
{ |
||||
public PageStyle myPageStyle; // Reference to a custom PageStyle prefab |
||||
|
||||
void OnEnter() |
||||
{ |
||||
Say("This text will display using the default PageStyle"); |
||||
SetPageStyle(myPageStyle); |
||||
Say("This text will now display using the custom PageStyle"); |
||||
} |
||||
} |
||||
~~~~~~~~~~~~~~~~~~~~ |
||||
|
||||
## Notes |
||||
|
||||
- PageStyle uses standard Unity GUIStyle properties to control the appearance of the text and box background. |
||||
- You can easily change font, text color, bold, italic, etc. for each type of text. |
||||
- Modify the texture and settings in the boxStyle to change the appearance of the background box. |
||||
- Fungus overrides the font size properties for text to ensure consistent text scaling across devices with varying resolutions. |
||||
- Use the xxxFontScale properties to specify font size as a fraction of screen height. |
@ -0,0 +1,4 @@
|
||||
fileFormatVersion: 2 |
||||
guid: e9255c3d0ca1a4a8f86da27ba223db65 |
||||
DefaultImporter: |
||||
userData: |
@ -0,0 +1,64 @@
|
||||
Controlling the Camera with Views |
||||
================================= |
||||
|
||||
The [View](@ref Fungus.View) component specifies a single camera position. You can add multiple Views in a Fungus room and perform transitions between those Views to move the camera around the Room. |
||||
|
||||
# How do I add a View to a Room? |
||||
|
||||
1. Create an instance of Fungus/Prefabs/View.prefab and make it a child of the Room. |
||||
2. Resize and position the Room as desired. |
||||
|
||||
- - - |
||||
|
||||
# How do I move the camera using Views? |
||||
|
||||
1. Add a public View property to your Room script and setup a reference to your View object in the inspector. |
||||
2. Use the [SetView](@ref Fungus.GameController.SetView) command to instantly move the camera to a different View. |
||||
3. Use the [PanToView](@ref Fungus.GameController.SetView) command to move the camera towards a different View over a period of time. |
||||
4. Use the [FadeToView](@ref Fungus.GameController.SetView) command to fade out and then fade in again using a different View. |
||||
|
||||
## C# Code Example |
||||
~~~~~~~~~~~~~~~~~~~~ |
||||
using UnityEngine; |
||||
using System.Collections; |
||||
using Fungus; |
||||
|
||||
public class MyRoom : Room |
||||
{ |
||||
public View farView; // Zoomed out view |
||||
public View closeView; // Zoomed in view |
||||
|
||||
void OnEnter() |
||||
{ |
||||
SetView(farView); // Camera moves instantly to this View |
||||
PanToView(closeView, 2f); // Zoom in to the close up view over 2 seconds |
||||
FadeToView(farView, 2f); // Fade out and then fade in to the original view over 2 seconds |
||||
} |
||||
} |
||||
~~~~~~~~~~~~~~~~~~~~ |
||||
|
||||
## Notes |
||||
- The [View](@ref Fungus.View) component specifies a single camera position and orthographic size. |
||||
- Fungus automatically modifies the position and size of the camera when changing Rooms and transitioning between Views. |
||||
- You can add multiple Views in a Fungus room and perform transitions between those Views to move the camera around the Room. |
||||
- When a transition to a new View completes, Fungus looks for a Page object that is a child of that View. The child Page then utomatically becomes the active Page. |
||||
- View transitions cause the command queue to pause until the transition has completed. |
||||
- The View class currently only supports the Orthographic mode for Unity's Camera component. |
||||
|
||||
- - - |
||||
|
||||
# How do I safely support multiple aspect ratios? |
||||
|
||||
A common problem in games development is ensuring that graphics are correctly positioned on devices with widely varying resolutions and aspect ratios. The View component helps solve this by drawing colored rectangles which provide a quick visual preview of how the game will appear under different aspect ratios. This simple technique quickly highlights art layout issues, thus saving on testing effort. |
||||
|
||||
- The inner rectangle shows the minimum supported aspect ratio. The default is 4:3 (e.g. iPad) |
||||
- The outer rectangle shows the maximum supported aspect ratio. The default is 2:1 (e.g. Surface Pro) |
||||
|
||||
Follow these two simple rules to ensure correct and safe artwork layout. |
||||
1. The max aspect ratio box should be fully covered with artwork (i.e. no empty space at edges of box). |
||||
2. All interactive elements (e.g. Pages and Buttons) must be fully contained within the min aspect ratio box. |
||||
|
||||
Failure to comply with rule 2 may cause some interactive elements to appear off-screen on devices with smaller aspect ratios. |
||||
|
||||
## Notes |
||||
- The min/max aspect ratios and colors can be configured to preview any aspect ratio required. |
@ -0,0 +1,4 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 430b685fda63f4d3db12b0cbd5feddbf |
||||
DefaultImporter: |
||||
userData: |
@ -0,0 +1,41 @@
|
||||
Using Audio |
||||
=========== |
||||
|
||||
# How do I play music & sound effects? |
||||
|
||||
1. Add an audio asset to your Unity project (e.g. MP3, WAV file). |
||||
2. Add a public AudioClip property to your Room script and setup the reference to the audio asset in the inspector. |
||||
3. Use the [PlayMusic](@ref Fungus.GameController.PlayMusic) command to start music playing. |
||||
4. Use the [StopMusic](@ref Fungus.GameController.StopMusic) command to stop music playing. |
||||
5. Use [SetMusicVolume](@ref Fungus.GameController.SetMusicVolume) to set the music volume level. |
||||
6. Use [PlaySound](@ref Fungus.GameController.PlaySound) to play a one-off sound effect. |
||||
|
||||
## C# code example |
||||
~~~~~~~~~~~~~~~~~~~~ |
||||
using UnityEngine; |
||||
using System.Collections; |
||||
using Fungus; |
||||
|
||||
public class MyRoom : Room |
||||
{ |
||||
public AudioClip musicClip; // A music audio clip |
||||
public AudioClip soundClip; // A sound effect audio clip |
||||
|
||||
void OnEnter() |
||||
{ |
||||
PlayMusic(musicClip); // Start the music |
||||
Wait(5); |
||||
PlaySound(soundClip); // Play a one-off sound effect |
||||
Wait(5); |
||||
SetMusicVolume(0.5f); // Reduce music volume |
||||
Wait(5); |
||||
StopMusic(); // Stop the music |
||||
} |
||||
} |
||||
~~~~~~~~~~~~~~~~~~~~ |
||||
|
||||
## Notes |
||||
- Fungus only provides simple commands for playing AudioClips. |
||||
- For more advanced control over audio you should use the AudioSource component in Unity directly. |
||||
- Uncheck the 3D Sound option for each audio asset in the property inspector. |
||||
- 2D Sounds do not attenuate (grow quieter) with distance from the listener. |
@ -0,0 +1,4 @@
|
||||
fileFormatVersion: 2 |
||||
guid: fdf20a790d88b4f74b035560f3801dde |
||||
DefaultImporter: |
||||
userData: |
@ -0,0 +1,52 @@
|
||||
Using Sprites |
||||
============= |
||||
|
||||
# How do I control sprite visibility? |
||||
|
||||
1. Add a public SpriteRenderer property to your Room script and setup a reference to your SpriteRenderer object in the inspector. |
||||
2. Use the [ShowSprite](@ref Fungus.GameController.ShowSprite) command to make a sprite visible instantly. |
||||
3. Use the [HideSprite](@ref Fungus.GameController.HideSprite) command to make a sprite invisible instantly. |
||||
4. Use the [FadeSprite](@ref Fungus.GameController.FadeSprite) command to fade a sprite in or out over a period of time. |
||||
|
||||
## C# Code Example |
||||
~~~~~~~~~~~~~~~~~~~~ |
||||
using UnityEngine; |
||||
using System.Collections; |
||||
using Fungus; |
||||
|
||||
public class MyRoom : Room |
||||
{ |
||||
public SpriteRenderer mySprite; |
||||
|
||||
void OnEnter() |
||||
{ |
||||
HideSprite(mySprite); // Sets sprite alpha to 0 (invisible) |
||||
Wait(5); |
||||
ShowSprite(mySprite); // Sets sprite alpha to 1 (fully visible) |
||||
Wait(5); |
||||
FadeSprite(mySprite, 0f, 5f); // Fades sprite alpha to 0 over 5 seconds |
||||
} |
||||
} |
||||
~~~~~~~~~~~~~~~~~~~~ |
||||
|
||||
## Notes |
||||
- The [FadeSprite](@ref Fungus.GameController.FadeSprite) command does not pause command execution. This allows for fading multiple sprites simultaneously. |
||||
- Use a [Wait](@ref Fungus.GameController.Wait) command if you need to wait for a sprite fade to finish before continuing. |
||||
|
||||
- - - |
||||
|
||||
# How do I make Buttons? |
||||
|
||||
TODO: Document this! |
||||
|
||||
- - - |
||||
|
||||
# How do I trigger an animation? |
||||
|
||||
TODO: Document this! |
||||
|
||||
- - - |
||||
|
||||
# How do I listen for Animation Events? |
||||
|
||||
TODO: Document this! |
@ -0,0 +1,4 @@
|
||||
fileFormatVersion: 2 |
||||
guid: ff38bd5aa2bef48ab84b40b818c18588 |
||||
DefaultImporter: |
||||
userData: |
@ -0,0 +1,38 @@
|
||||
Inventory Items and Gameplay Flags |
||||
================================== |
||||
|
||||
# How do I manage inventory items and gameplay flags? |
||||
|
||||
1. Use the [SetValue](@ref Fungus.GameController.SetValue) command to record a collected inventory item or gameplay flag. |
||||
2. Use the [GetValue](@ref Fungus.GameController.GetValue) command to check how many items of that type have been set. |
||||
3. Use the [HasValue](@ref Fungus.GameController.HasValue) command to check if any items of that type have been set. |
||||
4. Use the [ClearValue](@ref Fungus.GameController.HasValue) command to reset item count to 0. |
||||
|
||||
## C# code example |
||||
~~~~~~~~~~~~~~~~~~~~ |
||||
using UnityEngine; |
||||
using System.Collections; |
||||
using Fungus; |
||||
|
||||
public class MyRoom : Room |
||||
{ |
||||
void OnEnter() |
||||
{ |
||||
// Inventory example (counting usage) |
||||
SetValue("rock", 2); // Pick up rocks |
||||
if (GetValue("rock") > 0) // Check if player has rocks |
||||
{ |
||||
Say("You have some rocks"); |
||||
} |
||||
SetValue("rock", 0); // Drop rocks |
||||
|
||||
// Gameplay flag example (boolean flag usage) |
||||
SetValue("door_open"); // Sets value to 1 (to indicate True) |
||||
if (HasValue("door_open")) // Checks if value is non-zero (indicates True) |
||||
{ |
||||
Say("The door is open"); |
||||
} |
||||
ClearValue("door_open"); // Sets value to 0 (to indicate False) |
||||
} |
||||
} |
||||
~~~~~~~~~~~~~~~~~~~~ |
@ -0,0 +1,4 @@
|
||||
fileFormatVersion: 2 |
||||
guid: f84926ad15b0a4fc3856b5e1f60dadef |
||||
DefaultImporter: |
||||
userData: |
@ -0,0 +1,93 @@
|
||||
Using the Command Queue |
||||
======================= |
||||
|
||||
# How do I wait between commands? |
||||
|
||||
- To wait for a period of time, use the [Wait](@ref Fungus.GameController.Wait) command. |
||||
- To wait for the player to tap or click, use the [WaitForInput](@ref Fungus.GameController.WaitForInput) command. |
||||
|
||||
## C# code example |
||||
~~~~~~~~~~~~~~~~~~~~ |
||||
using UnityEngine; |
||||
using System.Collections; |
||||
using Fungus; |
||||
|
||||
public class MyRoom : Room |
||||
{ |
||||
void OnEnter() |
||||
{ |
||||
Say("Hello"); |
||||
Wait(5); // Wait for 5 seconds |
||||
Say("World"); |
||||
WaitForInput(); // Wait for player to tap / click |
||||
Say("Goodbye"); |
||||
} |
||||
} |
||||
~~~~~~~~~~~~~~~~~~~~ |
||||
|
||||
- - - |
||||
|
||||
# How do I execute a method as part of a command sequence? |
||||
|
||||
The [Call](@ref Fungus.GameController.Call) commmand allows you to call a delegate method as part of a command sequence. This allows for code reuse as a you can place a common command sequence into a method and then use the Call command to invoke it from multiple locations in your code. |
||||
|
||||
## C# Code Example |
||||
~~~~~~~~~~~~~~~~~~~~ |
||||
using UnityEngine; |
||||
using System.Collections; |
||||
using Fungus; |
||||
|
||||
public class MyRoom : Room |
||||
{ |
||||
void OnEnter() |
||||
{ |
||||
Call(SayHello); |
||||
Wait(5); |
||||
Call(SayHello); // SayHello is called after a delay of 5 seconds |
||||
} |
||||
|
||||
void SayHello() |
||||
{ |
||||
Say("Hello"); |
||||
} |
||||
|
||||
} |
||||
~~~~~~~~~~~~~~~~~~~~ |
||||
|
||||
- - - |
||||
|
||||
# How do I control when Fungus commands start executing? |
||||
|
||||
It is possible to only use Fungus for certain parts of your game (e.g. for cutscenes). In this scenario we would like to trigger the execution of commands based on an arbitrary gameplay event. To do this, just add your commands to the command queue and then tell it to execute manually. |
||||
|
||||
## C# code example |
||||
~~~~~~~~~~~~~~~~~~~~ |
||||
using UnityEngine; |
||||
using System.Collections; |
||||
using Fungus; |
||||
|
||||
// A component class that does not inherit from Room |
||||
public class MyGameObject : MonoBehavior |
||||
{ |
||||
public Room startRoom; // The Room we want to start Fungus execution with |
||||
|
||||
void Start() |
||||
{ |
||||
// Ensure the command queue is empty |
||||
Game.Clear(); |
||||
|
||||
// Add any required Fungus commands |
||||
// It's a good idea to move to a start Room to ensure that everything is setup correctly. |
||||
// You can then add whatever commands are needed in the OnEnter() method for the Room. |
||||
Game.MoveToRoom(startRoom); |
||||
|
||||
// Start executing queued commands |
||||
Game.Execute(); |
||||
} |
||||
} |
||||
~~~~~~~~~~~~~~~~~~~~ |
||||
|
||||
## Notes |
||||
- Fungus commands can be called anywhere in your code by using the inherited static methods on the [Game class](@ref Fungus.Game). |
||||
- For convenience, the "Game." prefix is optional when invoking commands in a script that inherits from the [Room class](@ref Fungus.Room). |
||||
- In scripts that do not inherit from Room, you must use the "Game." prefix. |
@ -0,0 +1,4 @@
|
||||
fileFormatVersion: 2 |
||||
guid: e945cf0734435468b9d1b2c422ee7754 |
||||
DefaultImporter: |
||||
userData: |
@ -0,0 +1,40 @@
|
||||
Planned Features |
||||
================ |
||||
|
||||
# Cross Fade |
||||
- Fade a sprite over time to use a different texture. |
||||
|
||||
~~~~~~~~~~~~~~~~~~~~ |
||||
CrossFade(SpriteRenderer spriteRenderer, Texture2D texture2D, float duration); |
||||
~~~~~~~~~~~~~~~~~~~~ |
||||
|
||||
# Page Icons |
||||
- Set a sprite icon on left or right side of the active page |
||||
- Size is specified as a fraction of screen height for consistent display on different device types |
||||
|
||||
~~~~~~~~~~~~~~~~~~~~ |
||||
SetLeftIcon(Texture2D texture2D, float iconScale); |
||||
SetRightIcon(Texture2D texture2D, float iconScale); |
||||
SetNoIcon(); |
||||
~~~~~~~~~~~~~~~~~~~~ |
||||
|
||||
# More examples |
||||
- Examples Rooms showing usage for common game types (RPG, Visual Novel, Comic Strip, ...) |
||||
|
||||
# Fixed Page |
||||
- Option to clamp page to bottom or top section of screen (standard Visual Novel layout) |
||||
|
||||
# Comic Strip Bubbles |
||||
- Comic strip style bubbles |
||||
- Automatic fitting for bubble text |
||||
|
||||
# Button Hover |
||||
- Highlight buttons on mouse hover |
||||
|
||||
# New Unity GUI Support |
||||
- Complete rewrite Page system to use new Unity GUI system (when it's released!) |
||||
- Support checkboxes, scroll boxes, sliders, advanced font rendering, ... |
||||
|
||||
# Dice Roll Page |
||||
- Simple combat system via visual dice roll |
||||
|
Loading…
Reference in new issue