게임 중 일시정지 하기
'Unity3D > Tips' 카테고리의 다른 글
| iOS 디바이스 별 메모리 사용 한계치 (0) | 2013.07.02 |
|---|---|
| Max Texture Size of iOS Devices (0) | 2013.06.14 |
| Random.Range(min, max) 함수의 max값에 대해.. (0) | 2013.05.21 |
| 유니티 소소한 TIP (0) | 2013.04.05 |
| How to get SceneView Camera? (0) | 2013.03.25 |
| iOS 디바이스 별 메모리 사용 한계치 (0) | 2013.07.02 |
|---|---|
| Max Texture Size of iOS Devices (0) | 2013.06.14 |
| Random.Range(min, max) 함수의 max값에 대해.. (0) | 2013.05.21 |
| 유니티 소소한 TIP (0) | 2013.04.05 |
| How to get SceneView Camera? (0) | 2013.03.25 |
| Max Texture Size of iOS Devices (0) | 2013.06.14 |
|---|---|
| 게임 중 일시정지 하기 (0) | 2013.05.30 |
| 유니티 소소한 TIP (0) | 2013.04.05 |
| How to get SceneView Camera? (0) | 2013.03.25 |
| EditorWindow에서 마우스/키보드 입력 체크 (2) | 2013.03.22 |
화면에 커서를 보이거나 안보이게하기
Screen.showCursor = false;
화면의 가로/세로 크기값
Screen.width
Screen.height
해상도 설정하기
void Awake() {
Screen.SetResolution(640, 480, true);
}
해상도 정보얻어오기
public Resolution[] resolutions = Screen.resolutions;
커서가 보이지 않고 움직이지 않게하기
Screen.lockCursor = true;
프로그램 종료하기
Application.Quit();
화면 캡쳐하기 (png 파일로만 되는거 같아요. 확실치는 않음 ㅎㅎ)
Application.CaptureScreenshot("Screenshot.png");
씬데이터 로딩 체크하기
void Update() {
if (Application.CanStreamedLevelBeLoaded(1))
Application.LoadLevel(1);
}
유니티 오쏘링모드에서 게임이 플레이 중인지 체크하기
Application.isPlaying
웹사이트로 링크걸기
Application.OpenURL ("http://unity3d.com/");
플랫폼(OS) 확인하기
Application.platform
실행중인 디바이스 확인하기(OS체크)
RuntimePlatform.OSXPlayer //맥
RuntimePlatform.WindowsPlayer // 윈도우
RuntimePlatform.WiiPlayer //닌텐도 위(wii)
RuntimePlatform.IPhonePlayer // 아이폰
RuntimePlatform.Android // 안드로이드
RuntimePlatform.XBOX360 // 엑스박스
PS3 //플레이스테이션
| 게임 중 일시정지 하기 (0) | 2013.05.30 |
|---|---|
| Random.Range(min, max) 함수의 max값에 대해.. (0) | 2013.05.21 |
| How to get SceneView Camera? (0) | 2013.03.25 |
| EditorWindow에서 마우스/키보드 입력 체크 (2) | 2013.03.22 |
| 비활성화 된 오브젝트 찾을 때.. (0) | 2013.03.21 |
아래 둘 중 하나인 듯..
UnityEditor.SceneView.currentDrawingSceneView.camera
or
UnityEditor.SceneView.lastActiveSceneView.camera
| Random.Range(min, max) 함수의 max값에 대해.. (0) | 2013.05.21 |
|---|---|
| 유니티 소소한 TIP (0) | 2013.04.05 |
| EditorWindow에서 마우스/키보드 입력 체크 (2) | 2013.03.22 |
| 비활성화 된 오브젝트 찾을 때.. (0) | 2013.03.21 |
| iOS 60프레임으로 셋팅하기 (0) | 2013.03.08 |
EditorWindow에서 Input 클래스는 안먹히는가 보다.
(참조 : http://answers.unity3d.com/questions/15067/input-in-editor-scripts.html)
그래서 대신 사용하는 게 Event 클래스..
Event
A UnityGUI event.
Events correspond to user input (key presses, mouse actions), or are UnityGUI layout or rendering events.
For each event OnGUI is called in the scripts; so OnGUI is potentially called multiple times per frame. Event.current corresponds to "current" event inside OnGUI call.
See Also: GUI Scripting Guide, EventType.
| rawType |
|
| type | The type of event. |
| mousePosition | The mouse position. |
| delta | The relative movement of the mouse compared to last event. |
| button | Which mouse button was pressed. |
| modifiers | Which modifier keys are held down. |
| clickCount | How many consecutive mouse clicks have we received. |
| character | The character typed. |
| commandName | The name of an ExecuteCommand or ValidateCommand Event. |
| keyCode | The raw key code for keyboard events. |
| shift | Is Shift held down? (Read Only) |
| control | Is Control key held down? (Read Only) |
| alt | Is Alt/Option key held down? (Read Only) |
| command | Is Command/Windows key held down? (Read Only) |
| capsLock | Is Caps Lock on? (Read Only) |
| numeric | Is the current keypress on the numeric keyboard? (Read Only) |
| functionKey | Is the current keypress a function key? (Read Only) |
| isKey | Is this event a keyboard event? (Read Only) |
| isMouse | Is this event a mouse event? (Read Only) |
| GetTypeForControl |
|
| Use | Use this event. |
| current | The current event that's being processed right now. |
| KeyboardEvent | Create a keyboard event. |
링크 : http://docs.unity3d.com/Documentation/ScriptReference/Event.html
| 유니티 소소한 TIP (0) | 2013.04.05 |
|---|---|
| How to get SceneView Camera? (0) | 2013.03.25 |
| 비활성화 된 오브젝트 찾을 때.. (0) | 2013.03.21 |
| iOS 60프레임으로 셋팅하기 (0) | 2013.03.08 |
| 씬 로딩화면 (0) | 2013.03.08 |
비활성화 된 오브젝트를 찾을 때..
몰랐었는데 transform.FindChild() 함수가 자기 자식의 비활성 오브젝트까지 검사한다.
유용하게 쓸 것 같다.
(근데 왜 레퍼런스에는 FindChild() 함수가 안보이지..? -_-;)
1) 상위에 활성화 된 GameObject가 필요.
2) 활성화 된 상위 GameObject에서 GameObject.transform.FindChild() 함수로 비활성화 된 GameObject를 찾는다.
예)
1 GameObject goParent; 2 Transform trInactiveObject = goParent.transform.FindChild("찾고 싶은 비활성화 된 오브젝트 이름"); 3 trInactiveObject.gameObject.SetActive(true); // 비활성 오브젝트 활성화
--------------------------------------------------------------------------------------------------------
Transform.childCount; // 바로 아래의 자식 개수(비활성화 된 자식 포함)를 반환
Transform.GetChild(int index); // 해당 index의 자식 Transform(비활성화 된 자식 포함)을 반환
| How to get SceneView Camera? (0) | 2013.03.25 |
|---|---|
| EditorWindow에서 마우스/키보드 입력 체크 (2) | 2013.03.22 |
| iOS 60프레임으로 셋팅하기 (0) | 2013.03.08 |
| 씬 로딩화면 (0) | 2013.03.08 |
| Change MonoDevelop Line Ending (0) | 2013.03.06 |
Example :
GameMaster.cs
public class GameMaster : MonoSingleton< GameMaster > { public int difficulty = 0; public override void Init(){ difficulty = 5; } }
OtherClass.cs
You forgot a "using UnityEngine;" fixed. :P
using UnityEngine; public class OtherClass: MonoBehaviour { void Start(){ print( GameMaster.instance.difficulty ); } // 5 }
The code :
using UnityEngine; public abstract class MonoSingleton<T> : MonoBehaviour where T : MonoSingleton<T> { private static T m_Instance = null; public static T instance { get { // Instance requiered for the first time, we look for it if( m_Instance == null ) { m_Instance = GameObject.FindObjectOfType(typeof(T)) as T; // Object not found, we create a temporary one if( m_Instance == null ) { Debug.LogWarning("No instance of " + typeof(T).ToString() + ", a temporary one is created."); m_Instance = new GameObject("Temp Instance of " + typeof(T).ToString(), typeof(T)).GetComponent<T>(); // Problem during the creation, this should not happen if( m_Instance == null ) { Debug.LogError("Problem during the creation of " + typeof(T).ToString()); } } m_Instance.Init(); } return m_Instance; } } // If no other monobehaviour request the instance in an awake function // executing before this one, no need to search the object. private void Awake() { if( m_Instance == null ) { m_Instance = this as T; m_Instance.Init(); } } // This function is called when the instance is used the first time // Put all the initializations you need here, as you would do in Awake public virtual void Init(){} // Make sure the instance isn't referenced anymore when the user quit, just in case. private void OnApplicationQuit() { m_Instance = null; } }
| Unity3D MonoBehaviour Lifecycle(흐름도) (0) | 2013.07.03 |
|---|---|
| Assetbundle 을 이용한 업데이트 시스템 (0) | 2013.06.25 |
| NavMesh 사용하면서 오브젝트가 밀리지 않아야 될 때.. (0) | 2013.02.13 |
| Disable warning messages (0) | 2013.02.06 |
| 새로운 창으로 카메라 뷰어 만들기 (0) | 2013.02.05 |
원하는 프레임 속도를 설정하기 위해 Unity iOS 에 의해 생성되는 사용자의 XCode 프로젝트를 열고AppController.mm 파일을 선택합니다.
#define kFPS 30
...위의 라인이 현재의 프레임 속도를 결정합니다. 그러면 사용자는 원하는 값을 설정하기 위해 변화만 주면 됩니다. 예를 들어, define 을:-
#define kFPS 60
...위와 같이 바꾼 경우 어플리케이션이 30 FPS 대신에 60 FPS 로 랜더링 것입니다.
출처 : http://unitykoreawiki.com/index.php?n=KrMain.iphone-Optimizing-MainLoop
| EditorWindow에서 마우스/키보드 입력 체크 (2) | 2013.03.22 |
|---|---|
| 비활성화 된 오브젝트 찾을 때.. (0) | 2013.03.21 |
| 씬 로딩화면 (0) | 2013.03.08 |
| Change MonoDevelop Line Ending (0) | 2013.03.06 |
| 유니티(Unity) 4 설치 후 실행 오류 해결하기 (0) | 2013.02.19 |
Unity Pro only
AsyncOperation async = Application.LoadLevelAsync( 씬넘버 );
while( !async.isDone )
{
// async.progress 참조해서 로딩 게이지 출력
}
Application.LoadLevelAsync로 비동기 씬 로딩을 할 수 있구요
- 로딩이 다 되었는지는
async.isDone
- 얼마나 진행이 되었는지는
async.progress
참조2 : http://docs.unity3d.com/Documentation/ScriptReference/Application.LoadLevelAsync.html
| 비활성화 된 오브젝트 찾을 때.. (0) | 2013.03.21 |
|---|---|
| iOS 60프레임으로 셋팅하기 (0) | 2013.03.08 |
| Change MonoDevelop Line Ending (0) | 2013.03.06 |
| 유니티(Unity) 4 설치 후 실행 오류 해결하기 (0) | 2013.02.19 |
| Unity 4.x에서 이전 애니메이션 방식 사용할 때.. (0) | 2013.02.06 |
Project-Solution Options-Source Code-C# Source Code-Line Endings
(need UnChecked 'Use default settings from 'Text file')
1)
2)
3)
| iOS 60프레임으로 셋팅하기 (0) | 2013.03.08 |
|---|---|
| 씬 로딩화면 (0) | 2013.03.08 |
| 유니티(Unity) 4 설치 후 실행 오류 해결하기 (0) | 2013.02.19 |
| Unity 4.x에서 이전 애니메이션 방식 사용할 때.. (0) | 2013.02.06 |
| 스크립트 로딩 순서 정하는 방법 (0) | 2013.02.06 |