1. 程式人生 > >【Unity開發】Unity3d學習筆記記錄

【Unity開發】Unity3d學習筆記記錄

1.釋出到 ipad字型顯示不出來,改變Position位置的Z軸為-1

2.釋出打包有問題,記得使用者許可權有沒有設定

3.ipad4解析度:2048*1536

4.調整介面大小,儘量調整底下子物件位置

5.Anchor->offset->(錨定位置,讓位置固定)

6.載入fbx模型不能太大,ipad執行不了,塌陷下就可以用

7.reset panning  復位平移

8.在prefab上右擊匯出package,會自動關聯到所有該prefab呼叫的資源並匯出。如果匯出場景,就在場景檔案上右擊匯出,場景內的所有資源關聯都不應該丟失。

9.物體重新設定位置,相對座標(記得移除位置編譯指令碼)

btn1.transform.localPosition = newVector3(200,-224,0);

11.遍歷獲取子物件

GameObject go = GameObject.Find("Offset");

foreach(Transform child in go.transform)

{

child.gameObject.SetActive(false);

}

12.給遊戲物件GameObject賦值圖片

m_PlaneSlider.renderer.material.mainTexture = Texture

動態載入:m_Panel.renderer.material.mainTexture = (Texture2D

)Resources.Load(ShowImgName);


13.ipad上除錯unity程式,通過寫入資訊到文字來除錯(Application.persistentDataPath位置為/var/mobile/Application/xxxxxx/Document)

public static void CreateFile(string path,string name,string info)   
{    
StreamWriter sw;   
FileInfo t = new FileInfo(path+"//"+ name);   
if(!t.Exists)   
{    
sw = t.CreateText();
}
else
{
sw = t.AppendText();
}
sw.WriteLine(info);
sw.Close();
sw.Dispose();   
}  
public staticvoid DeleteFile(string path,string name)
{
File.Delete(path+"//"+ name);
}

14.Unity用Input.GetKeyDown()獲取按鍵是否按下,相反可以用Input.GetKeyUp()獲取按鍵是否擡起,長按判斷用Input.GetKey()

()裡面引數格式:Key.Code.A

Input.GetMouseButtonDown()來判斷滑鼠是否按下,()裡面只有一個引數,0代表滑鼠左鍵,1右鍵,2中鍵

Input.GetMouseButtonUp()  擡起

Input.GetMouseButton() 長按

15.