Browse Source
- Buttons now have a Button component at design time - The Button.autoHide property controls automatic hiding when displaying page text / waiting - The Button.hideOnFlag property controls hiding when a named flag value is set to true - Added Button prefab asset - Added default Button sprite texturemaster
chrisgregan
11 years ago
14 changed files with 197 additions and 195 deletions
Binary file not shown.
@ -0,0 +1,4 @@ |
|||||||
|
fileFormatVersion: 2 |
||||||
|
guid: 2830c354320dd41fb8c7fe61f592942c |
||||||
|
NativeFormatImporter: |
||||||
|
userData: |
@ -1,59 +0,0 @@ |
|||||||
using UnityEngine; |
|
||||||
using System.Collections; |
|
||||||
|
|
||||||
namespace Fungus |
|
||||||
{ |
|
||||||
public class ButtonController : MonoBehaviour |
|
||||||
{ |
|
||||||
public float autoButtonAlpha; |
|
||||||
|
|
||||||
void Update() |
|
||||||
{ |
|
||||||
// Poll if active page has no content and game is not waiting |
|
||||||
bool showAutoButtons = false; |
|
||||||
Page page = Game.GetInstance().activePage; |
|
||||||
if (page != null && |
|
||||||
page.mode == Page.Mode.Idle && |
|
||||||
!Game.GetInstance().waiting) |
|
||||||
{ |
|
||||||
showAutoButtons = true; |
|
||||||
} |
|
||||||
|
|
||||||
float targetAlpha = 0f; |
|
||||||
if (showAutoButtons) |
|
||||||
{ |
|
||||||
targetAlpha = 1f; |
|
||||||
} |
|
||||||
|
|
||||||
float fadeSpeed = (1f / Game.GetInstance().buttonFadeDuration); |
|
||||||
autoButtonAlpha = Mathf.MoveTowards(autoButtonAlpha, targetAlpha, Time.deltaTime * fadeSpeed); |
|
||||||
|
|
||||||
SetAutoButtonAlpha(autoButtonAlpha); |
|
||||||
} |
|
||||||
|
|
||||||
void SetAutoButtonAlpha(float alpha) |
|
||||||
{ |
|
||||||
Room room = Game.GetInstance().activeRoom; |
|
||||||
if (room == null) |
|
||||||
{ |
|
||||||
return; |
|
||||||
} |
|
||||||
|
|
||||||
Button[] buttons = room.gameObject.GetComponentsInChildren<Button>(); |
|
||||||
if (buttons == null) |
|
||||||
{ |
|
||||||
return; |
|
||||||
} |
|
||||||
|
|
||||||
foreach (Button button in buttons) |
|
||||||
{ |
|
||||||
if (button.autoDisplay) |
|
||||||
{ |
|
||||||
Color color = button.spriteRenderer.color; |
|
||||||
color.a = alpha; |
|
||||||
button.spriteRenderer.color = color; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,8 +0,0 @@ |
|||||||
fileFormatVersion: 2 |
|
||||||
guid: b5ce8326f58fb4caeabc99cf7f95fb0e |
|
||||||
MonoImporter: |
|
||||||
serializedVersion: 2 |
|
||||||
defaultReferences: [] |
|
||||||
executionOrder: 0 |
|
||||||
icon: {instanceID: 0} |
|
||||||
userData: |
|
Binary file not shown.
@ -0,0 +1,45 @@ |
|||||||
|
fileFormatVersion: 2 |
||||||
|
guid: 83e4bd04047eb419fbb6b205dd1f2f91 |
||||||
|
TextureImporter: |
||||||
|
serializedVersion: 2 |
||||||
|
mipmaps: |
||||||
|
mipMapMode: 0 |
||||||
|
enableMipMap: 0 |
||||||
|
linearTexture: 0 |
||||||
|
correctGamma: 0 |
||||||
|
fadeOut: 0 |
||||||
|
borderMipMap: 0 |
||||||
|
mipMapFadeDistanceStart: 1 |
||||||
|
mipMapFadeDistanceEnd: 3 |
||||||
|
bumpmap: |
||||||
|
convertToNormalMap: 0 |
||||||
|
externalNormalMap: 0 |
||||||
|
heightScale: .25 |
||||||
|
normalMapFilter: 0 |
||||||
|
isReadable: 0 |
||||||
|
grayScaleToAlpha: 0 |
||||||
|
generateCubemap: 0 |
||||||
|
seamlessCubemap: 0 |
||||||
|
textureFormat: -3 |
||||||
|
maxTextureSize: 1024 |
||||||
|
textureSettings: |
||||||
|
filterMode: -1 |
||||||
|
aniso: 1 |
||||||
|
mipBias: -1 |
||||||
|
wrapMode: 1 |
||||||
|
nPOTScale: 0 |
||||||
|
lightmap: 0 |
||||||
|
compressionQuality: 50 |
||||||
|
spriteMode: 1 |
||||||
|
spriteExtrude: 1 |
||||||
|
spriteMeshType: 1 |
||||||
|
alignment: 0 |
||||||
|
spritePivot: {x: .5, y: .5} |
||||||
|
spritePixelsToUnits: 100 |
||||||
|
alphaIsTransparency: 1 |
||||||
|
textureType: 8 |
||||||
|
buildTargetSettings: [] |
||||||
|
spriteSheet: |
||||||
|
sprites: [] |
||||||
|
spritePackingTag: |
||||||
|
userData: |
Binary file not shown.
Loading…
Reference in new issue