This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SnakeHead : MonoBehaviour { | |
static int bodyCount = 0; // 現在の身体の数をカウントするためstaticに。 | |
static readonly int maxBodyCount = 10; // この数字以上のパーツは造らない。 | |
public enum BodyType | |
{ | |
None, // 親用 | |
Head, // 頭部用 | |
Body, // 身体用 | |
Tail, // 尻尾用 | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SnakeHead : MonoBehaviour { | |
static int bodyCount = 0; // 現在の身体の数をカウントするためstaticに。 | |
static readonly int maxBodyCount = 10; // この数字以上のパーツは造らない。 | |
public enum BodyType | |
{ | |
None, // 親用 | |
Head, // 頭部用 | |
Body, // 身体用 | |
Tail, // 尻尾用 | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SnakeHead : MonoBehaviour { | |
static int bodyCount = 0; // 現在の身体の数をカウントするためstaticに。 | |
static readonly int maxBodyCount = 10; // この数字以上のパーツは造らない。 | |
public enum BodyType | |
{ | |
None, // 親用 | |
Head, // 頭部用 | |
Body, // 身体用 | |
Tail, // 尻尾用 | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BounceBall : MonoBehaviour { | |
Material mat; | |
enum State | |
{ | |
red = 0,blue = 1,green = 2,free = 3 | |
} | |
State state = State.red; | |
void Start() | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CreatePrimitiveByMouse2 : MonoBehaviour { | |
GameObject primitive = null; | |
int currentPrimitiveIndex = 0; | |
List<PrimitiveType> primitiveTypeList = new List<PrimitiveType>(); | |
void Start() | |
{ | |
// 必要なPrimitiveTypeを用意 | |
this.primitiveTypeList = new List<PrimitiveType>() | |
{ | |
PrimitiveType.Sphere, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class PrimitiveTypeRotation : MonoBehaviour { | |
GameObject primitive = null; | |
PrimitiveType currentPrimitive = PrimitiveType.Sphere; | |
void Update () { | |
if (Input.GetMouseButton(0)) | |
{ | |
// マウス位置から発生するRayを作成 | |
var ray = Camera.main.ScreenPointToRay(Input.mousePosition); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CreatePrimitiveByMouse : MonoBehaviour { | |
GameObject primitive = null; | |
void Update () { | |
if (Input.GetMouseButton(0)) | |
{ | |
// マウス位置から発生するRayを作成 | |
var ray = Camera.main.ScreenPointToRay(Input.mousePosition); | |
// 当たり確認オブジェクト | |
RaycastHit hit; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FizzBuzz : MonoBehaviour { | |
// 使いまわさない文字列 | |
static readonly string fizz = "fizz"; | |
// 使いまわさない文字列 | |
static readonly string buzz = "buzz"; | |
// 3フレームい1回表示 | |
const int printPerFrame = 3; | |
// fizz / buzz 用カウンタ | |
int counter = 0; | |
// 現在フレーム用カウンター |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LineDrawer : MonoBehaviour { | |
// ラインの角の数を予め宣言。マウスの軌道を取るので1000くらいで。 | |
static readonly int vertCount = 1000; | |
// ラインは使い回すのでメンバとして宣言。 | |
LineRenderer line; | |
// 毎フレーム新たにマウスの座標を拾うので、何番目の頂点を入れ替えるべきかを保持しておく。 | |
int frameCounter = 0; | |
// 頂点位置お格納しておく | |
Vector3[] orbit = new Vector3[vertCount]; | |
void Update() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LineMaker : MonoBehaviour { | |
// ラインは使い回すのでメンバとして宣言。 | |
LineRenderer line; | |
void Update() | |
{ | |
// GetMouseButtonDownは開始時。 | |
// GetMouseButtonはドラッグ時。 | |
// GetMouseButtonUpは終了時。 | |
if (Input.GetMouseButtonDown(0)) |