Browse Source

Initial commit of custom tags, portrait stage and portrait systems #84

master
chrisgregan 10 years ago
parent
commit
4217ad76e1
  1. 2
      Assets/Fungus/Audio/Editor.meta
  2. 65
      Assets/Fungus/Dialog/Editor/CharacterEditor.cs
  3. 23
      Assets/Fungus/Dialog/Editor/DialogMenuItems.cs
  4. 3
      Assets/Fungus/Dialog/Editor/MenuEditor.cs
  5. 154
      Assets/Fungus/Dialog/Editor/SayEditor.cs
  6. 1025
      Assets/Fungus/Dialog/Resources/FungusMenuDialog.prefab
  7. 16
      Assets/Fungus/Dialog/Resources/FungusSayDialog.prefab
  8. 57
      Assets/Fungus/Dialog/Resources/FungusTag.prefab
  9. 4
      Assets/Fungus/Dialog/Resources/FungusTag.prefab.meta
  10. 2
      Assets/Fungus/Dialog/Scripts/Character.cs
  11. 28
      Assets/Fungus/Dialog/Scripts/Commands/Menu.cs
  12. 3
      Assets/Fungus/Dialog/Scripts/Commands/MenuTimer.cs
  13. 90
      Assets/Fungus/Dialog/Scripts/Commands/Say.cs
  14. 32
      Assets/Fungus/Dialog/Scripts/Commands/SetMenuDialog.cs
  15. 30
      Assets/Fungus/Dialog/Scripts/Commands/SetSayDialog.cs
  16. 33
      Assets/Fungus/Dialog/Scripts/CustomTag.cs
  17. 8
      Assets/Fungus/Dialog/Scripts/CustomTag.cs.meta
  18. 270
      Assets/Fungus/Dialog/Scripts/Dialog.cs
  19. 69
      Assets/Fungus/Dialog/Scripts/DialogParser.cs
  20. 22
      Assets/Fungus/Dialog/Scripts/DialogText.cs
  21. 73
      Assets/Fungus/Dialog/Scripts/MenuDialog.cs
  22. 31
      Assets/Fungus/Dialog/Scripts/SayDialog.cs
  23. 47
      Assets/Fungus/FungusScript/Editor/AssetModProcessor.cs
  24. 8
      Assets/Fungus/FungusScript/Editor/AssetModProcessor.cs.meta
  25. 17
      Assets/Fungus/FungusScript/Editor/FungusScriptEditor.cs
  26. 10
      Assets/Fungus/FungusScript/Editor/FungusScriptWindow.cs
  27. 9
      Assets/Fungus/FungusScript/Scripts/Commands/Reset.cs
  28. 29
      Assets/Fungus/FungusScript/Scripts/FungusScript.cs
  29. 2
      Assets/Fungus/FungusScript/Scripts/Sequence.cs
  30. 5
      Assets/Fungus/Portrait.meta
  31. 5
      Assets/Fungus/Portrait/Editor.meta
  32. 299
      Assets/Fungus/Portrait/Editor/PortraitEditor.cs
  33. 8
      Assets/Fungus/Portrait/Editor/PortraitEditor.cs.meta
  34. 91
      Assets/Fungus/Portrait/Editor/StageEditor.cs
  35. 8
      Assets/Fungus/Portrait/Editor/StageEditor.cs.meta
  36. 482
      Assets/Fungus/Portrait/Portrait.cs
  37. 8
      Assets/Fungus/Portrait/Portrait.cs.meta
  38. 41
      Assets/Fungus/Portrait/PortraitStage.cs
  39. 8
      Assets/Fungus/Portrait/PortraitStage.cs.meta
  40. 5
      Assets/Fungus/Portrait/Prefabs.meta
  41. 75
      Assets/Fungus/Portrait/Prefabs/PortraitPosition.prefab
  42. 4
      Assets/Fungus/Portrait/Prefabs/PortraitPosition.prefab.meta
  43. 479
      Assets/Fungus/Portrait/Prefabs/PortraitStage.prefab
  44. 4
      Assets/Fungus/Portrait/Prefabs/PortraitStage.prefab.meta
  45. 226
      Assets/Fungus/Portrait/Stage.cs
  46. 8
      Assets/Fungus/Portrait/Stage.cs.meta
  47. 5
      Assets/FungusExamples/Sherlock.meta
  48. 5
      Assets/FungusExamples/Sherlock/Resources.meta
  49. 5
      Assets/FungusExamples/Sherlock/Resources/assets.meta
  50. 5
      Assets/FungusExamples/Sherlock/Resources/assets/audio.meta
  51. 5
      Assets/FungusExamples/Sherlock/Resources/assets/audio/emote.meta
  52. BIN
      Assets/FungusExamples/Sherlock/Resources/assets/audio/emote/EMOTE_angry.wav
  53. 12
      Assets/FungusExamples/Sherlock/Resources/assets/audio/emote/EMOTE_angry.wav.meta
  54. BIN
      Assets/FungusExamples/Sherlock/Resources/assets/audio/emote/EMOTE_annoyed.wav
  55. 12
      Assets/FungusExamples/Sherlock/Resources/assets/audio/emote/EMOTE_annoyed.wav.meta
  56. BIN
      Assets/FungusExamples/Sherlock/Resources/assets/audio/emote/EMOTE_answer.wav
  57. 12
      Assets/FungusExamples/Sherlock/Resources/assets/audio/emote/EMOTE_answer.wav.meta
  58. BIN
      Assets/FungusExamples/Sherlock/Resources/assets/audio/emote/EMOTE_clue.wav
  59. 12
      Assets/FungusExamples/Sherlock/Resources/assets/audio/emote/EMOTE_clue.wav.meta
  60. BIN
      Assets/FungusExamples/Sherlock/Resources/assets/audio/emote/EMOTE_confused.wav
  61. 12
      Assets/FungusExamples/Sherlock/Resources/assets/audio/emote/EMOTE_confused.wav.meta
  62. BIN
      Assets/FungusExamples/Sherlock/Resources/assets/audio/emote/EMOTE_furious.wav
  63. 12
      Assets/FungusExamples/Sherlock/Resources/assets/audio/emote/EMOTE_furious.wav.meta
  64. BIN
      Assets/FungusExamples/Sherlock/Resources/assets/audio/emote/EMOTE_pleased.wav
  65. 12
      Assets/FungusExamples/Sherlock/Resources/assets/audio/emote/EMOTE_pleased.wav.meta
  66. BIN
      Assets/FungusExamples/Sherlock/Resources/assets/audio/emote/EMOTE_question.wav
  67. 12
      Assets/FungusExamples/Sherlock/Resources/assets/audio/emote/EMOTE_question.wav.meta
  68. BIN
      Assets/FungusExamples/Sherlock/Resources/assets/audio/emote/EMOTE_realize.wav
  69. 12
      Assets/FungusExamples/Sherlock/Resources/assets/audio/emote/EMOTE_realize.wav.meta
  70. BIN
      Assets/FungusExamples/Sherlock/Resources/assets/audio/emote/EMOTE_scared.wav
  71. 12
      Assets/FungusExamples/Sherlock/Resources/assets/audio/emote/EMOTE_scared.wav.meta
  72. BIN
      Assets/FungusExamples/Sherlock/Resources/assets/audio/emote/EMOTE_shocked.wav
  73. 12
      Assets/FungusExamples/Sherlock/Resources/assets/audio/emote/EMOTE_shocked.wav.meta
  74. BIN
      Assets/FungusExamples/Sherlock/Resources/assets/audio/emote/EMOTE_shout.wav
  75. 12
      Assets/FungusExamples/Sherlock/Resources/assets/audio/emote/EMOTE_shout.wav.meta
  76. BIN
      Assets/FungusExamples/Sherlock/Resources/assets/audio/emote/EMOTE_worried.wav
  77. 12
      Assets/FungusExamples/Sherlock/Resources/assets/audio/emote/EMOTE_worried.wav.meta
  78. 5
      Assets/FungusExamples/Sherlock/Resources/assets/audio/gui.meta
  79. BIN
      Assets/FungusExamples/Sherlock/Resources/assets/audio/gui/UI_Paper.wav
  80. 12
      Assets/FungusExamples/Sherlock/Resources/assets/audio/gui/UI_Paper.wav.meta
  81. BIN
      Assets/FungusExamples/Sherlock/Resources/assets/audio/gui/UI_SpeechCheck-Fail.wav
  82. 12
      Assets/FungusExamples/Sherlock/Resources/assets/audio/gui/UI_SpeechCheck-Fail.wav.meta
  83. BIN
      Assets/FungusExamples/Sherlock/Resources/assets/audio/gui/UI_SpeechCheck-Pass.wav
  84. 12
      Assets/FungusExamples/Sherlock/Resources/assets/audio/gui/UI_SpeechCheck-Pass.wav.meta
  85. BIN
      Assets/FungusExamples/Sherlock/Resources/assets/audio/gui/UI_Stat-0.wav
  86. 12
      Assets/FungusExamples/Sherlock/Resources/assets/audio/gui/UI_Stat-0.wav.meta
  87. BIN
      Assets/FungusExamples/Sherlock/Resources/assets/audio/gui/UI_Stat-100.wav
  88. 12
      Assets/FungusExamples/Sherlock/Resources/assets/audio/gui/UI_Stat-100.wav.meta
  89. BIN
      Assets/FungusExamples/Sherlock/Resources/assets/audio/gui/UI_Stat-Decrease.wav
  90. 12
      Assets/FungusExamples/Sherlock/Resources/assets/audio/gui/UI_Stat-Decrease.wav.meta
  91. BIN
      Assets/FungusExamples/Sherlock/Resources/assets/audio/gui/UI_Stat-Increase.wav
  92. 12
      Assets/FungusExamples/Sherlock/Resources/assets/audio/gui/UI_Stat-Increase.wav.meta
  93. 5
      Assets/FungusExamples/Sherlock/Resources/assets/audio/music.meta
  94. BIN
      Assets/FungusExamples/Sherlock/Resources/assets/audio/music/Eliminate the Impossible.ogg
  95. 12
      Assets/FungusExamples/Sherlock/Resources/assets/audio/music/Eliminate the Impossible.ogg.meta
  96. 5
      Assets/FungusExamples/Sherlock/Resources/assets/audio/sfx.meta
  97. 5
      Assets/FungusExamples/Sherlock/Resources/assets/audio/sfx/Liquids.meta
  98. BIN
      Assets/FungusExamples/Sherlock/Resources/assets/audio/sfx/Liquids/PourLiquid.wav
  99. 12
      Assets/FungusExamples/Sherlock/Resources/assets/audio/sfx/Liquids/PourLiquid.wav.meta
  100. 5
      Assets/FungusExamples/Sherlock/Resources/assets/characters.meta
  101. Some files were not shown because too many files have changed in this diff Show More

2
Assets/Fungus/Dialog/Sprites.meta → Assets/Fungus/Audio/Editor.meta

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 8bbdbd776cccc4e1985aec1a2ee202b0
guid: 5a4fe51b67cee49b28f6a0231dae2352
folderAsset: yes
DefaultImporter:
userData:

65
Assets/Fungus/Dialog/Editor/CharacterEditor.cs

@ -2,6 +2,7 @@ using UnityEditor;
using UnityEngine;
using System.Collections;
using Rotorz.ReorderableList;
using System.Collections.Generic;
namespace Fungus
{
@ -9,14 +10,11 @@ namespace Fungus
[CustomEditor (typeof(Character))]
public class CharacterEditor : Editor
{
protected Material spriteMaterial;
protected SerializedProperty nameTextProp;
protected SerializedProperty nameColorProp;
protected SerializedProperty sayDialogBoxProp;
protected SerializedProperty chooseDialogBoxProp;
protected SerializedProperty soundEffectProp;
protected SerializedProperty portraitsProp;
protected SerializedProperty portraitsFaceProp;
protected SerializedProperty notesProp;
protected virtual void OnEnable()
@ -25,38 +23,20 @@ namespace Fungus
nameColorProp = serializedObject.FindProperty ("nameColor");
soundEffectProp = serializedObject.FindProperty ("soundEffect");
portraitsProp = serializedObject.FindProperty ("portraits");
portraitsFaceProp = serializedObject.FindProperty ("portraitsFace");
notesProp = serializedObject.FindProperty ("notes");
Shader shader = Shader.Find("Sprites/Default");
if (shader != null)
{
spriteMaterial = new Material(shader);
spriteMaterial.hideFlags = HideFlags.DontSave;
}
}
protected virtual void OnDisable()
{
DestroyImmediate(spriteMaterial);
}
public override void OnInspectorGUI()
{
serializedObject.Update();
Character t = target as Character;
EditorGUILayout.PropertyField(nameTextProp, new GUIContent("Name Text", "Name of the character display in the dialog"));
EditorGUILayout.PropertyField(nameColorProp, new GUIContent("Name Color", "Color of name text display in the dialog"));
EditorGUILayout.PropertyField(soundEffectProp, new GUIContent("Sound Effect", "Sound to play when the character is talking. Overrides the setting in the Dialog."));
ReorderableListGUI.Title(new GUIContent("Portraits", "Character image sprites to display in the dialog"));
ReorderableListGUI.ListField(portraitsProp);
EditorGUILayout.PropertyField(notesProp, new GUIContent("Notes", "Notes about this story character (personality, attibutes, etc.)"));
EditorGUILayout.Separator();
Character t = target as Character;
if (t.portraits != null &&
t.portraits.Count > 0)
{
@ -67,28 +47,31 @@ namespace Fungus
t.profileSprite = null;
}
if (t.profileSprite != null &&
spriteMaterial != null)
if (t.profileSprite != null)
{
float aspect = (float)t.profileSprite.texture.width / (float)t.profileSprite.texture.height;
Rect imagePreviewRect = GUILayoutUtility.GetAspectRect(aspect, GUILayout.Width(100), GUILayout.ExpandWidth(true));
DrawPreview(imagePreviewRect, t.profileSprite.texture);
Texture2D characterTexture = t.profileSprite.texture;
float aspect = (float)characterTexture.width / (float)characterTexture.height;
Rect previewRect = GUILayoutUtility.GetAspectRect(aspect, GUILayout.Width(100), GUILayout.ExpandWidth(true));
if (characterTexture != null)
GUI.DrawTexture(previewRect,characterTexture,ScaleMode.ScaleToFit,true,aspect);
}
ReorderableListGUI.Title(new GUIContent("Portraits", "Character image sprites to display in the dialog"));
ReorderableListGUI.ListField(portraitsProp);
string[] facingArrows = new string[]
{
"FRONT",
"<--",
"-->",
};
portraitsFaceProp.enumValueIndex = EditorGUILayout.Popup("Portraits Face", (int)portraitsFaceProp.enumValueIndex, facingArrows);
EditorGUILayout.Separator();
EditorUtility.SetDirty(t);
serializedObject.ApplyModifiedProperties();
}
public virtual void DrawPreview(Rect previewRect, Texture2D texture)
{
if (texture == null)
{
return;
}
EditorGUI.DrawPreviewTexture(previewRect,
texture,
spriteMaterial);
}
}
}

23
Assets/Fungus/Dialog/Editor/DialogMenuItems.cs

@ -41,6 +41,29 @@ namespace Fungus
spawnedGO.name = "MenuDialog";
}
}
[MenuItem("GameObject/Fungus/Dialog/Tag")]
static void CreateTagDialog()
{
GameObject go = Resources.Load<GameObject>("FungusTag");
if (go != null)
{
GameObject spawnedGO = PrefabUtility.InstantiatePrefab(go) as GameObject;
spawnedGO.name = "Tag";
}
}
[MenuItem("GameObject/Fungus/Portrait/PortraitStage")]
static void CreatePortraitStage()
{
FungusScriptMenuItems.SpawnPrefab("Assets/Fungus/Portrait/Prefabs/PortraitStage.prefab");
}
[MenuItem("GameObject/Fungus/Portrait/PortraitPosition")]
static void CreatePortraitPosition()
{
FungusScriptMenuItems.SpawnPrefab("Assets/Fungus/Portrait/Prefabs/PortraitPosition.prefab");
}
}
}

3
Assets/Fungus/Dialog/Editor/MenuEditor.cs

@ -13,12 +13,14 @@ namespace Fungus
protected SerializedProperty textProp;
protected SerializedProperty targetSequenceProp;
protected SerializedProperty hideIfVisitedProp;
protected SerializedProperty setMenuDialogProp;
protected virtual void OnEnable()
{
textProp = serializedObject.FindProperty("text");
targetSequenceProp = serializedObject.FindProperty("targetSequence");
hideIfVisitedProp = serializedObject.FindProperty("hideIfVisited");
setMenuDialogProp = serializedObject.FindProperty("setMenuDialog");
}
public override void DrawCommandGUI()
@ -39,6 +41,7 @@ namespace Fungus
fungusScript);
EditorGUILayout.PropertyField(hideIfVisitedProp);
EditorGUILayout.PropertyField(setMenuDialogProp);
serializedObject.ApplyModifiedProperties();
}

154
Assets/Fungus/Dialog/Editor/SayEditor.cs

@ -12,63 +12,140 @@ namespace Fungus
public class SayEditor : CommandEditor
{
static public bool showTagHelp;
public Texture2D blackTex;
static public void DrawTagHelpLabel()
{
string tagsText = "\t{b} Bold Text {/b}\n" +
string tagsText = "";
tagsText += "\n";
tagsText += "\t-------- DEFAULT TAGS --------\n\n";
tagsText += "" +
"\t{b} Bold Text {/b}\n" +
"\t{i} Italic Text {/i}\n" +
"\t{color=red} Color Text {/color}\n" +
"\t{w}, {w=0.5} Wait \n" +
"\t{color=red} Color Text (color){/color}\n" +
"\n" +
"\t{s}, {s=60} Writing speed (chars per sec){/s}\n" +
"\t{w}, {w=0.5} Wait (seconds)\n" +
"\t{wi} Wait for input\n" +
"\t{wc} Wait for input and clear\n" +
"\t{wp}, {wp=0.5} Wait on punctuation\n" +
"\t{wp}, {wp=0.5} Wait on punctuation (seconds){/wp}\n" +
"\t{c} Clear\n" +
"\t{s}, {s=60} Writing speed (chars per sec)\n" +
"\t{x} Exit\n" +
"\t{x} Exit, advance to the next command without waiting for input\n" +
"\n" +
"\t{vpunch=0.5} Vertically punch screen (intensity)\n" +
"\t{hpunch=0.5} Horizontally punch screen (intensity)\n" +
"\t{shake=1} Shake screen (intensity)\n" +
"\t{shiver=1} Shiver screen (intensity)\n" +
"\t{flash=0.5} Flash screen (duration)\n" +
"\n" +
"\t{audio=AudioObjectName} Play Audio Once\n" +
"\t{audioloop=AudioObjectName} Play Audio Loop\n" +
"\t{audiopause=AudioObjectName} Pause Audio\n" +
"\t{audiostop=AudioObjectName} Stop Audio\n" +
"\n" +
"\t{m} Broadcast message\n" +
"\t{$VarName} Substitute variable";
if (CustomTag.activeCustomTags.Count > 0)
{
tagsText += "\n\n\t-------- CUSTOM TAGS --------";
List<Transform> activeCustomTagGroup = new List<Transform>();
foreach (CustomTag ct in CustomTag.activeCustomTags)
{
if(ct.transform.parent != null)
{
if (!activeCustomTagGroup.Contains(ct.transform.parent.transform))
{
activeCustomTagGroup.Add(ct.transform.parent.transform);
}
}
else
{
activeCustomTagGroup.Add(ct.transform);
}
}
foreach(Transform parent in activeCustomTagGroup)
{
string tagName = parent.name;
string tagStartSymbol = "";
string tagEndSymbol = "";
CustomTag parentTag = parent.GetComponent<CustomTag>();
if (parentTag != null)
{
tagName = parentTag.name;
tagStartSymbol = parentTag.tagStartSymbol;
tagEndSymbol = parentTag.tagEndSymbol;
}
tagsText += "\n\n\t" + tagStartSymbol + " " + tagName + " " + tagEndSymbol;
foreach(Transform child in parent)
{
tagName = child.name;
tagStartSymbol = "";
tagEndSymbol = "";
CustomTag childTag = child.GetComponent<CustomTag>();
if (childTag != null)
{
tagName = childTag.name;
tagStartSymbol = childTag.tagStartSymbol;
tagEndSymbol = childTag.tagEndSymbol;
}
tagsText += "\n\t " + tagStartSymbol + " " + tagName + " " + tagEndSymbol;
}
}
}
tagsText += "\n";
float pixelHeight = EditorStyles.miniLabel.CalcHeight(new GUIContent(tagsText), EditorGUIUtility.currentViewWidth);
EditorGUILayout.SelectableLabel(tagsText, EditorStyles.miniLabel, GUILayout.MinHeight(pixelHeight));
EditorGUILayout.SelectableLabel(tagsText, GUI.skin.GetStyle("HelpBox"), GUILayout.MinHeight(pixelHeight));
}
protected SerializedProperty characterProp;
protected SerializedProperty sayDialogProp;
protected SerializedProperty portraitProp;
protected SerializedProperty storyTextProp;
protected SerializedProperty voiceOverClipProp;
protected SerializedProperty showAlwaysProp;
protected SerializedProperty showCountProp;
protected SerializedProperty waitForInputProp;
protected SerializedProperty extendPreviousProp;
protected SerializedProperty fadeInProp;
protected SerializedProperty fadeOutProp;
protected SerializedProperty waitForClickProp;
protected SerializedProperty setSayDialogProp;
protected virtual void OnEnable()
{
characterProp = serializedObject.FindProperty("character");
sayDialogProp = serializedObject.FindProperty("sayDialog");
portraitProp = serializedObject.FindProperty("portrait");
storyTextProp = serializedObject.FindProperty("storyText");
voiceOverClipProp = serializedObject.FindProperty("voiceOverClip");
showAlwaysProp = serializedObject.FindProperty("showAlways");
showCountProp = serializedObject.FindProperty("showCount");
waitForInputProp = serializedObject.FindProperty("waitForInput");
extendPreviousProp = serializedObject.FindProperty("extendPrevious");
fadeInProp = serializedObject.FindProperty("fadeIn");
fadeOutProp = serializedObject.FindProperty("fadeOut");
waitForClickProp = serializedObject.FindProperty("waitForClick");
setSayDialogProp = serializedObject.FindProperty("setSayDialog");
if (blackTex == null)
{
blackTex = CustomGUI.CreateBlackTexture();
}
}
protected virtual void OnDisable()
{
DestroyImmediate(blackTex);
}
public override void DrawCommandGUI()
{
serializedObject.Update();
Say t = target as Say;
bool showPortraits = false;
CommandEditor.ObjectField<Character>(characterProp,
new GUIContent("Character", "Character to display in dialog"),
new GUIContent("Character", "Character that is speaking"),
new GUIContent("<None>"),
Character.activeCharacters);
CommandEditor.ObjectField<SayDialog>(sayDialogProp,
new GUIContent("Say Dialog", "Say Dialog object to use to display the story text"),
new GUIContent("<Default>"),
SayDialog.activeDialogs);
bool showPortraits = false;
Say t = target as Say;
// Only show portrait selection if...
if (t.character != null && // Character is selected
t.character.portraits != null && // Character has a portraits field
@ -85,17 +162,22 @@ namespace Fungus
t.character.portraits);
}
else
{
if (!t.extendPrevious)
{
t.portrait = null;
}
}
EditorGUILayout.PropertyField(storyTextProp);
EditorGUILayout.BeginHorizontal();
EditorGUILayout.PropertyField(extendPreviousProp);
GUILayout.FlexibleSpace();
if (GUILayout.Button(new GUIContent("Tag Help", "Show help info for tags"), new GUIStyle(EditorStyles.miniButton)))
if (GUILayout.Button(new GUIContent("Tag Help", "View available tags"), new GUIStyle(EditorStyles.miniButton)))
{
showTagHelp = !showTagHelp;
}
@ -109,7 +191,7 @@ namespace Fungus
EditorGUILayout.Separator();
EditorGUILayout.PropertyField(voiceOverClipProp,
new GUIContent("Voice Over Clip", "Voice over audio to play when the say text is displayed"));
new GUIContent("Voice Over Clip", "Voice over audio to play when the text is displayed"));
EditorGUILayout.PropertyField(showAlwaysProp);
@ -118,19 +200,35 @@ namespace Fungus
EditorGUILayout.PropertyField(showCountProp);
}
EditorGUILayout.PropertyField(waitForInputProp);
GUIStyle centeredLabel = new GUIStyle(EditorStyles.label);
centeredLabel.alignment = TextAnchor.MiddleCenter;
GUIStyle leftButton = new GUIStyle(EditorStyles.miniButtonLeft);
leftButton.fontSize = 10;
leftButton.font = EditorStyles.toolbarButton.font;
GUIStyle rightButton = new GUIStyle(EditorStyles.miniButtonRight);
rightButton.fontSize = 10;
rightButton.font = EditorStyles.toolbarButton.font;
EditorGUILayout.BeginHorizontal();
EditorGUILayout.PrefixLabel("Fade");
t.fadeIn = GUILayout.Toggle(t.fadeIn, "In", leftButton, GUILayout.Width(80));
t.fadeOut = GUILayout.Toggle(t.fadeOut, "Out", rightButton, GUILayout.Width(80));
EditorGUILayout.EndHorizontal();
EditorGUILayout.PropertyField(waitForClickProp);
EditorGUILayout.PropertyField(setSayDialogProp);
if (showPortraits && t.portrait != null)
{
Texture2D characterTexture = t.portrait.texture;
float aspect = (float)characterTexture.width / (float)characterTexture.height;
Rect previewRect = GUILayoutUtility.GetAspectRect(aspect, GUILayout.Width(100), GUILayout.ExpandWidth(true));
CharacterEditor characterEditor = Editor.CreateEditor(t.character) as CharacterEditor;
characterEditor.DrawPreview(previewRect, characterTexture);
DestroyImmediate(characterEditor);
if (characterTexture != null)
{
GUI.DrawTexture(previewRect,characterTexture,ScaleMode.ScaleToFit,true,aspect);
}
}
serializedObject.ApplyModifiedProperties();

1025
Assets/Fungus/Dialog/Resources/FungusMenuDialog.prefab

File diff suppressed because it is too large Load Diff

16
Assets/Fungus/Dialog/Resources/FungusSayDialog.prefab

@ -232,7 +232,7 @@ MonoBehaviour:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_Sprite: {fileID: 0}
m_Sprite: {fileID: 21300000, guid: ea8f56c43254d41728f5ac4e8299b6c9, type: 3}
m_Type: 0
m_PreserveAspect: 1
m_FillCenter: 1
@ -254,7 +254,17 @@ MonoBehaviour:
writingSpeed: 30
writingSound: {fileID: 8300000, guid: 5a3c8e205638142dcb8227abe5f14f1f, type: 3}
loopWritingSound: 1
beepPerCharacter: 0
slowBeepsAt: 10
fastBeepsAt: 30
punctuationPause: .200000003
alwaysFadeDialog: 1
fadeDuration: .25
fadeEaseType: 0
alwaysMoveDialog: 0
startPosition: {x: 0, y: 0}
moveSpeed: 1000
moveEaseType: 0
clickAnywhere: 1
dialogCanvas: {fileID: 22388894}
nameText: {fileID: 11488900}
@ -276,7 +286,7 @@ MonoBehaviour:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FontData:
m_Font: {fileID: 12800000, guid: 333ca057701a73249850670faef184dc, type: 3}
m_Font: {fileID: 12800000, guid: bb145366ce7024469a5758b08d31802c, type: 3}
m_FontSize: 40
m_FontStyle: 0
m_BestFit: 1
@ -323,7 +333,7 @@ MonoBehaviour:
m_Material: {fileID: 0}
m_Color: {r: .258823544, g: .254901975, b: .262745112, a: 1}
m_FontData:
m_Font: {fileID: 12800000, guid: ee3a4060b74a7fd45b0cc411c99fd8f2, type: 3}
m_Font: {fileID: 12800000, guid: bb145366ce7024469a5758b08d31802c, type: 3}
m_FontSize: 50
m_FontStyle: 0
m_BestFit: 0

57
Assets/Fungus/Dialog/Resources/FungusTag.prefab

@ -0,0 +1,57 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &177196
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 4
m_Component:
- 4: {fileID: 477196}
- 114: {fileID: 11477196}
m_Layer: 0
m_Name: FungusTag
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &477196
Transform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 177196}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
--- !u!114 &11477196
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 177196}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 335e04fbdd5260043abb299a991dcbe8, type: 3}
m_Name:
m_EditorClassIdentifier:
tagStartSymbol: '{customName}'
tagEndSymbol: '{/customName}'
replaceTagStartWith: '{color=blue}'
replaceTagEndWith: '{/color}'
--- !u!1001 &100100000
Prefab:
m_ObjectHideFlags: 1
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications: []
m_RemovedComponents: []
m_ParentPrefab: {fileID: 0}
m_RootGameObject: {fileID: 177196}
m_IsPrefabParent: 1
m_IsExploded: 1

4
Assets/Fungus/Dialog/Resources/FungusTag.prefab.meta

@ -0,0 +1,4 @@
fileFormatVersion: 2
guid: 8345c33c7c8ada64083f41d452b315eb
NativeFormatImporter:
userData:

2
Assets/Fungus/Dialog/Scripts/Character.cs

@ -13,6 +13,8 @@ namespace Fungus
public AudioClip soundEffect;
public Sprite profileSprite;
public List<Sprite> portraits;
public FacingDirection portraitsFace;
public PortraitState state;
[TextArea(5,10)]
public string notes;

28
Assets/Fungus/Dialog/Scripts/Commands/Menu.cs

@ -17,34 +17,36 @@ namespace Fungus
// Menu Timeout executes a sequence if the timeout expires
// The 'Hide If Visited' option checks the execution count of the target sequence
// Hide Say dialog when finished? Let Say command handle that
// Can wrap in an If statement if you need a conditional option
public string text = "Option";
public string text = "Option Text";
public Sequence targetSequence;
public bool hideIfVisited;
public MenuDialog setMenuDialog;
protected static bool eventSystemPresent;
public override void OnEnter()
{
CheckEventSystem();
MenuDialog menuDialog = SetMenuDialog.GetActiveMenuDialog();
if (menuDialog != null)
if (setMenuDialog != null)
{
menuDialog.gameObject.SetActive(true);
// Override the active menu dialog
MenuDialog.activeMenuDialog = setMenuDialog;
}
bool hideOption = (hideIfVisited && targetSequence != null && targetSequence.GetExecutionCount() > 0);
if (hideIfVisited &&
targetSequence != null &&
targetSequence.GetExecutionCount() > 0)
if (!hideOption)
{
// Don't show this option
}
else
MenuDialog menuDialog = MenuDialog.GetMenuDialog();
if (menuDialog != null)
{
menuDialog.AddOption(text, targetSequence);
menuDialog.gameObject.SetActive(true);
string displayText = text;
menuDialog.AddOption(displayText, targetSequence);
}
}

3
Assets/Fungus/Dialog/Scripts/Commands/MenuTimer.cs

@ -17,7 +17,8 @@ namespace Fungus
public override void OnEnter()
{
MenuDialog menuDialog = SetMenuDialog.GetActiveMenuDialog();
MenuDialog menuDialog = MenuDialog.GetMenuDialog();
if (menuDialog != null &&
targetSequence != null)
{

90
Assets/Fungus/Dialog/Scripts/Commands/Say.cs

@ -7,23 +7,21 @@ namespace Fungus
{
[CommandInfo("Dialog",
"Say",
"Writes a line of story text to a Say Dialog. " +
"Select [Game Object > Fungus > Dialog > Say Dialog] to create a new Say Dialog in your scene. " +
"Select [Game Object > Fungus > Dialog > Character] to create a new selectable speaking character.")]
"Writes text in a dialog box.")]
[AddComponentMenu("")]
public class Say : Command
{
[Tooltip("Story text to display to the player")]
[Tooltip("Text to display")]
[TextArea(5,10)]
public string storyText;
[Tooltip("Speaking character to use when writing the story text")]
[Tooltip("Character that is speaking")]
public Character character;
[Tooltip("Portrait that represents speaking character")]
public Sprite portrait;
[Tooltip("Voiceover audio to play when writing the story text")]
[Tooltip("Voiceover audio to play when writing the text")]
public AudioClip voiceOverClip;
[Tooltip("Always show this Say text when the command is executed multiple times")]
@ -32,8 +30,20 @@ namespace Fungus
[Tooltip("Number of times to show this Say text when the command is executed multiple times")]
public int showCount = 1;
[Tooltip("Wait for player input before hiding the dialog and continuing. If false then the dialog will display and execution will continue.")]
public bool waitForInput = true;
[Tooltip("Type this text in the previous dialog box.")]
public bool extendPrevious = false;
[Tooltip("Fade in this dialog box.")]
public bool fadeIn = false;
[Tooltip("Fade out this dialog box.")]
public bool fadeOut = false;
[Tooltip("Wait for player to click before hiding the dialog and continuing. If false then the dialog will display and execution will continue immediately.")]
public bool waitForClick = true;
[Tooltip("Sets the active Say dialog with a reference to a Say Dialog object in the scene. All story text will now display using this Say Dialog.")]
public SayDialog setSayDialog;
protected int executionCount;
@ -47,7 +57,13 @@ namespace Fungus
executionCount++;
SayDialog sayDialog = SetSayDialog.GetActiveSayDialog();
// Override the active say dialog if needed
if (setSayDialog != null)
{
SayDialog.activeSayDialog = setSayDialog;
}
SayDialog sayDialog = SayDialog.GetSayDialog();
if (sayDialog == null)
{
@ -59,20 +75,66 @@ namespace Fungus
sayDialog.SetCharacter(character, fungusScript);
sayDialog.SetCharacterImage(portrait);
bool fadingIn = false;
bool movingIn = false;
if (sayDialog.alwaysFadeDialog || fadeIn)
{
sayDialog.FadeInDialog();
fadingIn = true;
}
if (sayDialog.alwaysMoveDialog)
{
sayDialog.MoveInDialog();
movingIn = true;
}
if (!fadingIn && !movingIn)
{
sayDialog.ShowDialog(true);
}
if (voiceOverClip != null)
{
sayDialog.PlayVoiceOver(voiceOverClip);
}
string subbedText = fungusScript.SubstituteVariables(storyText);
string displayText = storyText;
foreach (CustomTag ct in CustomTag.activeCustomTags)
{
displayText = displayText.Replace(ct.tagStartSymbol,ct.replaceTagStartWith);
if (ct.tagEndSymbol != "" && ct.replaceTagEndWith != "")
{
displayText = displayText.Replace(ct.tagEndSymbol,ct.replaceTagEndWith);
}
}
if (extendPrevious)
{
displayText = "{s=0}" + Dialog.prevStoryText + "{/s}" + displayText;
}
sayDialog.Say(subbedText, waitForInput, delegate {
if (waitForInput)
string subbedText = fungusScript.SubstituteVariables(displayText);
sayDialog.Say(subbedText, waitForClick, delegate {
if (waitForClick)
{
bool fadingOut = false;
bool movingOut = false;
if (sayDialog.alwaysFadeDialog || fadeOut)
{
sayDialog.FadeOutDialog();
fadingOut = true;
}
if (sayDialog.alwaysMoveDialog)
{
sayDialog.MoveOutDialog();
movingOut = true;
}
if (!fadingOut && !movingOut)
{
sayDialog.ShowDialog(false);
}
}
Continue();
});
}
@ -84,6 +146,10 @@ namespace Fungus
{
namePrefix = character.nameText + ": ";
}
if (extendPrevious)
{
namePrefix = "EXTEND" + ": ";
}
return namePrefix + "\"" + storyText + "\"";
}

32
Assets/Fungus/Dialog/Scripts/Commands/SetMenuDialog.cs

@ -10,43 +10,15 @@ namespace Fungus
[AddComponentMenu("")]
public class SetMenuDialog : Command
{
public static MenuDialog activeMenuDialog;
public MenuDialog menuDialog;
public static MenuDialog GetActiveMenuDialog()
{
if (activeMenuDialog == null)
{
activeMenuDialog = GameObject.FindObjectOfType<MenuDialog>();
}
if (activeMenuDialog == null)
{
// Auto spawn a menu object from the prefab
GameObject go = Resources.Load<GameObject>("FungusMenuDialog");
if (go != null)
{
GameObject spawnedGO = Instantiate(go) as GameObject;
spawnedGO.name = "MenuDialog";
spawnedGO.SetActive(false);
activeMenuDialog = spawnedGO.GetComponent<MenuDialog>();
}
}
return activeMenuDialog;
}
public override void OnEnter()
{
if (menuDialog != null)
{
activeMenuDialog = menuDialog;
MenuDialog.activeMenuDialog = menuDialog;
}
// Populate the static cached dialog
GetActiveMenuDialog();
Continue();
}
@ -62,7 +34,7 @@ namespace Fungus
public override Color GetButtonColor()
{
return new Color32(170, 204, 169, 255);
return new Color32(184, 210, 235, 255);
}
}

30
Assets/Fungus/Dialog/Scripts/Commands/SetSayDialog.cs

@ -10,43 +10,15 @@ namespace Fungus
[AddComponentMenu("")]
public class SetSayDialog : Command
{
public static SayDialog activeDialog;
public SayDialog sayDialog;
public static SayDialog GetActiveSayDialog()
{
if (activeDialog == null)
{
activeDialog = GameObject.FindObjectOfType<SayDialog>();
}
if (activeDialog == null)
{
// Auto spawn a say dialog from the prefab
GameObject go = Resources.Load<GameObject>("FungusSayDialog");
if (go != null)
{
GameObject spawnedGO = Instantiate(go) as GameObject;
spawnedGO.name = "SayDialog";
spawnedGO.SetActive(false);
activeDialog = spawnedGO.GetComponent<SayDialog>();
}
}
return activeDialog;
}
public override void OnEnter()
{
if (sayDialog != null)
{
activeDialog = sayDialog;
SayDialog.activeSayDialog = sayDialog;
}
// Populate the static cached dialog
GetActiveSayDialog();
Continue();
}

33
Assets/Fungus/Dialog/Scripts/CustomTag.cs

@ -0,0 +1,33 @@
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Events;
using System.Collections;
using System.Collections.Generic;
namespace Fungus
{
[ExecuteInEditMode]
public class CustomTag : MonoBehaviour
{
public string tagStartSymbol;
public string tagEndSymbol;
public string replaceTagStartWith;
public string replaceTagEndWith;
static public List<CustomTag> activeCustomTags = new List<CustomTag>();
protected virtual void OnEnable()
{
if (!activeCustomTags.Contains(this))
{
activeCustomTags.Add(this);
}
}
protected virtual void OnDisable()
{
activeCustomTags.Remove(this);
}
}
}

8
Assets/Fungus/Dialog/Scripts/CustomTag.cs.meta

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 335e04fbdd5260043abb299a991dcbe8
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

270
Assets/Fungus/Dialog/Scripts/Dialog.cs

@ -10,10 +10,24 @@ namespace Fungus
public class Dialog : MonoBehaviour
{
public static Character speakingCharacter;
public static string prevStoryText;
public float writingSpeed = 60;
public AudioClip writingSound;
public bool loopWritingSound = true;
public bool beepPerCharacter = false;
public float slowBeepsAt = 10f;
public float fastBeepsAt = 30f;
public float punctuationPause = 0.25f;
public bool alwaysFadeDialog = false;
public float fadeDuration = 1f;
public LeanTweenType fadeEaseType;
public bool alwaysMoveDialog = false;
public Vector2 startPosition;
protected Vector2 endPosition;
public float moveSpeed = 1000f;
public LeanTweenType moveEaseType;
[Tooltip("Click anywhere on screen to continue when set to true, or only on dialog when false.")]
public bool clickAnywhere = true;
@ -59,9 +73,10 @@ namespace Fungus
{
if (dialogCanvas != null)
{
LeanTween.cancel(dialogCanvas.gameObject);
dialogCanvas.GetComponent<CanvasGroup>().alpha = 1;
dialogCanvas.gameObject.SetActive(visible);
}
if (visible)
{
// A new dialog is often shown as the result of a mouse click, so we need
@ -71,6 +86,71 @@ namespace Fungus
}
}
public virtual void FadeInDialog()
{
LeanTween.cancel(dialogCanvas.gameObject);
dialogCanvas.GetComponent<CanvasGroup>().alpha = 0;
dialogCanvas.gameObject.SetActive(true);
if (fadeDuration == 0) fadeDuration = float.Epsilon;
LeanTween.value(dialogCanvas.gameObject,0,1,fadeDuration).setEase(fadeEaseType).setOnUpdate(
(float fadeAmount)=>{
dialogCanvas.GetComponent<CanvasGroup>().alpha = fadeAmount;
}
).setOnComplete(
()=>{
dialogCanvas.GetComponent<CanvasGroup>().alpha = 1;
}
);
}
public virtual void MoveInDialog()
{
endPosition = this.transform.position;
float moveDuration = (Vector3.Distance(startPosition,this.transform.position)/moveSpeed);
if (moveSpeed == 0) moveDuration = float.Epsilon;
LeanTween.value(this.gameObject,(Vector2)startPosition,(Vector2)endPosition,moveDuration).setEase(moveEaseType).setOnUpdate(
(Vector3 updatePosition)=>{
this.transform.position = updatePosition;
}
).setOnComplete(
()=>{
this.transform.position = endPosition;
}
);
}
public virtual void FadeOutDialog()
{
LeanTween.cancel(dialogCanvas.gameObject);
if (fadeDuration == 0) fadeDuration = float.Epsilon;
LeanTween.value(dialogCanvas.gameObject,1,0,fadeDuration).setEase(fadeEaseType).setOnUpdate(
(float fadeAmount)=>{
dialogCanvas.GetComponent<CanvasGroup>().alpha = fadeAmount;
}
).setOnComplete(
()=>{
dialogCanvas.gameObject.SetActive(false);
dialogCanvas.GetComponent<CanvasGroup>().alpha = 1;
}
);
}
public virtual void MoveOutDialog()
{
endPosition = this.transform.position;
float moveDuration = (Vector3.Distance(startPosition,this.transform.position)/moveSpeed);
if (moveSpeed == 0) moveDuration = float.Epsilon;
LeanTween.value(this.gameObject,(Vector2)endPosition,(Vector2)startPosition,moveDuration).setEase(moveEaseType).setOnUpdate(
(Vector3 updatePosition)=>{
this.transform.position = updatePosition;
}
).setOnComplete(
()=>{
this.transform.position = endPosition;
}
);
}
public virtual void SetCharacter(Character character, FungusScript fungusScript = null)
{
if (character == null)
@ -83,8 +163,33 @@ namespace Fungus
}
else
{
Character prevSpeakingCharacter = speakingCharacter;
speakingCharacter = character;
// Dim portraits of non-speaking characters
foreach (PortraitStage ps in PortraitStage.activePortraitStages)
{
if (ps.dimPortraits)
{
foreach (Character c in ps.charactersOnStage)
{
if (prevSpeakingCharacter != speakingCharacter)
{
if (c != speakingCharacter)
{
Portrait.Dim(c,ps);
}
else
{
Portrait.Undim(c,ps);
}
}
}
}
}
string characterName = character.nameText;
if (characterName == "")
{
// Use game object name as default
@ -100,7 +205,6 @@ namespace Fungus
SetCharacterName(characterName, character.nameColor);
}
}
public virtual void SetCharacterImage(Sprite image)
@ -148,12 +252,16 @@ namespace Fungus
DialogText dialogText = new DialogText();
dialogText.writingSpeed = writingSpeed;
dialogText.punctuationPause = punctuationPause;
dialogText.beepPerCharacter = beepPerCharacter;
dialogText.slowBeepsAt = slowBeepsAt;
dialogText.fastBeepsAt = fastBeepsAt;
GameObject typingAudio = null;
if (characterTypingSound != null || writingSound != null)
{
typingAudio = new GameObject("WritingSound");
typingAudio.AddComponent<AudioSource>();
typingAudio.hideFlags = HideFlags.HideInHierarchy;
if (characterTypingSound != null)
{
@ -227,20 +335,23 @@ namespace Fungus
StopVoiceOver();
break;
case TokenType.WaitOnPunctuation:
case TokenType.WaitOnPunctuationStart:
float newPunctuationPause = 0f;
if (!Single.TryParse(token.param, out newPunctuationPause))
{
newPunctuationPause = punctuationPause;
newPunctuationPause = 0f;
}
dialogText.punctuationPause = newPunctuationPause;
break;
case TokenType.WaitOnPunctuationEnd:
dialogText.punctuationPause = punctuationPause;
break;
case TokenType.Clear:
dialogText.Clear();
break;
case TokenType.Speed:
case TokenType.SpeedStart:
float newSpeed = 0;
if (!Single.TryParse(token.param, out newSpeed))
{
@ -249,19 +360,99 @@ namespace Fungus
dialogText.writingSpeed = newSpeed;
break;
case TokenType.Exit:
case TokenType.SpeedEnd:
dialogText.writingSpeed = writingSpeed;
break;
case TokenType.Exit:
if (onExitTag != null)
{
prevStoryText = storyText.text;
Destroy(typingAudio);
onExitTag();
}
yield break;
case TokenType.Message:
FungusScript.BroadcastFungusMessage(token.param);
break;
case TokenType.VerticalPunch:
float vPunchIntensity = 0;
if (!Single.TryParse(token.param, out vPunchIntensity))
{
vPunchIntensity = 0f;
}
VerticalPunch(vPunchIntensity);
break;
case TokenType.HorizontalPunch:
float hPunchIntensity = 0;
if (!Single.TryParse(token.param, out hPunchIntensity))
{
hPunchIntensity = 0f;
}
HorizontalPunch(hPunchIntensity);
break;
case TokenType.Shake:
float shakeIntensity = 0;
if (!Single.TryParse(token.param, out shakeIntensity))
{
shakeIntensity = 0f;
}
Shake(shakeIntensity);
break;
case TokenType.Shiver:
float shiverIntensity = 0;
if (!Single.TryParse(token.param, out shiverIntensity))
{
shiverIntensity = 0f;
}
Shiver(shiverIntensity);
break;
case TokenType.Flash:
float flashDuration = 0;
if (!Single.TryParse(token.param, out flashDuration))
{
flashDuration = 0f;
}
Flash(flashDuration);
break;
case TokenType.Audio:
{
AudioSource audioSource = FindAudio(token.param);
if (audioSource != null)
{
audioSource.PlayOneShot(audioSource.clip);
}
}
break;
case TokenType.AudioLoop:
{
AudioSource audioSource = FindAudio(token.param);
if (audioSource != null)
{
audioSource.Play();
audioSource.loop = true;
}
}
break;
case TokenType.AudioPause:
{
AudioSource audioSource = FindAudio(token.param);
if (audioSource != null)
{
audioSource.Pause ();
}
}
break;
case TokenType.AudioStop:
{
AudioSource audioSource = FindAudio(token.param);
if (audioSource != null)
{
audioSource.Pause ();
}
}
break;
}
// Update text writing
@ -276,6 +467,8 @@ namespace Fungus
// Now process next token
}
prevStoryText = storyText.text;
Destroy(typingAudio);
if (onWritingComplete != null)
@ -286,6 +479,47 @@ namespace Fungus
yield break;
}
protected virtual AudioSource FindAudio(string audioObjectName)
{
GameObject go = GameObject.Find(audioObjectName);
if (go == null)
{
return null;
}
return go.audio;
}
protected virtual void VerticalPunch(float intensity)
{
iTween.ShakePosition(this.gameObject, new Vector3(0f, intensity, 0f), 0.5f);
}
protected virtual void HorizontalPunch(float intensity)
{
iTween.ShakePosition(this.gameObject, new Vector3(intensity, 0f, 0f), 0.5f);
}
protected virtual void Shake(float intensity)
{
iTween.ShakePosition(this.gameObject, new Vector3(intensity, intensity, 0f), 0.5f);
}
protected virtual void Shiver(float intensity)
{
iTween.ShakePosition(this.gameObject, new Vector3(intensity, intensity, 0f), 1f);
}
protected virtual void Flash(float duration)
{
CameraController cameraController = CameraController.GetInstance();
cameraController.screenFadeTexture = CameraController.CreateColorTexture(new Color(1f,1f,1f,1f), 32, 32);
cameraController.Fade(1f, duration, delegate {
cameraController.screenFadeTexture = CameraController.CreateColorTexture(new Color(1f,1f,1f,1f), 32, 32);
cameraController.Fade(0f, duration, delegate {Destroy(cameraController);});
});
}
public virtual void Clear()
{
ClearStoryText();
@ -316,11 +550,31 @@ namespace Fungus
{
yield return null;
}
wasPointerClicked = false;
if (onInput != null)
{
// Stop all tweening portraits
foreach( Character c in Character.activeCharacters )
{
if (c.state.portraitImage != null)
{
if (LeanTween.isTweening(c.state.portraitObj))
{
LeanTween.cancel(c.state.portraitObj, true);
c.state.portraitImage.material.SetFloat( "_Fade", 1 );
Portrait.SetRectTransform(c.state.portraitImage.rectTransform, c.state.position);
if (c.state.dimmed == true)
{
c.state.portraitImage.material.SetColor("_Color", new Color(0.5f,0.5f,0.5f,1f));
}
else
{
c.state.portraitImage.material.SetColor("_Color", new Color(1f,1f,1f,1f));
}
}
}
}
onInput();
}
}

69
Assets/Fungus/Dialog/Scripts/DialogParser.cs

@ -17,11 +17,22 @@ namespace Fungus
Wait, // w, w=0.5
WaitForInputNoClear, // wi
WaitForInputAndClear, // wc
WaitOnPunctuation, // wp, wp=0.5
WaitOnPunctuationStart, // wp, wp=0.5
WaitOnPunctuationEnd, // /wp
Clear, // c
Speed, // s, s=60
SpeedStart, // s, s=60
SpeedEnd, // /s
Exit, // x
Message // m=MessageName
Message, // m=MessageName
VerticalPunch, // {vpunch=0.5}
HorizontalPunch, // {hpunch=0.5}
Shake, // {shake=0.5}
Shiver, // {shiver=0.5}
Flash, // {flash=0.5}
Audio, // {audio=Sound}
AudioLoop, // {audioloop=Sound}
AudioPause, // {audiopause=Sound}
AudioStop // {audiostop=Sound}
}
public class Token
@ -121,12 +132,16 @@ namespace Fungus
}
else if (tag.StartsWith("wp="))
{
type = TokenType.WaitOnPunctuation;
type = TokenType.WaitOnPunctuationStart;
paramText = tag.Substring(3, tag.Length - 3);
}
else if (tag == "wp")
{
type = TokenType.WaitOnPunctuation;
type = TokenType.WaitOnPunctuationStart;
}
else if (tag == "/wp")
{
type = TokenType.WaitOnPunctuationEnd;
}
else if (tag.StartsWith("w="))
{
@ -143,12 +158,16 @@ namespace Fungus
}
else if (tag.StartsWith("s="))
{
type = TokenType.Speed;
type = TokenType.SpeedStart;
paramText = tag.Substring(2, tag.Length - 2);
}
else if (tag == "s")
{
type = TokenType.Speed;
type = TokenType.SpeedStart;
}
else if (tag == "/s")
{
type = TokenType.SpeedEnd;
}
else if (tag == "x")
{
@ -159,7 +178,41 @@ namespace Fungus
type = TokenType.Message;
paramText = tag.Substring(2, tag.Length - 2);
}
else if (tag.StartsWith("vpunch="))
{
type = TokenType.VerticalPunch;
paramText = tag.Substring(7, tag.Length - 7);
}
else if (tag.StartsWith("hpunch="))
{
type = TokenType.HorizontalPunch;
paramText = tag.Substring(7, tag.Length - 7);
}
else if (tag.StartsWith("shake="))
{
type = TokenType.Shake;
paramText = tag.Substring(6, tag.Length - 6);
}
else if (tag.StartsWith("shiver="))
{
type = TokenType.Shiver;
paramText = tag.Substring(7, tag.Length - 7);
}
else if (tag.StartsWith("flash="))
{
type = TokenType.Flash;
paramText = tag.Substring(6, tag.Length - 6);
}
else if (tag.StartsWith("audio="))
{
type = TokenType.Audio;
paramText = tag.Substring(6, tag.Length - 6);
}
else if (tag.StartsWith("audioloop="))
{
type = TokenType.AudioLoop;
paramText = tag.Substring(10, tag.Length - 10);
}
Token token = new Token();
token.type = type;
token.param = paramText.Trim();

22
Assets/Fungus/Dialog/Scripts/DialogText.cs

@ -18,6 +18,7 @@ namespace Fungus
public class DialogText
{
protected List<Glyph> glyphs = new List<Glyph>();
protected bool oneBeep = false;
public bool boldActive { get; set; }
public bool italicActive { get; set; }
@ -26,6 +27,9 @@ namespace Fungus
public float writingSpeed { get; set; }
public float punctuationPause { get; set; }
public AudioSource typingAudio { get; set; }
public float slowBeepsAt { get; set; }
public float fastBeepsAt { get; set; }
public bool beepPerCharacter { get; set; }
public virtual void Clear()
{
@ -34,9 +38,14 @@ namespace Fungus
public virtual void Append(string words)
{
if (beepPerCharacter && (writingSpeed <= slowBeepsAt || writingSpeed >= fastBeepsAt)) // beeps match character speed at these speeds
oneBeep = true;
else
oneBeep = false;
if (typingAudio != null)
{
typingAudio.Stop();
if (!oneBeep)
typingAudio.Play();
}
@ -59,7 +68,7 @@ namespace Fungus
Glyph glyph = new Glyph();
glyph.hideTimer = hideTimer;
if (doPunctuationPause)
if (doPunctuationPause && writingSpeed != 0)
{
glyph.hasPunctuationPause = true;
glyph.hideTimer += punctuationPause;
@ -73,8 +82,7 @@ namespace Fungus
glyph.colorText = colorText;
glyphs.Add(glyph);
if (i < words.Length - 1 &&
IsPunctuation(c)) // No punctuation pause on last character, or if next character is also punctuation
if (IsPunctuation(c)) // If punctuation, do punctuation pause
{
doPunctuationPause = true;
}
@ -130,6 +138,14 @@ namespace Fungus
elapsedTime -= glyph.hideTimer;
glyph.hideTimer = 0f;
// Some elapsed time left over, so carry on to next glyph
if ((oneBeep && typingAudio != null))
{
if(!typingAudio.isPlaying &&
(glyph.character != " " && glyph.character != "\t" && glyph.character != "\n" ) )
{
typingAudio.PlayOneShot(typingAudio.clip);
}
}
}
else
{

73
Assets/Fungus/Dialog/Scripts/MenuDialog.cs

@ -10,9 +10,40 @@ namespace Fungus
public class MenuDialog : MonoBehaviour
{
// Currently active Menu Dialog used to display Menu options
public static MenuDialog activeMenuDialog;
protected Button[] cachedButtons;
protected Slider cachedSlider;
public static MenuDialog GetMenuDialog()
{
if (activeMenuDialog == null)
{
// Use first Menu Dialog found in the scene (if any)
MenuDialog md = GameObject.FindObjectOfType<MenuDialog>();
if (md != null)
{
activeMenuDialog = md;
}
if (activeMenuDialog == null)
{
// Auto spawn a menu dialog object from the prefab
GameObject go = Resources.Load<GameObject>("FungusMenuDialog");
if (go != null)
{
GameObject spawnedGO = Instantiate(go) as GameObject;
spawnedGO.name = "DialogMenu";
spawnedGO.SetActive(false);
activeMenuDialog = spawnedGO.GetComponent<MenuDialog>();
}
}
}
return activeMenuDialog;
}
public virtual void Awake()
{
Button[] optionButtons = GetComponentsInChildren<Button>();
@ -21,8 +52,12 @@ namespace Fungus
Slider timeoutSlider = GetComponentInChildren<Slider>();
cachedSlider = timeoutSlider;
if (Application.isPlaying)
{
// Don't auto disable buttons in the editor
Clear();
}
}
public virtual void OnEnable()
{
@ -58,7 +93,6 @@ namespace Fungus
public virtual bool AddOption(string text, Sequence targetSequence)
{
gameObject.SetActive(true);
bool addedOption = false;
foreach (Button button in cachedButtons)
@ -79,14 +113,8 @@ namespace Fungus
StopAllCoroutines(); // Stop timeout
Clear();
gameObject.SetActive(false);
// Hide the active Say dialog in case it's still being displayed
SayDialog activeSayDialog = SetSayDialog.GetActiveSayDialog();
if (activeSayDialog != null)
{
activeSayDialog.ShowDialog(false);
}
HideSayDialog();
if (sequence != null)
{
@ -96,6 +124,8 @@ namespace Fungus
fungusScript.selectedSequence = sequence;
#endif
gameObject.SetActive(false);
sequence.ExecuteCommand(0);
}
});
@ -108,9 +138,32 @@ namespace Fungus
return addedOption;
}
protected virtual void HideSayDialog()
{
SayDialog sayDialog = SayDialog.GetSayDialog();
if (sayDialog != null)
{
bool fadingOut = false;
bool movingOut = false;
if (sayDialog.alwaysFadeDialog)
{
sayDialog.FadeOutDialog();
fadingOut = true;
}
if (sayDialog.alwaysMoveDialog)
{
sayDialog.MoveOutDialog();
movingOut = true;
}
if (!fadingOut && !movingOut)
{
sayDialog.ShowDialog(false);
}
}
}
public virtual void ShowTimer(float duration, Sequence targetSequence)
{
gameObject.SetActive(true);
if (cachedSlider != null)
{
@ -142,6 +195,8 @@ namespace Fungus
Clear();
gameObject.SetActive(false);
HideSayDialog();
if (targetSequence != null)
{
targetSequence.ExecuteCommand(0);

31
Assets/Fungus/Dialog/Scripts/SayDialog.cs

@ -7,24 +7,39 @@ using System.Collections.Generic;
namespace Fungus
{
[ExecuteInEditMode]
public class SayDialog : Dialog
{
// Currently active Say Dialog used to display Say text
public static SayDialog activeSayDialog;
public Image continueImage;
static public List<SayDialog> activeDialogs = new List<SayDialog>();
public static SayDialog GetSayDialog()
{
if (activeSayDialog == null)
{
// Use first Say Dialog found in the scene (if any)
SayDialog sd = GameObject.FindObjectOfType<SayDialog>();
if (sd != null)
{
activeSayDialog = sd;
}
protected virtual void OnEnable()
if (activeSayDialog == null)
{
if (!activeDialogs.Contains(this))
// Auto spawn a say dialog object from the prefab
GameObject go = Resources.Load<GameObject>("FungusSayDialog");
if (go != null)
{
activeDialogs.Add(this);
GameObject spawnedGO = Instantiate(go) as GameObject;
spawnedGO.name = "SayDialog";
spawnedGO.SetActive(false);
activeSayDialog = spawnedGO.GetComponent<SayDialog>();
}
}
}
protected virtual void OnDisable()
{
activeDialogs.Remove(this);
return activeSayDialog;
}
public virtual void Say(string text, bool waitForInput, Action onComplete)

47
Assets/Fungus/FungusScript/Editor/AssetModProcessor.cs

@ -0,0 +1,47 @@
using UnityEngine;
using UnityEditor;
using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;
namespace Fungus
{
/**
* Prevents saving of selected sequence and commands to avoid version control conflicts
*/
public class AssetModProcessor : UnityEditor.AssetModificationProcessor
{
public static string[] OnWillSaveAssets(string[] paths)
{
string sceneName = "";
foreach (string path in paths)
{
if (path.Contains(".unity"))
{
sceneName = Path.GetFileNameWithoutExtension(path);
}
}
if (sceneName.Length == 0)
{
return paths;
}
// Reset these variables before save so that they won't cause a git conflict
FungusScript[] allFungusScripts = UnityEngine.Object.FindObjectsOfType<FungusScript>();
foreach (FungusScript fs in allFungusScripts)
{
if (!fs.saveSelection)
{
fs.selectedSequence = null;
fs.ClearSelectedCommands();
}
}
return paths;
}
}
}

8
Assets/Fungus/FungusScript/Editor/AssetModProcessor.cs.meta

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: b8ec97c8f203acf4fb2b799319f4c848
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

17
Assets/Fungus/FungusScript/Editor/FungusScriptEditor.cs

@ -11,13 +11,13 @@ namespace Fungus
[CustomEditor (typeof(FungusScript))]
public class FungusScriptEditor : Editor
{
protected SerializedProperty descriptionProp;
protected SerializedProperty defaultPortraitStageProp;
protected class AddVariableInfo
{
public FungusScript fungusScript;
public System.Type variableType;
}
protected SerializedProperty descriptionProp;
protected SerializedProperty colorCommandsProp;
protected SerializedProperty hideComponentsProp;
protected SerializedProperty runSlowDurationProp;
@ -26,6 +26,7 @@ namespace Fungus
protected virtual void OnEnable()
{
descriptionProp = serializedObject.FindProperty("description");
defaultPortraitStageProp = serializedObject.FindProperty("defaultPortraitStage");
colorCommandsProp = serializedObject.FindProperty("colorCommands");
hideComponentsProp = serializedObject.FindProperty("hideComponents");
runSlowDurationProp = serializedObject.FindProperty("runSlowDuration");
@ -41,6 +42,7 @@ namespace Fungus
fungusScript.UpdateHideFlags();
EditorGUILayout.PropertyField(descriptionProp);
EditorGUILayout.PropertyField(defaultPortraitStageProp);
EditorGUILayout.PropertyField(colorCommandsProp);
EditorGUILayout.PropertyField(hideComponentsProp);
EditorGUILayout.PropertyField(runSlowDurationProp);
@ -81,6 +83,16 @@ namespace Fungus
if (t.variables.Count > 0)
{
// Remove any null variables from the list
// Can sometimes happen when upgrading to a new version of Fungus (if .meta GUID changes for a variable class)
for (int i = t.variables.Count - 1; i >= 0; i--)
{
if (t.variables[i] == null)
{
t.variables.RemoveAt(i);
}
}
ReorderableListGUI.Title("Variables");
VariableListAdaptor adaptor = new VariableListAdaptor(variablesProp, 0);
@ -124,7 +136,6 @@ namespace Fungus
GUI.Button(plusRect, FungusEditorResources.texAddButton))
{
GenericMenu menu = new GenericMenu ();
List<System.Type> types = FindAllDerivedTypes<Variable>();
// Add variable types without a category

10
Assets/Fungus/FungusScript/Editor/FungusScriptWindow.cs

@ -148,7 +148,7 @@ namespace Fungus
GUILayout.Space(8);
if (GUILayout.Button(FungusEditorResources.texAddButton))
if (GUILayout.Button(new GUIContent(FungusEditorResources.texAddButton, "Add a new sequence")))
{
Vector2 newNodePosition = new Vector2(50 - fungusScript.scrollPos.x,
50 - fungusScript.scrollPos.y);
@ -504,6 +504,8 @@ namespace Fungus
}
}
nodeStyleCopy.normal.textColor = Color.black;
// Show event handler name, or a custom summary if one is provided
string nodeName = "";
if (sequence.eventHandler != null)
@ -525,10 +527,14 @@ namespace Fungus
float width = nodeStyleCopy.CalcSize(new GUIContent(nodeName)).x;
sequence.nodeRect.width = Mathf.Max (sequence.nodeRect.width, width);
GUI.backgroundColor = Color.white;
GUILayout.Box(nodeName, nodeStyleCopy, GUILayout.Width(sequence.nodeRect.width), GUILayout.Height(sequence.nodeRect.height));
if (sequence.description.Length > 0)
{
GUILayout.Label(sequence.description, EditorStyles.whiteLabel);
GUIStyle descriptionStyle = new GUIStyle(EditorStyles.whiteLabel);
descriptionStyle.wordWrap = true;
GUILayout.Label(sequence.description, descriptionStyle);
}
if (Event.current.type == EventType.ContextClick)

9
Assets/Fungus/FungusScript/Scripts/Commands/Reset.cs

@ -13,15 +13,12 @@ namespace Fungus
[Tooltip("Reset state of all commands in the script")]
public bool resetCommands = true;
[Tooltip("Reset local variables back to their default values")]
public bool resetLocalVariables = true;
[Tooltip("Reset global variables back to their default values")]
public bool resetGlobalVariables = true;
[Tooltip("Reset variables back to their default values")]
public bool resetVariables = true;
public override void OnEnter()
{
GetFungusScript().Reset(resetCommands, resetLocalVariables, resetGlobalVariables);
GetFungusScript().Reset(resetCommands, resetVariables);
Continue();
}

29
Assets/Fungus/FungusScript/Scripts/FungusScript.cs

@ -64,6 +64,12 @@ namespace Fungus
[Tooltip("Description text displayed in the Fungus Script editor window")]
public string description = "";
/**
* Portrait Stage to use for this game.
*/
[Tooltip("Default stage to display portraits on")]
public PortraitStage defaultPortraitStage;
/**
* Minimum time for each command to execute when runSlowInEditor is enabled.
*/
@ -84,6 +90,13 @@ namespace Fungus
[Tooltip("Hides the Fungus Script sequence and command components in the inspector")]
public bool hideComponents = true;
/**
* Saves the selected sequence and commands when saving the scene.
* Helps avoid version control conflicts if you've only changed the active selection.
*/
[Tooltip("Saves the selected sequence and commands when saving the scene.")]
public bool saveSelection = true;
protected virtual Sequence CreateSequenceComponent(GameObject parent)
{
Sequence s = parent.AddComponent<Sequence>();
@ -233,7 +246,7 @@ namespace Fungus
// No empty keys allowed
if (baseKey.Length == 0)
{
baseKey = "Sequence";
baseKey = "New Sequence";
}
Sequence[] sequences = GetComponentsInChildren<Sequence>();
@ -276,7 +289,7 @@ namespace Fungus
// No empty keys allowed
if (baseKey.Length == 0)
{
baseKey = "Label";
baseKey = "New Label";
}
Sequence sequence = ignoreLabel.parentSequence;
@ -572,7 +585,7 @@ namespace Fungus
}
}
public virtual void Reset(bool resetCommands, bool resetLocalVariables, bool resetGlobalVariables)
public virtual void Reset(bool resetCommands, bool resetVariables)
{
if (resetCommands)
{
@ -583,15 +596,9 @@ namespace Fungus
}
}
foreach (Variable variable in variables)
{
if (resetLocalVariables &&
variable.scope == VariableScope.Private)
if (resetVariables)
{
variable.OnReset();
}
else if (resetGlobalVariables &&
variable.scope == VariableScope.Public)
foreach (Variable variable in variables)
{
variable.OnReset();
}

2
Assets/Fungus/FungusScript/Scripts/Sequence.cs

@ -10,7 +10,7 @@ namespace Fungus
[AddComponentMenu("")]
public class Sequence : Node
{
public string sequenceName = "Sequence";
public string sequenceName = "New Sequence";
[TextArea(2, 5)]
[Tooltip("Description text to display under the sequence node")]

5
Assets/Fungus/Portrait.meta

@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: 0018d8c9e4d14f043af5b7e5b48e7b50
folderAsset: yes
DefaultImporter:
userData:

5
Assets/Fungus/Portrait/Editor.meta

@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: 36924863aa1cb9a41814e08237c0418a
folderAsset: yes
DefaultImporter:
userData:

299
Assets/Fungus/Portrait/Editor/PortraitEditor.cs

@ -0,0 +1,299 @@
using UnityEditor;
using UnityEditorInternal;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Events;
using System;
using System.Collections;
using System.Collections.Generic;
using Rotorz.ReorderableList;
namespace Fungus
{
[CustomEditor (typeof(Portrait))]
public class PortraitEditor : CommandEditor
{
protected SerializedProperty portraitStageProp;
protected SerializedProperty displayProp;
protected SerializedProperty characterProp;
protected SerializedProperty replacedCharacterProp;
protected SerializedProperty portraitProp;
protected SerializedProperty offsetProp;
protected SerializedProperty fromPositionProp;
protected SerializedProperty toPositionProp;
protected SerializedProperty facingProp;
protected SerializedProperty useDefaultSettingsProp;
protected SerializedProperty fadeDurationProp;
protected SerializedProperty moveSpeedProp;
protected SerializedProperty shiftOffsetProp;
protected SerializedProperty waitUntilFinishedProp;
protected SerializedProperty moveProp;
protected SerializedProperty shiftIntoPlaceProp;
protected virtual void OnEnable()
{
portraitStageProp = serializedObject.FindProperty("portraitStage");
displayProp = serializedObject.FindProperty("display");
characterProp = serializedObject.FindProperty("character");
replacedCharacterProp = serializedObject.FindProperty("replacedCharacter");
portraitProp = serializedObject.FindProperty("portrait");
offsetProp = serializedObject.FindProperty("offset");
fromPositionProp = serializedObject.FindProperty("fromPosition");
toPositionProp = serializedObject.FindProperty("toPosition");
facingProp = serializedObject.FindProperty("facing");
useDefaultSettingsProp = serializedObject.FindProperty("useDefaultSettings");
fadeDurationProp = serializedObject.FindProperty("fadeDuration");
moveSpeedProp = serializedObject.FindProperty("moveSpeed");
shiftOffsetProp = serializedObject.FindProperty("shiftOffset");
waitUntilFinishedProp = serializedObject.FindProperty("waitUntilFinished");
moveProp = serializedObject.FindProperty("move");
shiftIntoPlaceProp = serializedObject.FindProperty("shiftIntoPlace");
}
public override void DrawCommandGUI()
{
serializedObject.Update();
Portrait t = target as Portrait;
if (PortraitStage.activePortraitStages.Count > 1)
{
CommandEditor.ObjectField<PortraitStage>(portraitStageProp,
new GUIContent("Portrait Stage", "Stage to display the character portraits on"),
new GUIContent("<Default>"),
PortraitStage.activePortraitStages);
}
else
{
t.portraitStage = null;
}
// Format Enum names
string[] displayLabels = StringFormatter.FormatEnumNames(t.display,"<None>");
displayProp.enumValueIndex = EditorGUILayout.Popup("Display", (int)displayProp.enumValueIndex, displayLabels);
string characterLabel = "Character";
if (t.display == DisplayType.Replace)
{
CommandEditor.ObjectField<Character>(replacedCharacterProp,
new GUIContent("Replace", "Character to replace"),
new GUIContent("<None>"),
Character.activeCharacters);
characterLabel = "With";
}
CommandEditor.ObjectField<Character>(characterProp,
new GUIContent(characterLabel, "Character to display"),
new GUIContent("<None>"),
Character.activeCharacters);
bool showOptionalFields = true;
PortraitStage ps = t.portraitStage;
// Only show optional portrait fields once required fields have been filled...
if (t.character != null) // Character is selected
{
if (t.character.portraits == null || // Character has a portraits field
t.character.portraits.Count <= 0 ) // Character has at least one portrait
{
EditorGUILayout.HelpBox("This character has no portraits. Please add portraits to the character's prefab before using this command.", MessageType.Error);
showOptionalFields = false;
}
if (t.portraitStage == null) // If default portrait stage selected
{
ps = t.GetFungusScript().defaultPortraitStage;; // Try to get game's default portrait stage
if (t.portraitStage == null) // If no default specified, try to get any portrait stage in the scene
{
ps = GameObject.FindObjectOfType<PortraitStage>();
}
}
if (ps == null)
{
EditorGUILayout.HelpBox("No portrait stage has been set. Please create a new portrait stage using [Game Object > Fungus > Portrait > Portrait Stage].", MessageType.Error);
showOptionalFields = false;
}
}
if (t.display != DisplayType.None && t.character != null && showOptionalFields)
{
if (t.display != DisplayType.Hide && t.display != DisplayType.MoveToFront)
{
// PORTRAIT
CommandEditor.ObjectField<Sprite>(portraitProp,
new GUIContent("Portrait", "Portrait representing character"),
new GUIContent("<Previous>"),
t.character.portraits);
if (t.character.portraitsFace != FacingDirection.None)
{
// FACING
// Display the values of the facing enum as <-- and --> arrows to avoid confusion with position field
string[] facingArrows = new string[]
{
"<Previous>",
"<--",
"-->",
};
facingProp.enumValueIndex = EditorGUILayout.Popup("Facing", (int)facingProp.enumValueIndex, facingArrows);
}
else
{
t.facing = FacingDirection.None;
}
}
else
{
t.portrait = null;
t.facing = FacingDirection.None;
}
string toPositionPrefix = "";
if (t.move)
{
// MOVE
EditorGUILayout.PropertyField(moveProp);
}
if (t.move)
{
if (t.display != DisplayType.Hide)
{
// START FROM OFFSET
EditorGUILayout.PropertyField(shiftIntoPlaceProp);
}
}
if (t.move)
{
if (t.display != DisplayType.Hide)
{
if (t.shiftIntoPlace)
{
t.fromPosition = null;
// OFFSET
// Format Enum names
string[] offsetLabels = StringFormatter.FormatEnumNames(t.offset,"<Previous>");
offsetProp.enumValueIndex = EditorGUILayout.Popup("From Offset", (int)offsetProp.enumValueIndex, offsetLabels);
}
else
{
t.offset = PositionOffset.None;
// FROM POSITION
CommandEditor.ObjectField<RectTransform>(fromPositionProp,
new GUIContent("From Position", "Move the portrait to this position"),
new GUIContent("<Previous>"),
ps.positions);
}
}
toPositionPrefix = "To ";
}
else
{
t.shiftIntoPlace = false;
t.fromPosition = null;
toPositionPrefix = "At ";
}
if (t.display == DisplayType.Show || (t.display == DisplayType.Hide && t.move) )
{
// TO POSITION
CommandEditor.ObjectField<RectTransform>(toPositionProp,
new GUIContent(toPositionPrefix+"Position", "Move the portrait to this position"),
new GUIContent("<Previous>"),
ps.positions);
}
else
{
t.toPosition = null;
}
if (!t.move && t.display != DisplayType.MoveToFront)
{
// MOVE
EditorGUILayout.PropertyField(moveProp);
}
if (t.display != DisplayType.MoveToFront)
{
EditorGUILayout.Separator();
// USE DEFAULT SETTINGS
EditorGUILayout.PropertyField(useDefaultSettingsProp);
if (!t.useDefaultSettings) {
// FADE DURATION
EditorGUILayout.PropertyField(fadeDurationProp);
if (t.move)
{
// MOVE SPEED
EditorGUILayout.PropertyField(moveSpeedProp);
}
if (t.shiftIntoPlace)
{
// SHIFT OFFSET
EditorGUILayout.PropertyField(shiftOffsetProp);
}
}
}
else
{
t.move = false;
t.useDefaultSettings = true;
EditorGUILayout.Separator();
}
EditorGUILayout.PropertyField(waitUntilFinishedProp);
if (t.portrait != null && t.display != DisplayType.Hide)
{
Texture2D characterTexture = t.portrait.texture;
float aspect = (float)characterTexture.width / (float)characterTexture.height;
Rect previewRect = GUILayoutUtility.GetAspectRect(aspect, GUILayout.Width(100), GUILayout.ExpandWidth(true));
if (characterTexture != null)
{
GUI.DrawTexture(previewRect,characterTexture,ScaleMode.ScaleToFit,true,aspect);
}
}
if (t.display != DisplayType.Hide)
{
string portraitName = "<Previous>";
if (t.portrait != null)
{
portraitName = t.portrait.name;
}
string portraitSummary = " " + portraitName;
int toolbarInt = 1;
string[] toolbarStrings = {"<--", portraitSummary, "-->"};
toolbarInt = GUILayout.Toolbar (toolbarInt, toolbarStrings, GUILayout.MinHeight(20));
int portraitIndex = -1;
if (toolbarInt != 1)
{
for(int i=0; i<t.character.portraits.Count; i++){
if(portraitName == t.character.portraits[i].name)
{
portraitIndex = i;
}
}
}
if (toolbarInt == 0)
{
if(portraitIndex > 0)
{
t.portrait = t.character.portraits[--portraitIndex];
}
else
{
t.portrait = null;
}
}
if (toolbarInt == 2)
{
if(portraitIndex < t.character.portraits.Count-1)
{
t.portrait = t.character.portraits[++portraitIndex];
}
}
}
}
serializedObject.ApplyModifiedProperties();
}
}
}

8
Assets/Fungus/Portrait/Editor/PortraitEditor.cs.meta

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 032df7ff81b5ed44ca49742672a12676
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

91
Assets/Fungus/Portrait/Editor/StageEditor.cs

@ -0,0 +1,91 @@
using UnityEditor;
using UnityEditorInternal;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Events;
using System;
using System.Collections;
using System.Collections.Generic;
using Rotorz.ReorderableList;
namespace Fungus
{
[CustomEditor (typeof(Stage))]
public class StageEditor : CommandEditor
{
protected SerializedProperty displayProp;
protected SerializedProperty portraitStageProp;
protected SerializedProperty replacedPortraitStageProp;
protected SerializedProperty useDefaultSettingsProp;
protected SerializedProperty fadeDurationProp;
protected SerializedProperty waitUntilFinishedProp;
protected virtual void OnEnable()
{
displayProp = serializedObject.FindProperty("display");
portraitStageProp = serializedObject.FindProperty("portraitStage");
replacedPortraitStageProp = serializedObject.FindProperty("replacedPortraitStage");
useDefaultSettingsProp = serializedObject.FindProperty("useDefaultSettings");
fadeDurationProp = serializedObject.FindProperty("fadeDuration");
waitUntilFinishedProp = serializedObject.FindProperty("waitUntilFinished");
}
public override void DrawCommandGUI()
{
serializedObject.Update();
Stage t = target as Stage;
// Format Enum names
string[] displayLabels = StringFormatter.FormatEnumNames(t.display,"<None>");
displayProp.enumValueIndex = EditorGUILayout.Popup("Display", (int)displayProp.enumValueIndex, displayLabels);
string replaceLabel = "Portrait Stage";
if (t.display == StageDisplayType.Swap)
{
CommandEditor.ObjectField<PortraitStage>(replacedPortraitStageProp,
new GUIContent("Replace", "Character to swap with"),
new GUIContent("<Default>"),
PortraitStage.activePortraitStages);
replaceLabel = "With";
}
if (PortraitStage.activePortraitStages.Count > 1)
{
CommandEditor.ObjectField<PortraitStage>(portraitStageProp,
new GUIContent(replaceLabel, "Stage to display the character portraits on"),
new GUIContent("<Default>"),
PortraitStage.activePortraitStages);
}
bool showOptionalFields = true;
PortraitStage ps = t.portraitStage;
// Only show optional portrait fields once required fields have been filled...
if (t.portraitStage != null) // Character is selected
{
ps = t.GetFungusScript().defaultPortraitStage;; // Try to get game's default portrait stage
if (t.portraitStage == null) // If no default specified, try to get any portrait stage in the scene
{
ps = GameObject.FindObjectOfType<PortraitStage>();
}
if (ps == null)
{
EditorGUILayout.HelpBox("No portrait stage has been set. Please create a new portrait stage using [Game Object > Fungus > Portrait > Portrait Stage].", MessageType.Error);
showOptionalFields = false;
}
}
if (t.display != StageDisplayType.None && showOptionalFields)
{
EditorGUILayout.PropertyField(useDefaultSettingsProp);
if (!t.useDefaultSettings)
{
EditorGUILayout.PropertyField(fadeDurationProp);
}
EditorGUILayout.PropertyField(waitUntilFinishedProp);
}
serializedObject.ApplyModifiedProperties();
}
}
}

8
Assets/Fungus/Portrait/Editor/StageEditor.cs.meta

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 26c89a989ebd4504d84ad27ce08064d1
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

482
Assets/Fungus/Portrait/Portrait.cs

@ -0,0 +1,482 @@
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Events;
using System;
using System.Collections;
using System.Collections.Generic;
namespace Fungus
{
public struct PortraitState
{
public bool onScreen;
public bool dimmed;
public DisplayType display;
public Sprite portrait;
public RectTransform position;
public FacingDirection facing;
public GameObject portraitObj;
public Image portraitImage;
}
public enum DisplayType
{
None,
Show,
Hide,
Replace,
MoveToFront
}
public enum FacingDirection
{
None,
Left,
Right
}
public enum PositionOffset
{
None,
OffsetLeft,
OffsetRight
}
[CommandInfo("Portrait",
"Portrait",
"Controls a character portrait. ")]
public class Portrait : Command
{
[Tooltip("Display type")]
public PortraitStage portraitStage;
[Tooltip("Display type")]
public DisplayType display;
[Tooltip("Character to display")]
public Character character;
[Tooltip("Character to swap with")]
public Character replacedCharacter;
[Tooltip("Portrait to display")]
public Sprite portrait;
[Tooltip("Move the portrait from/to this offset position")]
public PositionOffset offset;
[Tooltip("Move the portrait from this position")]
public RectTransform fromPosition;
protected RectTransform fromPositionition;
[Tooltip("Move the portrait to this positoin")]
public RectTransform toPosition;
protected RectTransform toPositionition;
[Tooltip("Direction character is facing")]
public FacingDirection facing;
[Tooltip("Use Default Settings")]
public bool useDefaultSettings = true;
[Tooltip("Fade Duration")]
public float fadeDuration;
[Tooltip("Movement Speed")]
public float moveSpeed;
[Tooltip("Shift Offset")]
public Vector2 shiftOffset;
[Tooltip("Move")]
public bool move;
[Tooltip("Start from offset")]
public bool shiftIntoPlace;
[Tooltip("Wait until the tween has finished before executing the next command")]
public bool waitUntilFinished = false;
public override void OnEnter()
{
// If no display specified, do nothing
if (display == DisplayType.None)
{
Continue();
return;
}
// If no character specified, do nothing
if (character == null)
{
Continue();
return;
}
// If Replace and no replaced character specified, do nothing
if (display == DisplayType.Replace && replacedCharacter == null)
{
Continue();
return;
}
// Selected "use default Portrait Stage"
if (portraitStage == null) // Default portrait stage selected
{
portraitStage = GetFungusScript().defaultPortraitStage;; // Try to get game's default portrait stage
if (portraitStage == null) // If no default specified, try to get any portrait stage in the scene
{
portraitStage = GameObject.FindObjectOfType<PortraitStage>();
}
}
// If portrait stage does not exist, do nothing
if (portraitStage == null)
{
Continue();
return;
}
if (character.state.portraitImage == null)
{
CreatePortraitObject(character,portraitStage);
}
// if no previous portrait, use default portrait
if (character.state.portrait == null)
{
character.state.portrait = character.profileSprite;
}
// Selected "use previous portrait"
if (portrait == null)
{
portrait = character.state.portrait;
}
// if no previous position, use default position
if (character.state.position == null)
{
character.state.position = portraitStage.defaultPosition.rectTransform;
}
// Selected "use previous position"
if (toPosition == null)
{
toPosition = character.state.position;
}
if (replacedCharacter != null)
{
// if no previous position, use default position
if (replacedCharacter.state.position == null)
{
replacedCharacter.state.position = portraitStage.defaultPosition.rectTransform;
}
}
// If swapping, use replaced character's position
if (display == DisplayType.Replace)
{
toPosition = replacedCharacter.state.position;
}
// Selected "use previous position"
if (fromPosition == null)
{
fromPosition = character.state.position;
}
// if portrait not moving, use from position is same as to position
if (!move)
{
fromPosition = toPosition;
}
if (display == DisplayType.Hide)
{
fromPosition = character.state.position;
}
// if no previous facing direction, use default facing direction
if (character.state.facing == FacingDirection.None)
{
character.state.facing = character.portraitsFace;
}
// Selected "use previous facing direction"
if (facing == FacingDirection.None)
{
facing = character.state.facing;
}
// Use default settings
if (useDefaultSettings)
{
fadeDuration = portraitStage.fadeDuration;
moveSpeed = portraitStage.moveSpeed;
shiftOffset = portraitStage.shiftOffset;
}
switch(display)
{
case (DisplayType.Show):
Show(character,fromPosition,toPosition);
character.state.onScreen = true;
portraitStage.charactersOnStage.Add(character);
break;
case (DisplayType.Hide):
Hide(character,fromPosition,toPosition);
character.state.onScreen = false;
portraitStage.charactersOnStage.Remove(character);
break;
case (DisplayType.Replace):
Show(character,fromPosition,toPosition);
Hide(replacedCharacter, replacedCharacter.state.position, replacedCharacter.state.position);
character.state.onScreen = true;
replacedCharacter.state.onScreen = false;
portraitStage.charactersOnStage.Add(character);
portraitStage.charactersOnStage.Remove(replacedCharacter);
break;
case (DisplayType.MoveToFront):
MoveToFront(character);
break;
}
if (display == DisplayType.Replace)
{
character.state.display = DisplayType.Show;
replacedCharacter.state.display = DisplayType.Hide;
}
else
{
character.state.display = display;
}
character.state.portrait = portrait;
character.state.facing = facing;
character.state.position = toPosition;
if (!waitUntilFinished)
{
Continue();
}
}
public static void CreatePortraitObject(Character character, PortraitStage portraitStage)
{
GameObject portraitObj = new GameObject(character.name, typeof(RectTransform), typeof(CanvasRenderer), typeof(Image));
portraitObj.transform.SetParent(portraitStage.portraitCanvas.transform, true);
Image portraitImage = portraitObj.GetComponent<Image>();
portraitImage.preserveAspect = true;
portraitImage.sprite = character.profileSprite;
Material portraitMaterial = Instantiate(Resources.Load("Portrait")) as Material;
portraitImage.material = portraitMaterial;
character.state.portraitObj = portraitObj;
character.state.portraitImage = portraitImage;
character.state.portraitImage.material.SetFloat("_Alpha",0);
}
protected void SetupPortrait(Character character, RectTransform fromPosition)
{
SetRectTransform(character.state.portraitImage.rectTransform, fromPosition);
character.state.portraitImage.material.SetFloat("_Fade",0);
character.state.portraitImage.material.SetTexture("_MainTex", character.profileSprite.texture);
Texture2D blankTexture = new Texture2D(1, 1, TextureFormat.ARGB32, false);
blankTexture.SetPixel(0, 0, new Color(0f,0f,0f,0f));
blankTexture.Apply();
character.state.portraitImage.material.SetTexture("_TexStart", blankTexture as Texture);
character.state.portraitImage.material.SetTexture("_TexEnd", blankTexture as Texture);
if (character.state.facing != character.portraitsFace)
{
character.state.portraitImage.material.SetFloat("_FlipStart",1);
}
else
{
character.state.portraitImage.material.SetFloat("_FlipStart",0);
}
if (facing != character.portraitsFace)
{
character.state.portraitImage.material.SetFloat("_FlipEnd",1);
}
else
{
character.state.portraitImage.material.SetFloat("_FlipEnd",0);
}
character.state.portraitImage.material.SetFloat("_Alpha",1);
}
public static void SetRectTransform(RectTransform oldRectTransform, RectTransform newRectTransform)
{
oldRectTransform.eulerAngles = newRectTransform.eulerAngles;
oldRectTransform.position = newRectTransform.position;
oldRectTransform.rotation = newRectTransform.rotation;
oldRectTransform.anchoredPosition = newRectTransform.anchoredPosition;
oldRectTransform.sizeDelta = newRectTransform.sizeDelta;
oldRectTransform.anchorMax = newRectTransform.anchorMax;
oldRectTransform.anchorMin = newRectTransform.anchorMin;
oldRectTransform.pivot = newRectTransform.pivot;
oldRectTransform.localScale = newRectTransform.localScale;
}
protected void Show(Character character, RectTransform fromPosition, RectTransform toPosition)
{
if (shiftIntoPlace)
{
fromPosition = Instantiate(toPosition) as RectTransform;
if (offset == PositionOffset.OffsetLeft)
{
fromPosition.anchoredPosition = new Vector2(fromPosition.anchoredPosition.x-Mathf.Abs(shiftOffset.x), fromPosition.anchoredPosition.y-Mathf.Abs(shiftOffset.y));
}
else if (offset == PositionOffset.OffsetRight)
{
fromPosition.anchoredPosition = new Vector2(fromPosition.anchoredPosition.x+Mathf.Abs(shiftOffset.x), fromPosition.anchoredPosition.y+Mathf.Abs(shiftOffset.y));
}
else
{
fromPosition.anchoredPosition = new Vector2(fromPosition.anchoredPosition.x, fromPosition.anchoredPosition.y);
}
}
SetupPortrait(character, fromPosition);
if (character.state.display != DisplayType.None && character.state.display != DisplayType.Hide)
{
character.state.portraitImage.material.SetTexture("_TexStart", character.state.portrait.texture);
}
character.state.portraitImage.material.SetTexture("_TexEnd", portrait.texture);
UpdateTweens(character, fromPosition, toPosition);
}
protected void Hide(Character character, RectTransform fromPosition, RectTransform toPosition)
{
if (character.state.display == DisplayType.None)
{
return;
}
SetupPortrait(character, fromPosition);
character.state.portraitImage.material.SetTexture("_TexStart", character.state.portrait.texture);
UpdateTweens(character, fromPosition, toPosition);
}
protected void MoveToFront(Character character)
{
character.state.portraitImage.transform.SetSiblingIndex(character.state.portraitImage.transform.parent.childCount);
}
protected void UpdateTweens(Character character, RectTransform fromPosition, RectTransform toPosition)
{
if (fadeDuration == 0) fadeDuration = float.Epsilon;
LeanTween.value(character.state.portraitObj,0,1,fadeDuration).setEase(portraitStage.fadeEaseType).setOnComplete(OnComplete).setOnUpdate(
(float fadeAmount)=>{
character.state.portraitImage.material.SetFloat("_Fade", fadeAmount);
}
);
float moveDuration = (Vector3.Distance(fromPosition.anchoredPosition,toPosition.anchoredPosition)/moveSpeed);
if (moveSpeed == 0) moveDuration = float.Epsilon;
LeanTween.value(character.state.portraitObj,fromPosition.anchoredPosition,toPosition.anchoredPosition,moveDuration).setEase(portraitStage.moveEaseType).setOnComplete(OnComplete).setOnUpdate(
(Vector3 updatePosition)=>{
character.state.portraitImage.rectTransform.anchoredPosition = updatePosition;
}
);
}
public static void Dim(Character character, PortraitStage portraitStage)
{
if (character.state.dimmed == false)
{
character.state.dimmed = true;
float fadeDuration = portraitStage.fadeDuration;
if (fadeDuration == 0) fadeDuration = float.Epsilon;
LeanTween.value(character.state.portraitObj,1f,0.5f,fadeDuration).setEase(portraitStage.fadeEaseType).setOnUpdate(
(float tintAmount)=>{
Color tint = new Color(tintAmount,tintAmount,tintAmount,1);
character.state.portraitImage.material.SetColor("_Color", tint);
}
);
}
}
public static void Undim(Character character, PortraitStage portraitStage)
{
if (character.state.dimmed == true)
{
character.state.dimmed = false;
float fadeDuration = portraitStage.fadeDuration;
if (fadeDuration == 0) fadeDuration = float.Epsilon;
LeanTween.value(character.state.portraitObj,0.5f,1f,fadeDuration).setEase(portraitStage.fadeEaseType).setOnUpdate(
(float tintAmount)=>{
Color tint = new Color(tintAmount,tintAmount,tintAmount,1);
character.state.portraitImage.material.SetColor("_Color", tint);
}
);
}
}
protected void OnComplete()
{
if (waitUntilFinished)
{
if (!LeanTween.isTweening (character.state.portraitObj))
{
Continue();
}
}
}
public override string GetSummary()
{
if (display == DisplayType.None && character == null)
{
return "Error: No character or display selected";
}
else if (display == DisplayType.None)
{
return "Error: No display selected";
}
else if (character == null)
{
return "Error: No character selected";
}
string displaySummary = "";
string characterSummary = "";
string fromPositionSummary = "";
string toPositionSummary = "";
string portraitStageSummary = "";
string portraitSummary = "";
string facingSummary = "";
displaySummary = StringFormatter.SplitCamelCase(display.ToString());
if (display == DisplayType.Replace)
{
if (replacedCharacter != null)
{
displaySummary += " \"" + replacedCharacter.name + "\" with";
}
}
characterSummary = character.name;
if (portraitStage != null)
{
portraitStageSummary = " on \"" + portraitStage.name + "\"";
}
if (portrait != null)
{
portraitSummary = " " + portrait.name;
}
if (shiftIntoPlace)
{
if (offset != 0)
{
fromPositionSummary = offset.ToString();
fromPositionSummary = " from " + "\"" + fromPositionSummary + "\"";
}
}
else if (fromPosition != null)
{
fromPositionSummary = " from " + "\"" + fromPosition.name + "\"";
}
if (toPosition != null)
{
string toPositionPrefixSummary = "";
if (move)
toPositionPrefixSummary = " to ";
else
toPositionPrefixSummary = " at ";
toPositionSummary = toPositionPrefixSummary + "\"" + toPosition.name + "\"";
}
if (facing != FacingDirection.None)
{
if ( facing == FacingDirection.Left )
{
facingSummary = "<--";
}
if ( facing == FacingDirection.Right )
{
facingSummary = "-->";
}
facingSummary = " facing \"" + facingSummary + "\"";
}
return displaySummary + " \"" + characterSummary + portraitSummary + "\"" + portraitStageSummary + facingSummary + fromPositionSummary + toPositionSummary;
}
public override Color GetButtonColor()
{
return new Color32(230, 200, 250, 255);
}
public override void OnCommandAdded(Sequence parentSequence)
{
//Default to display type: show
display = DisplayType.Show;
}
}
}

8
Assets/Fungus/Portrait/Portrait.cs.meta

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 3ac5ce55bc698fa4290939ef6e426501
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

41
Assets/Fungus/Portrait/PortraitStage.cs

@ -0,0 +1,41 @@
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Events;
using System;
using System.Collections;
using System.Collections.Generic;
namespace Fungus
{
public class PortraitStage : MonoBehaviour
{
public Canvas portraitCanvas;
public bool dimPortraits;
public float fadeDuration;
public float moveSpeed;
public LeanTweenType fadeEaseType;
public LeanTweenType moveEaseType;
public Vector2 shiftOffset;
public Image defaultPosition;
public List<RectTransform> positions;
public List<Character> charactersOnStage = new List<Character>();
[HideInInspector]
static public List<PortraitStage> activePortraitStages = new List<PortraitStage>();
[ExecuteInEditMode]
protected virtual void OnEnable()
{
if (!activePortraitStages.Contains(this))
{
activePortraitStages.Add(this);
}
}
[ExecuteInEditMode]
protected virtual void OnDisable()
{
activePortraitStages.Remove(this);
}
}
}

8
Assets/Fungus/Portrait/PortraitStage.cs.meta

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 6f6478b25a400c642b2dee75f022ab12
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

5
Assets/Fungus/Portrait/Prefabs.meta

@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: bc13409addc0175478468496602b7880
folderAsset: yes
DefaultImporter:
userData:

75
Assets/Fungus/Portrait/Prefabs/PortraitPosition.prefab

@ -0,0 +1,75 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &195640
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 4
m_Component:
- 224: {fileID: 22495640}
- 222: {fileID: 22295640}
- 114: {fileID: 11495640}
m_Layer: 0
m_Name: PortraitPosition
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &11495640
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 195640}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: -765806418, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 2100000, guid: 84ea47f59517f4ac1815f552cc8d60bc, type: 2}
m_Color: {r: 1, g: 1, b: 1, a: 0}
m_Sprite: {fileID: 21300000, guid: ea8f56c43254d41728f5ac4e8299b6c9, type: 3}
m_Type: 0
m_PreserveAspect: 1
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
--- !u!222 &22295640
CanvasRenderer:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 195640}
--- !u!224 &22495640
RectTransform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 195640}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_AnchorMin: {x: .5, y: 0}
m_AnchorMax: {x: .5, y: 0}
m_AnchoredPosition: {x: 0, y: 200}
m_SizeDelta: {x: 1000, y: 1000}
m_Pivot: {x: .5, y: 0}
--- !u!1001 &100100000
Prefab:
m_ObjectHideFlags: 1
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications: []
m_RemovedComponents: []
m_ParentPrefab: {fileID: 0}
m_RootGameObject: {fileID: 195640}
m_IsPrefabParent: 1
m_IsExploded: 1

4
Assets/Fungus/Portrait/Prefabs/PortraitPosition.prefab.meta

@ -0,0 +1,4 @@
fileFormatVersion: 2
guid: 7a4c270a5c18f6549a7683844dbf9f22
NativeFormatImporter:
userData:

479
Assets/Fungus/Portrait/Prefabs/PortraitStage.prefab

@ -0,0 +1,479 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &110270
GameObject:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 4
m_Component:
- 224: {fileID: 22410270}
- 222: {fileID: 22210270}
- 114: {fileID: 11410270}
m_Layer: 0
m_Name: Right
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!1 &110272
GameObject:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 4
m_Component:
- 224: {fileID: 22410272}
- 222: {fileID: 22210272}
- 114: {fileID: 11410272}
m_Layer: 0
m_Name: Offscreen Left
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!1 &110274
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 4
m_Component:
- 4: {fileID: 410270}
- 114: {fileID: 11410274}
m_Layer: 0
m_Name: PortraitStage
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!1 &110276
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 4
m_Component:
- 224: {fileID: 22410274}
- 223: {fileID: 22310270}
- 114: {fileID: 11410278}
- 114: {fileID: 11410276}
- 225: {fileID: 22510270}
m_Layer: 5
m_Name: Canvas
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!1 &110278
GameObject:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 4
m_Component:
- 224: {fileID: 22410276}
- 222: {fileID: 22210274}
- 114: {fileID: 11410280}
m_Layer: 0
m_Name: Middle
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!1 &110280
GameObject:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 4
m_Component:
- 224: {fileID: 22410278}
- 222: {fileID: 22210276}
- 114: {fileID: 11410282}
m_Layer: 0
m_Name: Offscreen Right
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!1 &110282
GameObject:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 4
m_Component:
- 224: {fileID: 22410280}
- 222: {fileID: 22210278}
- 114: {fileID: 11410284}
m_Layer: 0
m_Name: Left
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &410270
Transform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 110274}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -480.924713, y: -314.928009, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 22410274}
m_Father: {fileID: 0}
m_RootOrder: 0
--- !u!114 &11410270
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 110270}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: -765806418, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 0}
m_Sprite: {fileID: 21300000, guid: ea8f56c43254d41728f5ac4e8299b6c9, type: 3}
m_Type: 0
m_PreserveAspect: 1
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
--- !u!114 &11410272
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 110272}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: -765806418, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 0}
m_Sprite: {fileID: 21300000, guid: ea8f56c43254d41728f5ac4e8299b6c9, type: 3}
m_Type: 0
m_PreserveAspect: 1
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
--- !u!114 &11410274
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 110274}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 6f6478b25a400c642b2dee75f022ab12, type: 3}
m_Name:
m_EditorClassIdentifier:
portraitCanvas: {fileID: 22310270}
dimPortraits: 1
fadeDuration: .5
moveSpeed: 800
fadeEaseType: 1
moveEaseType: 4
slideOffset: {x: 300, y: 0}
defaultPosition: {fileID: 11410280}
positions:
- {fileID: 22410280}
- {fileID: 22410276}
- {fileID: 22410270}
- {fileID: 22410272}
- {fileID: 22410278}
--- !u!114 &11410276
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 110276}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 1980459831, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
m_Name:
m_EditorClassIdentifier:
m_UiScaleMode: 1
m_ReferencePixelsPerUnit: 100
m_ScaleFactor: 1
m_ReferenceResolution: {x: 1600, y: 1200}
m_ScreenMatchMode: 0
m_MatchWidthOrHeight: 1
m_PhysicalUnit: 3
m_FallbackScreenDPI: 96
m_DefaultSpriteDPI: 96
m_DynamicPixelsPerUnit: 1
--- !u!114 &11410278
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 110276}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 1301386320, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
m_Name:
m_EditorClassIdentifier:
ignoreReversedGraphics: 1
blockingObjects: 0
m_BlockingMask:
serializedVersion: 2
m_Bits: 4294967295
--- !u!114 &11410280
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 110278}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: -765806418, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 0}
m_Sprite: {fileID: 21300000, guid: ea8f56c43254d41728f5ac4e8299b6c9, type: 3}
m_Type: 0
m_PreserveAspect: 1
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
--- !u!114 &11410282
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 110280}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: -765806418, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 0}
m_Sprite: {fileID: 21300000, guid: ea8f56c43254d41728f5ac4e8299b6c9, type: 3}
m_Type: 0
m_PreserveAspect: 1
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
--- !u!114 &11410284
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 110282}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: -765806418, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 0}
m_Sprite: {fileID: 21300000, guid: ea8f56c43254d41728f5ac4e8299b6c9, type: 3}
m_Type: 0
m_PreserveAspect: 1
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
--- !u!222 &22210270
CanvasRenderer:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 110270}
--- !u!222 &22210272
CanvasRenderer:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 110272}
--- !u!222 &22210274
CanvasRenderer:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 110278}
--- !u!222 &22210276
CanvasRenderer:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 110280}
--- !u!222 &22210278
CanvasRenderer:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 110282}
--- !u!223 &22310270
Canvas:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 110276}
m_Enabled: 1
serializedVersion: 2
m_RenderMode: 0
m_Camera: {fileID: 0}
m_PlaneDistance: 100
m_PixelPerfect: 1
m_ReceivesEvents: 1
m_OverrideSorting: 0
m_OverridePixelPerfect: 0
m_SortingLayerID: 0
m_SortingOrder: 0
--- !u!224 &22410270
RectTransform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 110270}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 22410274}
m_RootOrder: 2
m_AnchorMin: {x: .5, y: 0}
m_AnchorMax: {x: .5, y: 0}
m_AnchoredPosition: {x: 449.999969, y: 200.000031}
m_SizeDelta: {x: 1000, y: 1000}
m_Pivot: {x: .5, y: 0}
--- !u!224 &22410272
RectTransform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 110272}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 22410274}
m_RootOrder: 3
m_AnchorMin: {x: .5, y: 0}
m_AnchorMax: {x: .5, y: 0}
m_AnchoredPosition: {x: -1000, y: 200}
m_SizeDelta: {x: 1000, y: 1000}
m_Pivot: {x: .5, y: 0}
--- !u!224 &22410274
RectTransform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 110276}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0, y: 0, z: 0}
m_Children:
- {fileID: 22410276}
- {fileID: 22410280}
- {fileID: 22410270}
- {fileID: 22410272}
- {fileID: 22410278}
m_Father: {fileID: 410270}
m_RootOrder: 0
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0, y: 0}
--- !u!224 &22410276
RectTransform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 110278}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 22410274}
m_RootOrder: 0
m_AnchorMin: {x: .5, y: 0}
m_AnchorMax: {x: .5, y: 0}
m_AnchoredPosition: {x: 0, y: 200}
m_SizeDelta: {x: 1000, y: 1000}
m_Pivot: {x: .5, y: 0}
--- !u!224 &22410278
RectTransform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 110280}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 22410274}
m_RootOrder: 4
m_AnchorMin: {x: .5, y: 0}
m_AnchorMax: {x: .5, y: 0}
m_AnchoredPosition: {x: 1000, y: 200}
m_SizeDelta: {x: 1000, y: 1000}
m_Pivot: {x: .5, y: 0}
--- !u!224 &22410280
RectTransform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 110282}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 22410274}
m_RootOrder: 1
m_AnchorMin: {x: .5, y: 0}
m_AnchorMax: {x: .5, y: 0}
m_AnchoredPosition: {x: -450, y: 200}
m_SizeDelta: {x: 1000, y: 1000}
m_Pivot: {x: .5, y: 0}
--- !u!225 &22510270
CanvasGroup:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 110276}
m_Enabled: 1
m_Alpha: 1
m_Interactable: 1
m_BlocksRaycasts: 1
m_IgnoreParentGroups: 0
--- !u!1001 &100100000
Prefab:
m_ObjectHideFlags: 1
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications: []
m_RemovedComponents: []
m_ParentPrefab: {fileID: 0}
m_RootGameObject: {fileID: 110274}
m_IsPrefabParent: 1
m_IsExploded: 1

4
Assets/Fungus/Portrait/Prefabs/PortraitStage.prefab.meta

@ -0,0 +1,4 @@
fileFormatVersion: 2
guid: c6289d5f8fa843145a2355af9cb09719
NativeFormatImporter:
userData:

226
Assets/Fungus/Portrait/Stage.cs

@ -0,0 +1,226 @@
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Events;
using System;
using System.Collections;
using System.Collections.Generic;
namespace Fungus
{
public enum StageDisplayType
{
None,
Show,
Hide,
Swap,
MoveToFront,
UndimAllPortraits,
DimNonSpeakingPortraits
}
[CommandInfo("Portrait",
"Stage",
"Controls the stage on which character portraits are displayed.")]
public class Stage : Command
{
[Tooltip("Display type")]
public StageDisplayType display;
[Tooltip("Stage to display characters on")]
public PortraitStage portraitStage;
[Tooltip("PortraitStage to swap with")]
public PortraitStage replacedPortraitStage;
[Tooltip("Use Default Settings")]
public bool useDefaultSettings = true;
[Tooltip("Fade Duration")]
public float fadeDuration;
[Tooltip("Wait until the tween has finished before executing the next command")]
public bool waitUntilFinished = false;
public override void OnEnter()
{
// If no display specified, do nothing
if (display == StageDisplayType.None)
{
Continue();
return;
}
// Selected "use default Portrait Stage"
if (portraitStage == null) // Default portrait stage selected
{
portraitStage = GetFungusScript().defaultPortraitStage;; // Try to get game's default portrait stage
if (portraitStage == null) // If no default specified, try to get any portrait stage in the scene
{
portraitStage = GameObject.FindObjectOfType<PortraitStage>();
}
}
// If portrait stage does not exist, do nothing
if (portraitStage == null)
{
Continue();
return;
}
// Selected "use default Portrait Stage"
if (display == StageDisplayType.Swap) // Default portrait stage selected
{
replacedPortraitStage = GetFungusScript().defaultPortraitStage;; // Try to get game's default portrait stage
if (replacedPortraitStage == null) // If no default specified, try to get any portrait stage in the scene
{
replacedPortraitStage = GameObject.FindObjectOfType<PortraitStage>();
}
// If portrait stage does not exist, do nothing
if (replacedPortraitStage == null)
{
Continue();
return;
}
}
// Use default settings
if (useDefaultSettings)
{
fadeDuration = portraitStage.fadeDuration;
}
switch(display)
{
case (StageDisplayType.Show):
Show(portraitStage);
break;
case (StageDisplayType.Hide):
Hide(portraitStage);
break;
case (StageDisplayType.Swap):
Show(portraitStage);
Hide(replacedPortraitStage);
break;
case (StageDisplayType.MoveToFront):
MoveToFront(portraitStage);
break;
case (StageDisplayType.UndimAllPortraits):
UndimAllPortraits(portraitStage);
break;
case (StageDisplayType.DimNonSpeakingPortraits):
DimNonSpeakingPortraits(portraitStage);
break;
}
if (!waitUntilFinished)
{
Continue();
}
}
protected void Show(PortraitStage portraitStage)
{
if (fadeDuration == 0)
{
fadeDuration = float.Epsilon;
}
LeanTween.value(gameObject,0,1,fadeDuration).setOnUpdate(
(float fadeAmount)=>{
foreach ( Character c in portraitStage.charactersOnStage)
{
c.state.portraitImage.material.SetFloat("_Alpha",fadeAmount);
}
}
).setOnComplete(
()=>{
foreach ( Character c in portraitStage.charactersOnStage)
{
c.state.portraitImage.material.SetFloat("_Alpha",1);
}
OnComplete();
}
);
}
protected void Hide(PortraitStage portraitStage)
{
if (fadeDuration == 0)
{
fadeDuration = float.Epsilon;
}
LeanTween.value(gameObject,1,0,fadeDuration).setOnUpdate(
(float fadeAmount)=>{
foreach ( Character c in portraitStage.charactersOnStage)
{
c.state.portraitImage.material.SetFloat("_Alpha",fadeAmount);
}
}
).setOnComplete(
()=>{
foreach ( Character c in portraitStage.charactersOnStage)
{
c.state.portraitImage.material.SetFloat("_Alpha",0);
}
OnComplete();
}
);
}
protected void MoveToFront(PortraitStage portraitStage)
{
foreach (PortraitStage ps in PortraitStage.activePortraitStages)
{
if (ps == portraitStage)
{
ps.portraitCanvas.sortingOrder = 1;
}
else
{
ps.portraitCanvas.sortingOrder = 0;
}
}
}
protected void UndimAllPortraits(PortraitStage portraitStage)
{
portraitStage.dimPortraits = false;
foreach (Character character in portraitStage.charactersOnStage)
{
Portrait.Undim(character,portraitStage);
}
}
protected void DimNonSpeakingPortraits(PortraitStage portraitStage)
{
portraitStage.dimPortraits = true;
}
protected void OnComplete()
{
if (waitUntilFinished)
{
Continue();
}
}
public override string GetSummary()
{
string displaySummary = "";
if (display != StageDisplayType.None)
{
displaySummary = StringFormatter.SplitCamelCase(display.ToString());
}
else
{
return "Error: No display selected";
}
string portraitStageSummary = "";
if (portraitStage != null)
{
portraitStageSummary = " \"" + portraitStage.name + "\"";
}
return displaySummary + portraitStageSummary;
}
public override Color GetButtonColor()
{
return new Color32(230, 200, 250, 255);
}
public override void OnCommandAdded(Sequence parentSequence)
{
//Default to display type: show
display = StageDisplayType.Show;
}
}
}

8
Assets/Fungus/Portrait/Stage.cs.meta

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f1ff0f540016ff64ab1556db6fe1e10f
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

5
Assets/FungusExamples/Sherlock.meta

@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: bfdd031cf416e4f20900a580a6ffccd6
folderAsset: yes
DefaultImporter:
userData:

5
Assets/FungusExamples/Sherlock/Resources.meta

@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: e538b0104f03e434193a1e945ea7e39e
folderAsset: yes
DefaultImporter:
userData:

5
Assets/FungusExamples/Sherlock/Resources/assets.meta

@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: 8f1983c921f94c94291718e0094f1d6b
folderAsset: yes
DefaultImporter:
userData:

5
Assets/FungusExamples/Sherlock/Resources/assets/audio.meta

@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: f40e440dde308d1429c8b03dbe1a3b8c
folderAsset: yes
DefaultImporter:
userData:

5
Assets/FungusExamples/Sherlock/Resources/assets/audio/emote.meta

@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: 04ec89a3ffad38d4ab18f563a895c6ba
folderAsset: yes
DefaultImporter:
userData:

BIN
Assets/FungusExamples/Sherlock/Resources/assets/audio/emote/EMOTE_angry.wav

Binary file not shown.

12
Assets/FungusExamples/Sherlock/Resources/assets/audio/emote/EMOTE_angry.wav.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: e15cd033e8242884fa44bbbffb3635e4
AudioImporter:
serializedVersion: 4
format: -1
quality: -1
stream: 1
3D: 1
forceToMono: 0
useHardware: 0
loopable: 0
userData:

BIN
Assets/FungusExamples/Sherlock/Resources/assets/audio/emote/EMOTE_annoyed.wav

Binary file not shown.

12
Assets/FungusExamples/Sherlock/Resources/assets/audio/emote/EMOTE_annoyed.wav.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 61bed2868b732754d8642fd8cf3ea4f1
AudioImporter:
serializedVersion: 4
format: -1
quality: -1
stream: 1
3D: 1
forceToMono: 0
useHardware: 0
loopable: 0
userData:

BIN
Assets/FungusExamples/Sherlock/Resources/assets/audio/emote/EMOTE_answer.wav

Binary file not shown.

12
Assets/FungusExamples/Sherlock/Resources/assets/audio/emote/EMOTE_answer.wav.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: be122d5e134d8fb46a8f0d559bf85f08
AudioImporter:
serializedVersion: 4
format: -1
quality: -1
stream: 1
3D: 1
forceToMono: 0
useHardware: 0
loopable: 0
userData:

BIN
Assets/FungusExamples/Sherlock/Resources/assets/audio/emote/EMOTE_clue.wav

Binary file not shown.

12
Assets/FungusExamples/Sherlock/Resources/assets/audio/emote/EMOTE_clue.wav.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 72d43fdfb85cbb04187e145717cfc970
AudioImporter:
serializedVersion: 4
format: -1
quality: -1
stream: 1
3D: 1
forceToMono: 0
useHardware: 0
loopable: 0
userData:

BIN
Assets/FungusExamples/Sherlock/Resources/assets/audio/emote/EMOTE_confused.wav

Binary file not shown.

12
Assets/FungusExamples/Sherlock/Resources/assets/audio/emote/EMOTE_confused.wav.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 2c83109679b046a45a12f2ab05210351
AudioImporter:
serializedVersion: 4
format: -1
quality: -1
stream: 1
3D: 1
forceToMono: 0
useHardware: 0
loopable: 0
userData:

BIN
Assets/FungusExamples/Sherlock/Resources/assets/audio/emote/EMOTE_furious.wav

Binary file not shown.

12
Assets/FungusExamples/Sherlock/Resources/assets/audio/emote/EMOTE_furious.wav.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: a84a8e1a17e158c48b4d308292df81db
AudioImporter:
serializedVersion: 4
format: -1
quality: -1
stream: 1
3D: 1
forceToMono: 0
useHardware: 0
loopable: 0
userData:

BIN
Assets/FungusExamples/Sherlock/Resources/assets/audio/emote/EMOTE_pleased.wav

Binary file not shown.

12
Assets/FungusExamples/Sherlock/Resources/assets/audio/emote/EMOTE_pleased.wav.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: cf4986a7000bafc498f65f9d71ab28d1
AudioImporter:
serializedVersion: 4
format: -1
quality: -1
stream: 1
3D: 1
forceToMono: 0
useHardware: 0
loopable: 0
userData:

