diff --git a/Assets/Fungus/Audio/Scripts/MusicController.cs b/Assets/Fungus/Audio/Scripts/MusicController.cs index c4122953..beffa372 100644 --- a/Assets/Fungus/Audio/Scripts/MusicController.cs +++ b/Assets/Fungus/Audio/Scripts/MusicController.cs @@ -29,7 +29,7 @@ namespace Fungus return instance; } - void Start() + protected virtual void Start() { audio.playOnAwake = false; audio.loop = true; @@ -49,7 +49,7 @@ namespace Fungus /** * Stops playing game music. */ - public void StopMusic() + public virtual void StopMusic() { audio.Stop(); } @@ -59,7 +59,7 @@ namespace Fungus * @param volume The new music volume value [0..1] * @param duration The length of time in seconds needed to complete the volume change. */ - public void SetMusicVolume(float volume, float duration) + public virtual void SetMusicVolume(float volume, float duration) { iTween.AudioTo(gameObject, volume, 1f, duration); } @@ -70,7 +70,7 @@ namespace Fungus * @param soundClip The sound effect clip to play * @param volume The volume level of the sound effect */ - public void PlaySound(AudioClip soundClip, float volume) + public virtual void PlaySound(AudioClip soundClip, float volume) { audio.PlayOneShot(soundClip, volume); } diff --git a/Assets/Fungus/Camera/Commands/ShakeCamera.cs b/Assets/Fungus/Camera/Commands/ShakeCamera.cs index c3a89feb..e0919e19 100644 --- a/Assets/Fungus/Camera/Commands/ShakeCamera.cs +++ b/Assets/Fungus/Camera/Commands/ShakeCamera.cs @@ -27,7 +27,7 @@ namespace Fungus } } - void OnWaitComplete() + protected virtual void OnWaitComplete() { Continue(); } diff --git a/Assets/Fungus/Camera/Editor/ViewEditor.cs b/Assets/Fungus/Camera/Editor/ViewEditor.cs index 72e9ea76..6899ed60 100644 --- a/Assets/Fungus/Camera/Editor/ViewEditor.cs +++ b/Assets/Fungus/Camera/Editor/ViewEditor.cs @@ -2,243 +2,247 @@ using UnityEditor; using UnityEngine; using System.Collections; using System.Collections.Generic; -using Fungus; -[CanEditMultipleObjects] -[CustomEditor (typeof(View))] -public class ViewEditor : Editor +namespace Fungus { - static Color viewColor = Color.yellow; - SerializedProperty primaryAspectRatioProp; - SerializedProperty secondaryAspectRatioProp; - - // Draw Views when they're not selected - [DrawGizmo(GizmoType.NotSelected | GizmoType.SelectedOrChild)] - static void RenderCustomGizmo(Transform objectTransform, GizmoType gizmoType) + [CanEditMultipleObjects] + [CustomEditor (typeof(View))] + public class ViewEditor : Editor { - View view = objectTransform.gameObject.GetComponent(); - if (view != null) - { - DrawView(view); - } - } + static Color viewColor = Color.yellow; - Vector2 LookupAspectRatio(int index) - { - switch (index) + protected SerializedProperty primaryAspectRatioProp; + protected SerializedProperty secondaryAspectRatioProp; + + // Draw Views when they're not selected + [DrawGizmo(GizmoType.NotSelected | GizmoType.SelectedOrChild)] + static void RenderCustomGizmo(Transform objectTransform, GizmoType gizmoType) { - default: - case 1: - return new Vector2(4, 3); - case 2: - return new Vector2(3, 2); - case 3: - return new Vector2(16, 10); - case 4: - return new Vector2(17, 10); - case 5: - return new Vector2(16, 9); - case 6: - return new Vector2(2, 1); - case 7: - return new Vector2(3, 4); - case 8: - return new Vector2(2, 3); - case 9: - return new Vector2(10, 16); - case 10: - return new Vector2(10, 17); - case 11: - return new Vector2(9, 16); - case 12: - return new Vector2(1, 2); + View view = objectTransform.gameObject.GetComponent(); + if (view != null) + { + DrawView(view); + } } - } - - void OnEnable() - { - primaryAspectRatioProp = serializedObject.FindProperty ("primaryAspectRatio"); - secondaryAspectRatioProp = serializedObject.FindProperty ("secondaryAspectRatio"); - } - - public override void OnInspectorGUI() - { - serializedObject.Update(); - - EditorGUI.BeginChangeCheck(); - string[] ratios = { "", "Landscape / 4:3", "Landscape / 3:2", "Landscape / 16:10", "Landscape / 17:10", "Landscape / 16:9", "Landscape / 2:1", "Portrait / 3:4", "Portrait / 2:3", "Portrait / 10:16", "Portrait / 10:17", "Portrait / 9:16", "Portrait / 1:2" }; - - EditorGUILayout.PropertyField(primaryAspectRatioProp, new GUIContent("Primary Aspect Ratio", "Width and height values that define the primary aspect ratio (e.g. 4:3)")); - int primaryIndex = EditorGUILayout.Popup("Select Aspect Ratio", 0, ratios); - if (primaryIndex > 0) + protected virtual Vector2 LookupAspectRatio(int index) { - primaryAspectRatioProp.vector2Value = LookupAspectRatio(primaryIndex); + switch (index) + { + default: + case 1: + return new Vector2(4, 3); + case 2: + return new Vector2(3, 2); + case 3: + return new Vector2(16, 10); + case 4: + return new Vector2(17, 10); + case 5: + return new Vector2(16, 9); + case 6: + return new Vector2(2, 1); + case 7: + return new Vector2(3, 4); + case 8: + return new Vector2(2, 3); + case 9: + return new Vector2(10, 16); + case 10: + return new Vector2(10, 17); + case 11: + return new Vector2(9, 16); + case 12: + return new Vector2(1, 2); + } } - EditorGUILayout.Separator(); - EditorGUILayout.PropertyField(secondaryAspectRatioProp, new GUIContent("Secondary Aspect Ratio", "Width and height values that define the primary aspect ratio (e.g. 4:3)")); - int secondaryIndex = EditorGUILayout.Popup("Select Aspect Ratio", 0, ratios); - if (secondaryIndex > 0) + protected virtual void OnEnable() { - secondaryAspectRatioProp.vector2Value = LookupAspectRatio(secondaryIndex); + primaryAspectRatioProp = serializedObject.FindProperty ("primaryAspectRatio"); + secondaryAspectRatioProp = serializedObject.FindProperty ("secondaryAspectRatio"); } - EditorGUILayout.Separator(); - if (EditorGUI.EndChangeCheck()) + public override void OnInspectorGUI() { - // Avoid divide by zero errors - if (primaryAspectRatioProp.vector2Value.y == 0) + serializedObject.Update(); + + EditorGUI.BeginChangeCheck(); + + string[] ratios = { "", "Landscape / 4:3", "Landscape / 3:2", "Landscape / 16:10", "Landscape / 17:10", "Landscape / 16:9", "Landscape / 2:1", "Portrait / 3:4", "Portrait / 2:3", "Portrait / 10:16", "Portrait / 10:17", "Portrait / 9:16", "Portrait / 1:2" }; + + EditorGUILayout.PropertyField(primaryAspectRatioProp, new GUIContent("Primary Aspect Ratio", "Width and height values that define the primary aspect ratio (e.g. 4:3)")); + int primaryIndex = EditorGUILayout.Popup("Select Aspect Ratio", 0, ratios); + if (primaryIndex > 0) { - primaryAspectRatioProp.vector2Value = new Vector2(primaryAspectRatioProp.vector2Value.x, 1f); + primaryAspectRatioProp.vector2Value = LookupAspectRatio(primaryIndex); } - if (secondaryAspectRatioProp.vector2Value.y == 0) + EditorGUILayout.Separator(); + + EditorGUILayout.PropertyField(secondaryAspectRatioProp, new GUIContent("Secondary Aspect Ratio", "Width and height values that define the primary aspect ratio (e.g. 4:3)")); + int secondaryIndex = EditorGUILayout.Popup("Select Aspect Ratio", 0, ratios); + if (secondaryIndex > 0) { - secondaryAspectRatioProp.vector2Value = new Vector2(secondaryAspectRatioProp.vector2Value.x, 1f); + secondaryAspectRatioProp.vector2Value = LookupAspectRatio(secondaryIndex); } + EditorGUILayout.Separator(); - SceneView.RepaintAll(); - } + if (EditorGUI.EndChangeCheck()) + { + // Avoid divide by zero errors + if (primaryAspectRatioProp.vector2Value.y == 0) + { + primaryAspectRatioProp.vector2Value = new Vector2(primaryAspectRatioProp.vector2Value.x, 1f); + } + if (secondaryAspectRatioProp.vector2Value.y == 0) + { + secondaryAspectRatioProp.vector2Value = new Vector2(secondaryAspectRatioProp.vector2Value.x, 1f); + } + + SceneView.RepaintAll(); + } - serializedObject.ApplyModifiedProperties(); - } - - void OnSceneGUI () - { - View t = target as View; - if (t.enabled) - { - EditViewBounds(); + serializedObject.ApplyModifiedProperties(); } - - if (GUI.changed) + + protected virtual void OnSceneGUI () { - EditorUtility.SetDirty(target); + View t = target as View; + if (t.enabled) + { + EditViewBounds(); + } + + if (GUI.changed) + { + EditorUtility.SetDirty(target); + } } - } - - void EditViewBounds() - { - View view = target as View; + + protected virtual void EditViewBounds() + { + View view = target as View; - DrawView(view); + DrawView(view); - Vector3 pos = view.transform.position; + Vector3 pos = view.transform.position; - float viewSize = CalculateLocalViewSize(view); + float viewSize = CalculateLocalViewSize(view); - Vector3[] handles = new Vector3[2]; - handles[0] = view.transform.TransformPoint(new Vector3(0, -viewSize, 0)); - handles[1] = view.transform.TransformPoint(new Vector3(0, viewSize, 0)); + Vector3[] handles = new Vector3[2]; + handles[0] = view.transform.TransformPoint(new Vector3(0, -viewSize, 0)); + handles[1] = view.transform.TransformPoint(new Vector3(0, viewSize, 0)); - Handles.color = Color.white; + Handles.color = Color.white; - for (int i = 0; i < 2; ++i) - { - Vector3 newPos = Handles.FreeMoveHandle(handles[i], - Quaternion.identity, - HandleUtility.GetHandleSize(pos) * 0.1f, - Vector3.zero, - Handles.CubeCap); - if (newPos != handles[i]) + for (int i = 0; i < 2; ++i) { - Undo.RecordObject(view, "Changed view size"); - view.viewSize = (newPos - pos).magnitude; - break; + Vector3 newPos = Handles.FreeMoveHandle(handles[i], + Quaternion.identity, + HandleUtility.GetHandleSize(pos) * 0.1f, + Vector3.zero, + Handles.CubeCap); + if (newPos != handles[i]) + { + Undo.RecordObject(view, "Changed view size"); + view.viewSize = (newPos - pos).magnitude; + break; + } } } - } - public static void DrawView(View view) - { - float height = CalculateLocalViewSize(view); - float widthA = height * (view.primaryAspectRatio.x / view.primaryAspectRatio.y); - float widthB = height * (view.secondaryAspectRatio.x / view.secondaryAspectRatio.y); + public static void DrawView(View view) + { + float height = CalculateLocalViewSize(view); + float widthA = height * (view.primaryAspectRatio.x / view.primaryAspectRatio.y); + float widthB = height * (view.secondaryAspectRatio.x / view.secondaryAspectRatio.y); - Color transparent = new Color(1,1,1,0f); - Color fill = viewColor; - Color outline = viewColor; + Color transparent = new Color(1,1,1,0f); + Color fill = viewColor; + Color outline = viewColor; - bool highlight = Selection.activeGameObject == view.gameObject; + bool highlight = Selection.activeGameObject == view.gameObject; - FungusScript fungusScript = FungusScriptWindow.GetFungusScript(); - if (fungusScript != null) - { - MoveToView moveToViewCommand = fungusScript.selectedCommand as MoveToView; - if (moveToViewCommand != null) + FungusScript fungusScript = FungusScriptWindow.GetFungusScript(); + if (fungusScript != null) { - highlight = (moveToViewCommand.targetView == view); + MoveToView moveToViewCommand = fungusScript.selectedCommand as MoveToView; + if (moveToViewCommand != null) + { + highlight = (moveToViewCommand.targetView == view); + } + + FadeToView fadeToViewCommand = fungusScript.selectedCommand as FadeToView; + if (fadeToViewCommand != null) + { + highlight = (fadeToViewCommand.targetView == view); + } } - FadeToView fadeToViewCommand = fungusScript.selectedCommand as FadeToView; - if (fadeToViewCommand != null) + if (highlight) { - highlight = (fadeToViewCommand.targetView == view); + fill = outline = Color.green; + fill.a = 0.1f; + outline.a = 1f; + } + else + { + fill.a = 0.1f; + outline.a = 0.5f; } - } - if (highlight) - { - fill = outline = Color.green; - fill.a = 0.1f; - outline.a = 1f; - } - else - { - fill.a = 0.1f; - outline.a = 0.5f; - } + // Draw left box + { + Vector3[] verts = new Vector3[4]; + verts[0] = view.transform.TransformPoint(new Vector3(-widthB, -height, 0)); + verts[1] = view.transform.TransformPoint(new Vector3(-widthB, height, 0)); + verts[2] = view.transform.TransformPoint(new Vector3(-widthA, height, 0)); + verts[3] = view.transform.TransformPoint(new Vector3(-widthA, -height, 0)); - // Draw left box - { - Vector3[] verts = new Vector3[4]; - verts[0] = view.transform.TransformPoint(new Vector3(-widthB, -height, 0)); - verts[1] = view.transform.TransformPoint(new Vector3(-widthB, height, 0)); - verts[2] = view.transform.TransformPoint(new Vector3(-widthA, height, 0)); - verts[3] = view.transform.TransformPoint(new Vector3(-widthA, -height, 0)); + Handles.DrawSolidRectangleWithOutline(verts, fill, transparent); + } - Handles.DrawSolidRectangleWithOutline(verts, fill, transparent); - } + // Draw right box + { + Vector3[] verts = new Vector3[4]; + verts[0] = view.transform.TransformPoint(new Vector3(widthA, -height, 0)); + verts[1] = view.transform.TransformPoint(new Vector3(widthA, height, 0)); + verts[2] = view.transform.TransformPoint(new Vector3(widthB, height, 0)); + verts[3] = view.transform.TransformPoint(new Vector3(widthB, -height, 0)); + + Handles.DrawSolidRectangleWithOutline(verts, fill, transparent); + } - // Draw right box - { - Vector3[] verts = new Vector3[4]; - verts[0] = view.transform.TransformPoint(new Vector3(widthA, -height, 0)); - verts[1] = view.transform.TransformPoint(new Vector3(widthA, height, 0)); - verts[2] = view.transform.TransformPoint(new Vector3(widthB, height, 0)); - verts[3] = view.transform.TransformPoint(new Vector3(widthB, -height, 0)); - - Handles.DrawSolidRectangleWithOutline(verts, fill, transparent); - } + // Draw inner box + { + Vector3[] verts = new Vector3[4]; + verts[0] = view.transform.TransformPoint(new Vector3(-widthA, -height, 0)); + verts[1] = view.transform.TransformPoint(new Vector3(-widthA, height, 0)); + verts[2] = view.transform.TransformPoint(new Vector3(widthA, height, 0)); + verts[3] = view.transform.TransformPoint(new Vector3(widthA, -height, 0)); + + Handles.DrawSolidRectangleWithOutline(verts, transparent, outline ); + } - // Draw inner box - { - Vector3[] verts = new Vector3[4]; - verts[0] = view.transform.TransformPoint(new Vector3(-widthA, -height, 0)); - verts[1] = view.transform.TransformPoint(new Vector3(-widthA, height, 0)); - verts[2] = view.transform.TransformPoint(new Vector3(widthA, height, 0)); - verts[3] = view.transform.TransformPoint(new Vector3(widthA, -height, 0)); - - Handles.DrawSolidRectangleWithOutline(verts, transparent, outline ); + // Draw outer box + { + Vector3[] verts = new Vector3[4]; + verts[0] = view.transform.TransformPoint(new Vector3(-widthB, -height, 0)); + verts[1] = view.transform.TransformPoint(new Vector3(-widthB, height, 0)); + verts[2] = view.transform.TransformPoint(new Vector3(widthB, height, 0)); + verts[3] = view.transform.TransformPoint(new Vector3(widthB, -height, 0)); + + Handles.DrawSolidRectangleWithOutline(verts, transparent, outline ); + } } - // Draw outer box + // Calculate view size in local coordinates + // Kinda expensive, but accurate and only called in editor. + static float CalculateLocalViewSize(View view) { - Vector3[] verts = new Vector3[4]; - verts[0] = view.transform.TransformPoint(new Vector3(-widthB, -height, 0)); - verts[1] = view.transform.TransformPoint(new Vector3(-widthB, height, 0)); - verts[2] = view.transform.TransformPoint(new Vector3(widthB, height, 0)); - verts[3] = view.transform.TransformPoint(new Vector3(widthB, -height, 0)); - - Handles.DrawSolidRectangleWithOutline(verts, transparent, outline ); + return view.transform.InverseTransformPoint(view.transform.position + new Vector3(0, view.viewSize, 0)).magnitude; } } - // Calculate view size in local coordinates - // Kinda expensive, but accurate and only called in editor. - static float CalculateLocalViewSize(View view) - { - return view.transform.InverseTransformPoint(view.transform.position + new Vector3(0, view.viewSize, 0)).magnitude; - } -} +} \ No newline at end of file diff --git a/Assets/Fungus/Camera/Scripts/CameraController.cs b/Assets/Fungus/Camera/Scripts/CameraController.cs index bb487c5c..f5a6a052 100644 --- a/Assets/Fungus/Camera/Scripts/CameraController.cs +++ b/Assets/Fungus/Camera/Scripts/CameraController.cs @@ -39,23 +39,23 @@ namespace Fungus [HideInInspector] public bool waiting; - float fadeAlpha = 0f; + protected float fadeAlpha = 0f; // Swipe panning control - View swipePanViewA; - View swipePanViewB; - Vector3 previousMousePos; + protected View swipePanViewA; + protected View swipePanViewB; + protected Vector3 previousMousePos; - class CameraView + protected class CameraView { public Vector3 cameraPos; public Quaternion cameraRot; public float cameraSize; }; - Dictionary storedViews = new Dictionary(); + protected Dictionary storedViews = new Dictionary(); - static CameraController instance; + protected static CameraController instance; /** * Returns the CameraController singleton instance. @@ -86,7 +86,7 @@ namespace Fungus return texture; } - void OnGUI() + protected virtual void OnGUI() { if (swipePanActive) { @@ -123,7 +123,7 @@ namespace Fungus /** * Perform a fullscreen fade over a duration. */ - public void Fade(float targetAlpha, float fadeDuration, Action fadeAction) + public virtual void Fade(float targetAlpha, float fadeDuration, Action fadeAction) { StartCoroutine(FadeInternal(targetAlpha, fadeDuration, fadeAction)); } @@ -131,7 +131,7 @@ namespace Fungus /** * Fade out, move camera to view and then fade back in. */ - public void FadeToView(View view, float fadeDuration, Action fadeAction) + public virtual void FadeToView(View view, float fadeDuration, Action fadeAction) { swipePanActive = false; fadeAlpha = 0f; @@ -152,7 +152,7 @@ namespace Fungus }); } - IEnumerator FadeInternal(float targetAlpha, float fadeDuration, Action fadeAction) + protected virtual IEnumerator FadeInternal(float targetAlpha, float fadeDuration, Action fadeAction) { float startAlpha = fadeAlpha; float timer = 0; @@ -188,7 +188,7 @@ namespace Fungus * Positions camera so sprite is centered and fills the screen. * @param spriteRenderer The sprite to center the camera on */ - public void CenterOnSprite(SpriteRenderer spriteRenderer) + public virtual void CenterOnSprite(SpriteRenderer spriteRenderer) { swipePanActive = false; @@ -202,7 +202,7 @@ namespace Fungus SetCameraZ(); } - public void PanToView(View view, float duration, Action arriveAction) + public virtual void PanToView(View view, float duration, Action arriveAction) { PanToPosition(view.transform.position, view.transform.rotation, view.viewSize, duration, arriveAction); } @@ -210,7 +210,7 @@ namespace Fungus /** * Moves camera from current position to a target position over a period of time. */ - public void PanToPosition(Vector3 targetPosition, Quaternion targetRotation, float targetSize, float duration, Action arriveAction) + public virtual void PanToPosition(Vector3 targetPosition, Quaternion targetRotation, float targetSize, float duration, Action arriveAction) { // Stop any pan that is currently active StopAllCoroutines(); @@ -238,7 +238,7 @@ namespace Fungus /** * Stores the current camera view using a name. */ - public void StoreView(string viewName) + public virtual void StoreView(string viewName) { CameraView currentView = new CameraView(); currentView.cameraPos = Camera.main.transform.position; @@ -250,7 +250,7 @@ namespace Fungus /** * Moves the camera to a previously stored camera view over a period of time. */ - public void PanToStoredView(string viewName, float duration, Action arriveAction) + public virtual void PanToStoredView(string viewName, float duration, Action arriveAction) { if (!storedViews.ContainsKey(viewName)) { @@ -282,7 +282,7 @@ namespace Fungus } } - IEnumerator PanInternal(Vector3 targetPos, Quaternion targetRot, float targetSize, float duration, Action arriveAction) + protected virtual IEnumerator PanInternal(Vector3 targetPos, Quaternion targetRot, float targetSize, float duration, Action arriveAction) { float timer = 0; float startSize = Camera.main.orthographicSize; @@ -322,7 +322,7 @@ namespace Fungus /** * Moves camera smoothly through a sequence of Views over a period of time */ - public void PanToPath(View[] viewList, float duration, Action arriveAction) + public virtual void PanToPath(View[] viewList, float duration, Action arriveAction) { swipePanActive = false; @@ -348,7 +348,7 @@ namespace Fungus StartCoroutine(PanToPathInternal(duration, arriveAction, pathList.ToArray())); } - IEnumerator PanToPathInternal(float duration, Action arriveAction, Vector3[] path) + protected virtual IEnumerator PanToPathInternal(float duration, Action arriveAction, Vector3[] path) { float timer = 0; @@ -377,7 +377,7 @@ namespace Fungus * Activates swipe panning mode. * The player can pan the camera within the area between viewA & viewB. */ - public void StartSwipePan(View viewA, View viewB, float duration, Action arriveAction) + public virtual void StartSwipePan(View viewA, View viewB, float duration, Action arriveAction) { swipePanViewA = viewA; swipePanViewB = viewB; @@ -401,19 +401,19 @@ namespace Fungus /** * Deactivates swipe panning mode. */ - public void StopSwipePan() + public virtual void StopSwipePan() { swipePanActive = false; swipePanViewA = null; swipePanViewB = null; } - void SetCameraZ() + protected virtual void SetCameraZ() { Camera.main.transform.position = new Vector3(Camera.main.transform.position.x, Camera.main.transform.position.y, cameraZ); } - void Update() + protected virtual void Update() { if (!swipePanActive) { @@ -454,7 +454,7 @@ namespace Fungus } // Clamp camera position to region defined by the two views - Vector3 CalcCameraPosition(Vector3 pos, View viewA, View viewB) + protected virtual Vector3 CalcCameraPosition(Vector3 pos, View viewA, View viewB) { Vector3 safePos = pos; @@ -468,7 +468,7 @@ namespace Fungus } // Smoothly interpolate camera orthographic size based on relative position to two views - float CalcCameraSize(Vector3 pos, View viewA, View viewB) + protected virtual float CalcCameraSize(Vector3 pos, View viewA, View viewB) { // Get ray and point in same space Vector3 toViewB = viewB.transform.position - viewA.transform.position; diff --git a/Assets/Fungus/Camera/Scripts/View.cs b/Assets/Fungus/Camera/Scripts/View.cs index cfebce1e..caf33711 100644 --- a/Assets/Fungus/Camera/Scripts/View.cs +++ b/Assets/Fungus/Camera/Scripts/View.cs @@ -31,7 +31,7 @@ namespace Fungus [Tooltip("Aspect ratio of the secondary view rectangle. (e.g. 2:1 aspect ratio = 2.0)")] public Vector2 secondaryAspectRatio = new Vector2(2, 1); - void Update() + protected virtual void Update() { // Disable scaling to avoid complicating the orthographic size calculations transform.localScale = new Vector3(1,1,1); diff --git a/Assets/Fungus/Dialog/Commands/Choose.cs b/Assets/Fungus/Dialog/Commands/Choose.cs index 16723fef..36f2b0f4 100644 --- a/Assets/Fungus/Dialog/Commands/Choose.cs +++ b/Assets/Fungus/Dialog/Commands/Choose.cs @@ -25,7 +25,7 @@ namespace Fungus public AudioClip voiceOverClip; public float timeoutDuration; - bool showBasicGUI; + protected bool showBasicGUI; public override void OnEnter() { @@ -100,7 +100,7 @@ namespace Fungus } } - void OnGUI() + protected virtual void OnGUI() { if (!showBasicGUI) { diff --git a/Assets/Fungus/Dialog/Commands/Say.cs b/Assets/Fungus/Dialog/Commands/Say.cs index 3e7a0ab2..c5cb8411 100644 --- a/Assets/Fungus/Dialog/Commands/Say.cs +++ b/Assets/Fungus/Dialog/Commands/Say.cs @@ -16,9 +16,8 @@ namespace Fungus public Character character; public AudioClip voiceOverClip; public bool showOnce; - int executionCount; - - bool showBasicGUI; + protected int executionCount; + protected bool showBasicGUI; public override void OnEnter() { @@ -58,7 +57,7 @@ namespace Fungus return "\"" + storyText + "\""; } - void OnGUI() + protected virtual void OnGUI() { if (!showBasicGUI) { diff --git a/Assets/Fungus/Dialog/Editor/AddOptionEditor.cs b/Assets/Fungus/Dialog/Editor/AddOptionEditor.cs index 1d853784..ae30fd3c 100644 --- a/Assets/Fungus/Dialog/Editor/AddOptionEditor.cs +++ b/Assets/Fungus/Dialog/Editor/AddOptionEditor.cs @@ -11,11 +11,11 @@ namespace Fungus [CustomEditor (typeof(AddOption))] public class AddOptionEditor : CommandEditor { - SerializedProperty optionTextProp; - SerializedProperty hideOnSelectedProp; - SerializedProperty targetSequenceProp; + protected SerializedProperty optionTextProp; + protected SerializedProperty hideOnSelectedProp; + protected SerializedProperty targetSequenceProp; - void OnEnable() + protected virtual void OnEnable() { optionTextProp = serializedObject.FindProperty("optionText"); hideOnSelectedProp = serializedObject.FindProperty("hideOnSelected"); diff --git a/Assets/Fungus/Dialog/Editor/CharacterEditor.cs b/Assets/Fungus/Dialog/Editor/CharacterEditor.cs index f9d5f5a8..5f0137d7 100644 --- a/Assets/Fungus/Dialog/Editor/CharacterEditor.cs +++ b/Assets/Fungus/Dialog/Editor/CharacterEditor.cs @@ -8,14 +8,14 @@ namespace Fungus [CustomEditor (typeof(Character))] public class CharacterEditor : Editor { - Material spriteMaterial; + protected Material spriteMaterial; - SerializedProperty nameTextProp; - SerializedProperty nameColorProp; - SerializedProperty profileSpriteProp; - SerializedProperty notesProp; + protected SerializedProperty nameTextProp; + protected SerializedProperty nameColorProp; + protected SerializedProperty profileSpriteProp; + protected SerializedProperty notesProp; - void OnEnable() + protected virtual void OnEnable() { nameTextProp = serializedObject.FindProperty ("nameText"); nameColorProp = serializedObject.FindProperty ("nameColor"); @@ -30,7 +30,7 @@ namespace Fungus } } - void OnDisable() + protected virtual void OnDisable() { DestroyImmediate(spriteMaterial); } @@ -66,7 +66,7 @@ namespace Fungus serializedObject.ApplyModifiedProperties(); } - public void DrawPreview(Rect previewRect, Texture2D texture) + public virtual void DrawPreview(Rect previewRect, Texture2D texture) { if (texture == null) { diff --git a/Assets/Fungus/Dialog/Editor/ChooseEditor.cs b/Assets/Fungus/Dialog/Editor/ChooseEditor.cs index 8e2aec44..2e9c0080 100644 --- a/Assets/Fungus/Dialog/Editor/ChooseEditor.cs +++ b/Assets/Fungus/Dialog/Editor/ChooseEditor.cs @@ -13,12 +13,12 @@ namespace Fungus { static public bool showTagHelp; - SerializedProperty chooseTextProp; - SerializedProperty characterProp; - SerializedProperty voiceOverClipProp; - SerializedProperty timeoutDurationProp; + protected SerializedProperty chooseTextProp; + protected SerializedProperty characterProp; + protected SerializedProperty voiceOverClipProp; + protected SerializedProperty timeoutDurationProp; - void OnEnable() + protected virtual void OnEnable() { chooseTextProp = serializedObject.FindProperty("chooseText"); characterProp = serializedObject.FindProperty("character"); diff --git a/Assets/Fungus/Dialog/Editor/SayEditor.cs b/Assets/Fungus/Dialog/Editor/SayEditor.cs index 81228433..a2cd88a6 100644 --- a/Assets/Fungus/Dialog/Editor/SayEditor.cs +++ b/Assets/Fungus/Dialog/Editor/SayEditor.cs @@ -30,12 +30,12 @@ namespace Fungus EditorGUILayout.SelectableLabel(tagsText, EditorStyles.miniLabel, GUILayout.MinHeight(pixelHeight)); } - SerializedProperty storyTextProp; - SerializedProperty characterProp; - SerializedProperty voiceOverClipProp; - SerializedProperty showOnceProp; + protected SerializedProperty storyTextProp; + protected SerializedProperty characterProp; + protected SerializedProperty voiceOverClipProp; + protected SerializedProperty showOnceProp; - void OnEnable() + protected virtual void OnEnable() { storyTextProp = serializedObject.FindProperty("storyText"); characterProp = serializedObject.FindProperty("character"); diff --git a/Assets/Fungus/Dialog/Editor/SetChooseDialogEditor.cs b/Assets/Fungus/Dialog/Editor/SetChooseDialogEditor.cs index f79054ed..f1efff20 100644 --- a/Assets/Fungus/Dialog/Editor/SetChooseDialogEditor.cs +++ b/Assets/Fungus/Dialog/Editor/SetChooseDialogEditor.cs @@ -11,9 +11,9 @@ namespace Fungus [CustomEditor (typeof(SetChooseDialog))] public class SetChooseDialogEditor : CommandEditor { - SerializedProperty chooseDialogProp; + protected SerializedProperty chooseDialogProp; - void OnEnable() + protected virtual void OnEnable() { chooseDialogProp = serializedObject.FindProperty("chooseDialog"); } diff --git a/Assets/Fungus/Dialog/Editor/SetSayDialogEditor.cs b/Assets/Fungus/Dialog/Editor/SetSayDialogEditor.cs index 0721f03b..2f98a3c8 100644 --- a/Assets/Fungus/Dialog/Editor/SetSayDialogEditor.cs +++ b/Assets/Fungus/Dialog/Editor/SetSayDialogEditor.cs @@ -11,9 +11,9 @@ namespace Fungus [CustomEditor (typeof(SetSayDialog))] public class SetSayDialogEditor : CommandEditor { - SerializedProperty sayDialogProp; + protected SerializedProperty sayDialogProp; - void OnEnable() + protected virtual void OnEnable() { sayDialogProp = serializedObject.FindProperty("sayDialog"); } diff --git a/Assets/Fungus/Dialog/Scripts/Background.cs b/Assets/Fungus/Dialog/Scripts/Background.cs index c64294b4..ceaa677a 100644 --- a/Assets/Fungus/Dialog/Scripts/Background.cs +++ b/Assets/Fungus/Dialog/Scripts/Background.cs @@ -7,7 +7,7 @@ public class Background : MonoBehaviour public Canvas backgroundCanvas; public Image backgroundImage; - public void SetBackgroundImage(Sprite imageSprite) + public virtual void SetBackgroundImage(Sprite imageSprite) { if (backgroundCanvas != null) { diff --git a/Assets/Fungus/Dialog/Scripts/Character.cs b/Assets/Fungus/Dialog/Scripts/Character.cs index 67321e2a..a85a63df 100644 --- a/Assets/Fungus/Dialog/Scripts/Character.cs +++ b/Assets/Fungus/Dialog/Scripts/Character.cs @@ -17,7 +17,7 @@ namespace Fungus static public List activeCharacters = new List(); - void OnEnable() + protected virtual void OnEnable() { if (!activeCharacters.Contains(this)) { @@ -25,7 +25,7 @@ namespace Fungus } } - void OnDisable() + protected virtual void OnDisable() { activeCharacters.Remove(this); } diff --git a/Assets/Fungus/Dialog/Scripts/ChooseDialog.cs b/Assets/Fungus/Dialog/Scripts/ChooseDialog.cs index caf46ac6..359de37a 100644 --- a/Assets/Fungus/Dialog/Scripts/ChooseDialog.cs +++ b/Assets/Fungus/Dialog/Scripts/ChooseDialog.cs @@ -23,7 +23,7 @@ namespace Fungus static public List activeDialogs = new List(); - void OnEnable() + protected virtual void OnEnable() { if (!activeDialogs.Contains(this)) { @@ -31,7 +31,7 @@ namespace Fungus } } - void OnDisable() + protected virtual void OnDisable() { activeDialogs.Remove(this); } @@ -42,7 +42,7 @@ namespace Fungus timeoutSlider.gameObject.SetActive(false); } - public void Choose(string text, List