Browse Source

Fixed Dialog text not updating scale after fullscreen

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

27
Assets/Fungus/Scripts/Dialog.cs

@ -282,8 +282,9 @@ namespace Fungus
float continueTimer;
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 cachedNameTextStyle;
GUIStyle cachedSayTextStyle;
@ -296,12 +297,9 @@ namespace Fungus
return;
}
// Apply resolution independent scaling to styles
// Cache these so we're not creating lots of new objects every frame
cachedBoxStyle = ScaleFontSize(boxStyle);
cachedNameTextStyle = ScaleFontSize(nameTextStyle);
cachedSayTextStyle = ScaleFontSize(sayTextStyle);
cachedButtonStyle = ScaleFontSize (buttonStyle);
CacheScaledStyles();
fullscreen = Screen.fullScreen;
}
void Update()
@ -347,16 +345,23 @@ namespace Fungus
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)
{
CacheScaledStyles();
fullscreen = Screen.fullScreen;
}
}
void CacheScaledStyles()
{
// Live update of GUIStyles when running in editor
// Not bid deal if we're triggering garbage collection inside editor
cachedBoxStyle = ScaleFontSize(boxStyle);
cachedNameTextStyle = ScaleFontSize(nameTextStyle);
cachedSayTextStyle = ScaleFontSize(sayTextStyle);
cachedButtonStyle = ScaleFontSize(buttonStyle);
}
}
public void Say(string _sayText, Action sayAction)
{

Loading…
Cancel
Save