0
、私の次のコードは、このです:=画面サイズに基づいてインスタンス化されたUIプレハブを配置するコード?私はインスタンス化さプレハブ画面サイズに基づいてを配置する方法については、このような状況に苦しんでいます
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class UPStand : MonoBehaviour
{
public GameObject SaleButtonPrefab;
public GameObject ParentButton;
public int
void Start()
{
//To loop all the list
for(int i = 0; i < 3; i++)
{
//Instantiate the button prefab and make a parent
GameObject nu = Instantiate(SaleButtonPrefab) as GameObject;
nu.transform.SetParent(ParentButton.transform, false);
//To set the position and function
nu.GetComponent<RectTransform>().anchoredPosition = new Vector2(0, (i*-289.5f));// <-- This positioning does not position with screen the size
}
}
}
私は720x1280の解像度でこれを実行すると、それはとして完璧に動作します
しかし、私は解像度でこれを実行すると、画像は以下を示して高さの位置決めがかなり異なっている、900x1100を言うことができます::下の画像は示し
イメージのコーナーにアンカー位置を設定しようとしましたが、スケーリングの面では機能しましたが、配置はできませんでした。
事前cのそして感謝: