Skip to content

Instantly share code, notes, and snippets.

@onionmk2
onionmk2 / unityCamera.md
Last active February 5, 2017 13:15
unityのカメラのサイズとは

カメラには、sizeという項目があるが、何のサイズなのかわからなかったので調べた。 camerasize

サイズ いず 何?

orthographic モードの場合、カメラの半分のサイズ。 これは垂直サイズの視野量の半分です。 水平のサイズはビューポートのアスペクト比に応じて変化します。 https://docs.unity3d.com/ja/current/ScriptReference/Camera-orthographicSize.html

@onionmk2
onionmk2 / unityCanvas.md
Last active February 5, 2017 16:34
unity canvasのRender Mode別の挙動
@onionmk2
onionmk2 / screenToWorld.md
Last active February 8, 2017 12:45
[Unity]Convert Screen(click position) To world

not using camera

var screenX = Input.mousePosition.x / Screen.width;
var worldUnitsPerScreenDot = 16;
var x = screenX * worldUnitsPerScreenDot;

using camera 

var cameraObj = GameObject.FindWithTag("MainCamera");
@onionmk2
onionmk2 / transform.md
Last active February 8, 2017 11:05
[unity] transform == gameobject.GetComponent<Transform>
@onionmk2
onionmk2 / usingScreenToWorldPoint.cs
Last active February 8, 2017 13:34
this is inelegant but it works
using UnityEngine;
public class Paddle : MonoBehaviour
{
void Update()
{
var cameraObj = GameObject.FindWithTag("MainCamera");
var camera = cameraObj.GetComponent(typeof(Camera)) as Camera;
if (camera == null) return;
@onionmk2
onionmk2 / how.md
Last active February 11, 2017 23:56
How to autocomplete c# Attribute in VS2015
  1. enter [ and ]
  2. press alt → to use intellisense

attribute

c#ではフィールドとプロパティは別のものを指す用語。

フィールド

クラスまたは構造体で直接宣言される任意の型の変数です。 フィールドは、それを含んでいる型のメンバーです。 クラスや構造体には、インスタンス フィールドと静的フィールドのいずれかまたは両方が含まれていることがあります。 https://msdn.microsoft.com/ja-jp/library/ms173118.aspx

プロパティ

@onionmk2
onionmk2 / Event Functions VS Inspector.md
Created February 12, 2017 07:51
[unity] variable change in Event Functions and Inspector

stackoverflow

In Visual Studio Menu Bar: Tools -> External Tools -> Add New

Configuration:
Name: Git Bash
Command: c:\Program Files (x86)\git\bin\sh.exe
Args: --login -i
Initial Dir : $(SolutionDir)

c# には System.Type というクラスがある。

System.Typeの用途

リフレクション(メタプロ)には、このSystem.Typeが必要、らしい。
例えば、unityの[RequireComponent(A)] のAはSystem.Typeである必要がある。

System.Typeのとりかた

typeof演算子を使う。