스프라이트의 갯수가 1번부터 10번까지 10개라고 치면 먼저 1번 스프라이트를 드래그앤 드롭으로 넣습니다.

그 다음 shift를 누른 상태에서 1번~10번 스프라이트를 모두 선택합니다.

2번 스프라이트를 클릭해서 드래그앤드롭으로 넣습니다.

windows기준으로 스프라이트 순서가 파일명에 따라 sorting 되지 않고 뒤죽박죽 혹은 역순으로 배치되는 상황을

해결하기 위한 팁 입니다.


'Unity3D' 카테고리의 다른 글

터치한 지점으로 이동하기  (0) 2016.08.25
4.6 터치 이벤트  (0) 2015.09.10
Unity Sprite Zorder  (0) 2015.09.10
유니티 애즈 연동  (4) 2015.06.26
Admob 연동 방법  (0) 2015.06.26
Posted by 에브리피플
,
using UnityEngine;
using System.Collections;

public class Touch : MonoBehaviour {

    public float speed = 3.0f;
    private Vector3 target;

    void Start()
    {
        target = transform.position;
    }

    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            target = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            target.z = transform.position.z;
        }
        transform.position = Vector3.MoveTowards(transform.position, target, speed * Time.deltaTime);
    }
}


출처 : http://cafe.naver.com/unityhub

'Unity3D' 카테고리의 다른 글

유니티 인스펙터 순서대로 sort 방법  (0) 2016.08.25
4.6 터치 이벤트  (0) 2015.09.10
Unity Sprite Zorder  (0) 2015.09.10
유니티 애즈 연동  (4) 2015.06.26
Admob 연동 방법  (0) 2015.06.26
Posted by 에브리피플
,

4.6 터치 이벤트

Unity3D 2015. 9. 10. 22:39

public class TestScript : MonoBehaviour, IPointerDownHandler, IPointerEnterHandler {


// 인터페이스 트리거 관련

public void OnPointerDown(PointerEventData data)

{

Debug.Log(transform.name);

}


public void OnPointerEnter(PointerEventData data)

{

Debug.Log("MouseOver");

}

}



'Unity3D' 카테고리의 다른 글

유니티 인스펙터 순서대로 sort 방법  (0) 2016.08.25
터치한 지점으로 이동하기  (0) 2016.08.25
Unity Sprite Zorder  (0) 2015.09.10
유니티 애즈 연동  (4) 2015.06.26
Admob 연동 방법  (0) 2015.06.26
Posted by 에브리피플
,

Unity Sprite Zorder

Unity3D 2015. 9. 10. 22:20

SpriteRenderer에서 Order in Layer 를 조절하면 된다.

'Unity3D' 카테고리의 다른 글

터치한 지점으로 이동하기  (0) 2016.08.25
4.6 터치 이벤트  (0) 2015.09.10
유니티 애즈 연동  (4) 2015.06.26
Admob 연동 방법  (0) 2015.06.26
Unity3D Android JNI 연동  (0) 2015.06.26
Posted by 에브리피플
,

유니티 애즈 연동

Unity3D 2015. 6. 26. 18:32

http://www.unityads.co.kr/?page_id=518 에서

웹 설정 다해주고

github에 있는

UnityAdsHelper.cs


using UnityEngine;

using System.Collections;


// UnityAdsHelper.cs - Written for Unity Ads Asset Store v1.0.4 (SDK 1.3.10)

//  by Nikkolai Davenport <nikkolai@unity3d.com>

//

// Setup Instructions:

// 1. Attach this script to a new game object.

// 2. Enter game IDs into the fields provided.

// 3. Enable Development Build in Build Settings to 

//     enable test mode and show SDK debug levels.

// 

// Usage Guide:

//  Write a script and call UnityAdsHelper.ShowAd() to show an ad. 

//  Customize the HandleShowResults method to perform actions based 

//  on whether an ad was succesfully shown or not.

//

// Notes:

//  - Game IDs by platform are required to initialize Unity Ads.