BIN
Assets/FungusExamples/Sherlock/Resources/assets/audio/emote/EMOTE_question.wav

Binary file not shown.

12
Assets/FungusExamples/Sherlock/Resources/assets/audio/emote/EMOTE_question.wav.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 682fe1817a668354d986bb418c9a75fe
AudioImporter:
serializedVersion: 4
format: -1
quality: -1
stream: 1
3D: 1
forceToMono: 0
useHardware: 0
loopable: 0
userData:

BIN
Assets/FungusExamples/Sherlock/Resources/assets/audio/emote/EMOTE_realize.wav

Binary file not shown.

12
Assets/FungusExamples/Sherlock/Resources/assets/audio/emote/EMOTE_realize.wav.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 40c43dcdccf69ed46b85dd1dc5566184
AudioImporter:
serializedVersion: 4
format: -1
quality: -1
stream: 1
3D: 1
forceToMono: 0
useHardware: 0
loopable: 0
userData:

BIN
Assets/FungusExamples/Sherlock/Resources/assets/audio/emote/EMOTE_scared.wav

Binary file not shown.

12
Assets/FungusExamples/Sherlock/Resources/assets/audio/emote/EMOTE_scared.wav.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 70f3ad5c22ae4f442a18b2784b073d44
AudioImporter:
serializedVersion: 4
format: -1
quality: -1
stream: 1
3D: 1
forceToMono: 0
useHardware: 0
loopable: 0
userData:

BIN
Assets/FungusExamples/Sherlock/Resources/assets/audio/emote/EMOTE_shocked.wav

Binary file not shown.

12
Assets/FungusExamples/Sherlock/Resources/assets/audio/emote/EMOTE_shocked.wav.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: d64bcc814caf23c41ba706c2d4f06724
AudioImporter:
serializedVersion: 4
format: -1
quality: -1
stream: 1
3D: 1
forceToMono: 0
useHardware: 0
loopable: 0
userData:

BIN
Assets/FungusExamples/Sherlock/Resources/assets/audio/emote/EMOTE_shout.wav

Binary file not shown.

12
Assets/FungusExamples/Sherlock/Resources/assets/audio/emote/EMOTE_shout.wav.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 08ed144a85c2c844ab568517982e0924
AudioImporter:
serializedVersion: 4
format: -1
quality: -1
stream: 1
3D: 1
forceToMono: 0
useHardware: 0
loopable: 0
userData:

BIN
Assets/FungusExamples/Sherlock/Resources/assets/audio/emote/EMOTE_worried.wav

Binary file not shown.

12
Assets/FungusExamples/Sherlock/Resources/assets/audio/emote/EMOTE_worried.wav.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 476f002f45c7655408b9e7b1fa186f26
AudioImporter:
serializedVersion: 4
format: -1
quality: -1
stream: 1
3D: 1
forceToMono: 0
useHardware: 0
loopable: 0
userData:

5
Assets/FungusExamples/Sherlock/Resources/assets/audio/gui.meta

@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: 7dd97c8fce954be4090b43296036bf75
folderAsset: yes
DefaultImporter:
userData:

BIN
Assets/FungusExamples/Sherlock/Resources/assets/audio/gui/UI_Paper.wav

Binary file not shown.

12
Assets/FungusExamples/Sherlock/Resources/assets/audio/gui/UI_Paper.wav.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 9e747544e092d9543b6d81b14434358e
AudioImporter:
serializedVersion: 4
format: -1
quality: -1
stream: 1
3D: 1
forceToMono: 0
useHardware: 0
loopable: 0
userData:

BIN
Assets/FungusExamples/Sherlock/Resources/assets/audio/gui/UI_SpeechCheck-Fail.wav

Binary file not shown.

12
Assets/FungusExamples/Sherlock/Resources/assets/audio/gui/UI_SpeechCheck-Fail.wav.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 8b619861be9f614458920a34a125727f
AudioImporter:
serializedVersion: 4
format: -1
quality: -1
stream: 1
3D: 1
forceToMono: 0
useHardware: 0
loopable: 0
userData:

BIN
Assets/FungusExamples/Sherlock/Resources/assets/audio/gui/UI_SpeechCheck-Pass.wav

Binary file not shown.

12
Assets/FungusExamples/Sherlock/Resources/assets/audio/gui/UI_SpeechCheck-Pass.wav.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: f5ffbadf97e0bd24bae41734cf28d2da
AudioImporter:
serializedVersion: 4
format: -1
quality: -1
stream: 1
3D: 1
forceToMono: 0
useHardware: 0
loopable: 0
userData:

BIN
Assets/FungusExamples/Sherlock/Resources/assets/audio/gui/UI_Stat-0.wav

Binary file not shown.

12
Assets/FungusExamples/Sherlock/Resources/assets/audio/gui/UI_Stat-0.wav.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: c467b39701f3e0644b3361508f474021
AudioImporter:
serializedVersion: 4
format: -1
quality: -1
stream: 1
3D: 1
forceToMono: 0
useHardware: 0
loopable: 0
userData:

BIN
Assets/FungusExamples/Sherlock/Resources/assets/audio/gui/UI_Stat-100.wav

Binary file not shown.

12
Assets/FungusExamples/Sherlock/Resources/assets/audio/gui/UI_Stat-100.wav.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 753c104435015c240a34199227ab10be
AudioImporter:
serializedVersion: 4
format: -1
quality: -1
stream: 1
3D: 1
forceToMono: 0
useHardware: 0
loopable: 0
userData:

BIN
Assets/FungusExamples/Sherlock/Resources/assets/audio/gui/UI_Stat-Decrease.wav

Binary file not shown.

12
Assets/FungusExamples/Sherlock/Resources/assets/audio/gui/UI_Stat-Decrease.wav.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: e794f7f8b387c4242a6e1e61f1c85b17
AudioImporter:
serializedVersion: 4
format: -1
quality: -1
stream: 1
3D: 1
forceToMono: 0
useHardware: 0
loopable: 0
userData:

BIN
Assets/FungusExamples/Sherlock/Resources/assets/audio/gui/UI_Stat-Increase.wav

Binary file not shown.

12
Assets/FungusExamples/Sherlock/Resources/assets/audio/gui/UI_Stat-Increase.wav.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: bae673dd6cc6a3a4bba065590ad3e41c
AudioImporter:
serializedVersion: 4
format: -1
quality: -1
stream: 1
3D: 1
forceToMono: 0
useHardware: 0
loopable: 0
userData:

5
Assets/FungusExamples/Sherlock/Resources/assets/audio/music.meta

@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: afe3a8baede25d74f9a4e324c65c97bf
folderAsset: yes
DefaultImporter:
userData:

BIN
Assets/FungusExamples/Sherlock/Resources/assets/audio/music/Eliminate the Impossible.ogg

Binary file not shown.

12
Assets/FungusExamples/Sherlock/Resources/assets/audio/music/Eliminate the Impossible.ogg.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: f3c866bbc4639e7409c30c71736d84a6
AudioImporter:
serializedVersion: 4
format: 0
quality: -1
stream: 1
3D: 1
forceToMono: 0
useHardware: 0
loopable: 0
userData:

5
Assets/FungusExamples/Sherlock/Resources/assets/audio/sfx.meta

@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: 15b7769150522a54ca7b0e5830ead528
folderAsset: yes
DefaultImporter:
userData:

5
Assets/FungusExamples/Sherlock/Resources/assets/audio/sfx/Liquids.meta

@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: 48184afb80ef8194880b215ae1b13b1d
folderAsset: yes
DefaultImporter:
userData:

BIN
Assets/FungusExamples/Sherlock/Resources/assets/audio/sfx/Liquids/PourLiquid.wav

Binary file not shown.

12
Assets/FungusExamples/Sherlock/Resources/assets/audio/sfx/Liquids/PourLiquid.wav.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: e513fc9af808b8c438338e58bc17a700
AudioImporter:
serializedVersion: 4
format: -1
quality: -1
stream: 1
3D: 1
forceToMono: 0
useHardware: 0
loopable: 0
userData:

5
Assets/FungusExamples/Sherlock/Resources/assets/characters.meta

@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: e75d2824582e33f49b9d53af12dc070c
folderAsset: yes
DefaultImporter:
userData:

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save