2019年10月20日 星期日

[Android][App] Pin Poke Challenge 隱私權保護政策

非常歡迎您使用「Pin Poke Challenge」,為了讓您能夠安心使用此App的各項服務與資訊,特此向您說明Pin Poke Challenge的隱私權保護政策,以保障您的權益,請您詳閱下列內容:
一、隱私權保護政策的適用範圍
隱私權保護政策內容,包括Pin Poke Challenge如何處理在您使用Pin Poke Challenge服務時收集到的使用情況。隱私權保護政策不適用於Pin Poke Challenge以外的相關連結網站,也不適用於非Pin Poke Challenge所委託或參與管理的人員。
二、個人資料的蒐集、處理及利用方式
當您使用Pin Poke Challenge時,所收集之資料僅作為提供顯示之廣告用途,並且不會收集其他任何個人資料;非經您書面同意,Pin Poke Challenge不會將個人資料用於其他用途。
三、隱私權保護政策之修正
Pin Poke Challenge隱私權保護政策將因應需求隨時進行修正,修正後的條款將刊登於此。

2019年6月29日 星期六

Unity 學習筆記 - UGUI 滑動式關卡選擇製作

1. 範例截圖如下,可上下滑動
2. Hierarchy 結構如下,皆為Image UI
3. SlideBg添加組件ScrollRectMask組件,並將BeSlided拉至content中,如下圖。
4. BeSlided添加Grid Layout Group組件,可格狀排列。

2019年6月23日 星期日

Unity 學習筆記 - 手機實機 debug 除錯(Android)


1. 將手機與電腦透過傳輸線連接,並連線於同一個 Wi-Fi

2. 開啟 Build Setting ,將 Development Build 打勾

3. sdk 安裝的路徑下開啟 monitor,路徑如: C:\Users\user\AppData\Local\Android\Sdk\tools\lib\monitor-x86_64\monitor.exe

Unity 學習筆記 - 手機螢幕獲取觸碰座標


直接上程式碼

private void FixedUpdate()
    {
        if (Input.touchCount > 0)
        {
            // 獲取觸碰點的座標(此為螢幕座標)
            float x_touch_position = Input.GetTouch(0).position.x;
            float y_touch_position = Input.GetTouch(0).position.y;
        }
    }

Unity 學習筆記 - 放置Admob廣告


關於如何在unity 中加入Admob廣告,在官方網站其實有很詳細的說明,請參照Mobile Ads SDK (Unity)
1. 下載插件
2. import GoogleMobileAdsPlugin.unitypackage (即下載下來的插件)
3. 建立一腳本 ShowGoogleAds.cs 掛在一物件上,即可成功顯示廣告
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using GoogleMobileAds.Api;

public class ShowGoogleAds : MonoBehaviour {
    private BannerView bannerView;

    // Use this for initialization
    void Start () {
        // google ad
        #if UNITY_ANDROID
            string appId = "xx-xxx-xxx-xxxxxxxxxxxxxxxx~xxxxxxxxxx";
        #elif UNITY_IPHONE
            string appId = " xx-xxx-xxx-xxxxxxxxxxxxxxxx~xxxxxxxxxx ";
        #else
            string appId = "unexpected_platform";
        #endif

        // Initialize the Google Mobile Ads SDK.
        MobileAds.Initialize(appId);
        this.RequestBanner();
    }
    
     // Update is called once per frame
     void Update () {
         
     }

    private void RequestBanner()
    {
        // 這是測試id
        //ca-app-pub-3940256099942544/6300978111

        #if UNITY_ANDROID
            string adUnitId = "xx-xxx-xxx-xxxxxxxxxxxxxxxx/xxxxxxxxxx";
        #elif UNITY_IPHONE
            string adUnitId = " xx-xxx-xxx-xxxxxxxxxxxxxxxx/xxxxxxxxxx ";
        #else
            string adUnitId = "unexpected_platform";
        #endif

        // Create a banner at the top of the screen.
        bannerView = new BannerView(adUnitId, AdSize.SmartBanner, AdPosition.Bottom);

        // Create an empty ad request.
        AdRequest request = new AdRequest.Builder().Build();

        // Load the banner with the request.
        bannerView.LoadAd(request);
    }
}


Unity 學習筆記 - 音效播放


1. 添加 Audio Source 組件,並將聲音檔拉至 AudioClip

2. 於掛在同一物件上的腳本控制播放聲音
// Use this for initialization
    void Start () {
        audioSource = GetComponent<AudioSource>();
    }
public void Test()
    {
        audioSource.Play();
    }

2019年6月22日 星期六

Unity 學習筆記 - 根據觸碰點施加不同方向的力


直接上程式碼

private Rigidbody2D m_rigidbody2D;

// Use this for initialization
    void Start () {
        m_rigidbody2D = GetComponent<Rigidbody2D>();
    }

private void FixedUpdate()
    {
        if (Input.touchCount > 0 && flag)
        {
            // 獲取觸碰點的座標(此為螢幕座標)
            float x_touch_position = Input.GetTouch(0).position.x;
            float y_touch_position = Input.GetTouch(0).position.y;

            // 世界座標轉換為螢幕座標 ()
            Vector3 tempPosition = Camera.main.WorldToScreenPoint(m_rigidbody2D.transform.position);

            // 欲施加的 X 方向向量
            float vx = x_touch_position - tempPosition.x;

            // 欲施加的 Y 方向向量
            float vy = y_touch_position - tempPosition.y;

            if (vx >=0 && vy>=0)
            {
                myAngle = Vector2.Angle(new Vector2(0, 1), new Vector2(vx, vy));
                m_rigidbody2D.rotation = 90f - myAngle;
                m_rigidbody2D.AddRelativeForce(Vector2.right * speed);
                flag = false;
            }
            else if (vx < 0 && vy >= 0)
            {
                myAngle = Vector2.Angle(new Vector2(0, 1), new Vector2(vx, vy));
                m_rigidbody2D.rotation = 90f + myAngle;
                m_rigidbody2D.AddRelativeForce(Vector2.right * speed);
                flag = false;
            }
        }
    }

[Android][App] Pin Poke Challenge 隱私權保護政策

非常歡迎您使用「 Pin Poke Challenge 」,為了讓您能夠安心使用此 App 的各項服務與資訊,特此向您說明 Pin Poke Challenge的隱私權保護政策,以保障您的權益,請您詳閱下列內容: 一、隱私權保護政策的適用範圍 隱私權保護政策內容,包括...