//  - Test game IDs are optional. If not set while in test mode, 

//     test game IDs will default to platform game IDs.

//  - The various debug levels and test mode are only used when

//     Development Build is enabled in Build Settings.

//  - Test mode can be disabled while Development Build is set

//     by checking the option to disable it in the inspector.


using UnityEngine;

using System.Collections;

#if UNITY_IOS || UNITY_ANDROID

using UnityEngine.Advertisements;

#endif


public class UnityAdsHelper : MonoBehaviour

{

    [System.Serializable]

    public struct GameInfo

    {

        [SerializeField]

        private string _gameID;

        [SerializeField]

        private string _testGameID;


        public string GetGameID()

        {

            return Debug.isDebugBuild && !string.IsNullOrEmpty(_testGameID) ? _testGameID : _gameID;

        }

    }

    public GameInfo iOS;

    public GameInfo android;


    // Development Build must be enabled in Build Settings

    //  in order to use test mode and to show debug levels.

    public bool disableTestMode;

    public bool showInfoLogs;

    public bool showDebugLogs;

    public bool showWarningLogs = true;

    public bool showErrorLogs = true;


    protected void Awake()

    {

#if UNITY_IOS || UNITY_ANDROID

        string gameID = null;


#if UNITY_IOS

gameID = iOS.GetGameID();

#elif UNITY_ANDROID

        gameID = android.GetGameID();

#endif


        if (string.IsNullOrEmpty(gameID))

        {

            Debug.LogError("A valid game ID is required to initialize Unity Ads.");

        }

        else

        {

            Advertisement.debugLevel = Advertisement.DebugLevel.NONE;

            if (showInfoLogs) Advertisement.debugLevel |= Advertisement.DebugLevel.INFO;

            if (showDebugLogs) Advertisement.debugLevel |= Advertisement.DebugLevel.DEBUG;

            if (showWarningLogs) Advertisement.debugLevel |= Advertisement.DebugLevel.WARNING;

            if (showErrorLogs) Advertisement.debugLevel |= Advertisement.DebugLevel.ERROR;


            bool enableTestMode = Debug.isDebugBuild && !disableTestMode;

            Debug.Log(string.Format("Initializing Unity Ads for game ID {0} with test mode {1}...",

                                    gameID, enableTestMode ? "enabled" : "disabled"));


            Advertisement.Initialize(gameID, enableTestMode);

        }

#else

Debug.LogWarning("Unity Ads is not supported on the current build platform.");

#endif

    }


    public static bool isInitialized

    {

        get

        {

#if UNITY_IOS || UNITY_ANDROID

            return Advertisement.isInitialized;

#else

return false;

#endif

        }

    }


    public static bool isReady(string zone = null)

    {

#if UNITY_IOS || UNITY_ANDROID

        if (string.IsNullOrEmpty(zone)) zone = null;

        return Advertisement.isReady(zone);

#else

return false;

#endif

    }


    public static bool ShowAd(string zone = null, bool pauseGameDuringAd = true)

    {

#if UNITY_IOS || UNITY_ANDROID

        if (string.IsNullOrEmpty(zone)) zone = null;


        if (!Advertisement.isReady(zone))

        {

            Debug.LogWarning(string.Format("Unable to show ad. The ad placement zone ($0) is not ready.",

                                           zone == null ? "default" : zone));

            return false;

        }


        ShowOptions options = new ShowOptions();

        options.pause = pauseGameDuringAd;

        options.resultCallback = HandleShowResult;


        Advertisement.Show(zone, options);


        return true;

#else

Debug.LogError("Failed to show ad. Unity Ads is not supported on the current build platform.");

return false;

#endif

    }


#if UNITY_IOS || UNITY_ANDROID

    private static void HandleShowResult(ShowResult result)

    {

        switch (result)

        {

            case ShowResult.Finished:

                Debug.Log("The ad was successfully shown.");

                break;

            case ShowResult.Skipped:

                Debug.Log("The ad was skipped before reaching the end.");

                break;

            case ShowResult.Failed:

                Debug.LogError("The ad failed to be shown.");

                break;

        }

    }

#endif

    public void ShowTestAds()

    {

        ShowAd();

    }

}

스크립트 생성.

ShowAd() 호출하면

동영상 광고가 나옴

'Unity3D' 카테고리의 다른 글

4.6 터치 이벤트  (0) 2015.09.10
Unity Sprite Zorder  (0) 2015.09.10
Admob 연동 방법  (0) 2015.06.26
Unity3D Android JNI 연동  (0) 2015.06.26
NGUI sprite 텍스쳐 변경  (0) 2015.05.14
Posted by 에브리피플
,

Admob 연동 방법

Unity3D 2015. 6. 26. 12:35


AdmobUnityPackage.zip



패키지 임포트해서 광고단위바꺼서 사용

'Unity3D' 카테고리의 다른 글

Unity Sprite Zorder  (0) 2015.09.10
유니티 애즈 연동  (4) 2015.06.26
Unity3D Android JNI 연동  (0) 2015.06.26
NGUI sprite 텍스쳐 변경  (0) 2015.05.14
외부 script 접근 방법  (0) 2015.05.14
Posted by 에브리피플
,

Unity3D Android JNI 연동

Unity3D 2015. 6. 26. 11:44

C#

public class TestMethod : MonoBehaviour {


// Use this for initialization

void Start () {


        using (AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))

        {

            using( AndroidJavaObject jo = jc.GetStatic<AndroidJavaObject>("currentActivity"))

            {

                jo.Call("initActivity", "unity to android");

            }

        }

}

    public void AndroidLog( string a )

    {

        transform.GetComponent<GUIText>().text = a;

    }

// Update is called once per frame

void Update () {

}

}

JAVA
public void initActivity( final String messageFromUnity )
{
runOnUiThread( new Runnable(){
public void run()
{
UnityPlayer.UnitySendMessage("TEST", "AndroidLog", messageFromUnity);
}
});
}
C#에서 Java InitActivity 호출 -> Java에서 C# TEST 오브젝트에 AndroidLog 메서드가 있는 컴포넌트에 파라미터를 전달


'Unity3D' 카테고리의 다른 글

유니티 애즈 연동  (4) 2015.06.26
Admob 연동 방법  (0) 2015.06.26
NGUI sprite 텍스쳐 변경  (0) 2015.05.14
외부 script 접근 방법  (0) 2015.05.14
유니티 싱글톤.  (0) 2015.05.13
Posted by 에브리피플
,

this.GetComponent<UISprite> ().spriteName = texture;

'Unity3D' 카테고리의 다른 글

Admob 연동 방법  (0) 2015.06.26
Unity3D Android JNI 연동  (0) 2015.06.26
외부 script 접근 방법  (0) 2015.05.14
유니티 싱글톤.  (0) 2015.05.13
NGUI sprite 마우스 입력  (0) 2015.05.13
Posted by 에브리피플
,

1. public List<Hole> HoleList; 선언

2. 에디터에서 게임 오브젝트( Hole )를 끌어서 List에 추가


Posted by 에브리피플
,

유니티 싱글톤.

Unity3D 2015. 5. 13. 16:08
-  모노디벨롭을 상속받는 클래스의경우 

public class GeneralWindow : MonoBehaviour {

    #region 인스턴스
    private static GeneralWindow _instance;

    public static GeneralWindow In {
        get {
            return _instance;
        }
    }
    #endregion

    #region 유니티메서드
    void Awake() {
        _instance = this;
    }

    void Start() {

    }

    #endregion


- 상속받지않는 일반 클래스의경우

public class GeneralDataFile{

    #region 인스턴스
      private static GeneralDataFile _instance = new GeneralDataFile();

      public static GeneralDataFile In {
        get {
            return _instance;
        }
    }
    #endregion

그냥 에디터에서
Static 체크하면 instance로 접근가능


Posted by 에브리피플
,