Browse Source

Fixed Dialog text not updating scale after fullscreen

master
chrisgregan 11 years ago
parent
commit
ac0df7ad67
  1. 33
      Assets/Fungus/Scripts/Dialog.cs

33
Assets/Fungus/Scripts/Dialog.cs

@ -282,8 +282,9 @@ namespace Fungus
float continueTimer; float continueTimer;
bool instantCompleteText; bool instantCompleteText;
bool fullscreen;
// Cached versions of scaled style objects // Cache scaled GUIStyle objects so we're not creating lots of new objects every frame
GUIStyle cachedBoxStyle; GUIStyle cachedBoxStyle;
GUIStyle cachedNameTextStyle; GUIStyle cachedNameTextStyle;
GUIStyle cachedSayTextStyle; GUIStyle cachedSayTextStyle;
@ -296,12 +297,9 @@ namespace Fungus
return; return;
} }
// Apply resolution independent scaling to styles CacheScaledStyles();
// Cache these so we're not creating lots of new objects every frame
cachedBoxStyle = ScaleFontSize(boxStyle); fullscreen = Screen.fullScreen;
cachedNameTextStyle = ScaleFontSize(nameTextStyle);
cachedSayTextStyle = ScaleFontSize(sayTextStyle);
cachedButtonStyle = ScaleFontSize (buttonStyle);
} }
void Update() void Update()
@ -347,17 +345,24 @@ namespace Fungus
timeoutTimer = Mathf.Max(timeoutTimer, 0f); timeoutTimer = Mathf.Max(timeoutTimer, 0f);
} }
if (Application.isEditor) // Update cached GUIStyles when running in editor or when switching to/from fullscreen
if (Application.isEditor ||
fullscreen != Screen.fullScreen)
{ {
// Live update of GUIStyles when running in editor CacheScaledStyles();
// Not bid deal if we're triggering garbage collection inside editor
cachedBoxStyle = ScaleFontSize(boxStyle); fullscreen = Screen.fullScreen;
cachedNameTextStyle = ScaleFontSize(nameTextStyle);
cachedSayTextStyle = ScaleFontSize(sayTextStyle);
cachedButtonStyle = ScaleFontSize(buttonStyle);
} }
} }
void CacheScaledStyles()
{
cachedBoxStyle = ScaleFontSize(boxStyle);
cachedNameTextStyle = ScaleFontSize(nameTextStyle);
cachedSayTextStyle = ScaleFontSize(sayTextStyle);
cachedButtonStyle = ScaleFontSize(buttonStyle);
}
public void Say(string _sayText, Action sayAction) public void Say(string _sayText, Action sayAction)
{ {
string copyText = _sayText; string copyText = _sayText;

Loading…
Cancel
Save