Unity
スポンサーリンク
Unity
シーン
Unity で外部のバージョン管理システムを使用
Player Settings
メニューから「Edit > Project Settings > Player」を選択で表示
「Other Settings」項目の「Scripting Runtime Version」を「.NET 3.5 Equivalent」か「.NET 4.x Equivalent」から設定
デフォルトでは「.NET 3.5 Equivalent」に設定されており、
エラー
ButtonコンポーネントのNavigation項目の設定によってキー操作でボタン押下処理が走る
Rect Transform の Rotationがカメラに対し裏向きになっている場合クリックできない。(90度以上?)
Applicationクラス
https://docs.unity3d.com/ja/current/ScriptReference/Application.html
StreamingAssets
https://docs.unity3d.com/ja/current/Manual/SpecialFolders.html
https://docs.unity3d.com/ja/current/Manual/StreamingAssets.html
Application.dataPath Application.streamingAssetsPath Application.persistentDataPath Application.productName Application.unityVersion Application.version
pngファイルからテクスチャ作成
Texture2D generateTexture2DFromPngFile(string path)
{
BinaryReader bin = new BinaryReader(new FileStream(path, FileMode.Open, FileAccess.Read));
byte[] rb = bin.ReadBytes((int)bin.BaseStream.Length);
bin.Close();
int pos = 16, width = 0, height = 0;
for (int i = 0; i < 4; i++) width = width * 256 + rb[pos++];
for (int i = 0; i < 4; i++) height = height * 256 + rb[pos++];
Texture2D texture = new Texture2D(width, height);
texture.LoadImage(rb);
return texture;
}
フルスクリーン切り換えスクリプト
using UnityEngine;
public class Sample : MonoBehaviour
{
void Update()
{
if(Input.GetKeyDown(KeyCode.F))
{
Screen.fullScreen = !Screen.fullScreen;
}
}
}
ゲーム終了スクリプト
using UnityEngine;
public class Sample : MonoBehaviour
{
void Update()
{
if (Input.GetKeyDown(KeyCode.Q))
{
Application.Quit();
}
}
}
マウスオーバーイベント
void Start ()
{
// obj = GameObject
EventTrigger eventTrigger = obj.AddComponent<EventTrigger>();
EventTriggerType eventType = EventTriggerType.PointerEnter;
System.Action<PointerEventData> listener = onPointerEnterListener;
EventTrigger.Entry entry = new EventTrigger.Entry();
entry.eventID = eventType;
entry.callback.AddListener(data => listener.Invoke((PointerEventData)data));
eventTrigger.triggers.Add(entry);
}
void onPointerEnterListener(PointerEventData eventData)
{
Debug.Log("onPointerEnterListener");
}