Created
January 21, 2015 15:18
-
-
Save rainbow23/4486b4e02ab52286e85a to your computer and use it in GitHub Desktop.
NGUIのUISpriteに貼付ける。FunctionManagerEditor.cs と一緒に使う。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
using System.Collections.Generic; | |
[RequireComponent(typeof(UISprite))] | |
public class FunctionManager : MonoBehaviour { | |
public enum FuncType{ | |
HelpFunc = 0, | |
OnOffSound, | |
ShowOsusumeApps, | |
ShowRanking, | |
GameStart | |
}; | |
public FuncType funcType; | |
public bool showHelp = true; | |
private bool checkAudioIcon = true; | |
public GameObject helpGameObj; | |
private UISprite thisUISprite; | |
private const string offSoundBtnSpriteName = "title_btn_speaker_off"; | |
private const string onSoundBtnSpriteName = "title_btn_speaker_on"; | |
AudioManager audioManager; | |
void Awake() | |
{ | |
switch (funcType) | |
{ | |
case FuncType.OnOffSound: | |
thisUISprite = GetComponent<UISprite>(); | |
audioManager = GameObject.Find("AudioManager").GetComponent<AudioManager>(); | |
if(audioManager.IsMute) | |
{ | |
audioManager.StopBGM(); | |
thisUISprite.spriteName = offSoundBtnSpriteName; | |
} | |
else thisUISprite.spriteName = onSoundBtnSpriteName; | |
break; | |
} | |
} | |
void OnPress(bool isDown) | |
{ | |
if(isDown) | |
{ | |
switch (funcType) | |
{ | |
case FuncType.HelpFunc: | |
helpFunc(); | |
break; | |
case FuncType.OnOffSound: | |
onOffSound(); | |
break; | |
case FuncType.ShowOsusumeApps: | |
break; | |
case FuncType.ShowRanking: | |
break; | |
case FuncType.GameStart: | |
FadeManager.Instance.LoadLevel(SCENE.GAME, FadeManager.Interval); | |
break; | |
default: | |
break; | |
} | |
} | |
} | |
void helpFunc() | |
{ | |
if(showHelp) | |
{ | |
helpGameObj.transform.setLocalPosition(0f, 0f, 0f); | |
} | |
else | |
{ | |
helpGameObj.transform.setLocalPosition(1000f, 0f, 0f); | |
} | |
} | |
void onOffSound() | |
{ | |
if(GetComponent<UISprite>().spriteName.Contains("on") ) | |
{ | |
audioManager.SetMute(true); | |
thisUISprite.spriteName = offSoundBtnSpriteName; | |
//print ("thisUISprite.spriteName: " + thisUISprite.spriteName); | |
} | |
else | |
{ | |
audioManager.SetMute(false); | |
thisUISprite.spriteName = onSoundBtnSpriteName; | |
//print ("soundOn: " + thisUISprite.spriteName); | |
} | |
} | |
void Update () | |
{ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment