Skip to content

Instantly share code, notes, and snippets.

@todorok1
todorok1 / SphereBooster_8.cs
Created April 11, 2018 03:36
Unityチュートリアル・Inspectorウィンドウからのデバッグのスクリプト。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SphereBooster : MonoBehaviour {
// 力を加える方向
Vector3 forceDirection = new Vector3(1.0f, 1.0f, 0f);
// 加える力の大きさ
@todorok1
todorok1 / SphereBooster_9.cs
Created April 11, 2018 04:23
Unityチュートリアル・Inspectorウィンドウからのデバッグのスクリプト。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SphereBooster : MonoBehaviour {
// 力を加える方向
public Vector3 forceDirection = new Vector3(1.0f, 1.0f, 0f);
// 加える力の大きさ
@todorok1
todorok1 / SphereBooster_10.cs
Created April 11, 2018 06:33
Unityチュートリアル・Inspectorウィンドウからのデバッグのスクリプト。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SphereBooster : MonoBehaviour {
// 力を加える方向
[SerializeField]
Vector3 forceDirection = new Vector3(1.0f, 1.0f, 0f);
@todorok1
todorok1 / SphereBooster_11.cs
Created April 11, 2018 07:38
Unityチュートリアル・角度計算のスクリプト。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SphereBooster : MonoBehaviour {
// 加える力の大きさ
[SerializeField]
float forceMagnitude = 10.0f;
@todorok1
todorok1 / SphereBooster_12.cs
Created April 11, 2018 11:46
Unityチュートリアル・角度計算のスクリプト。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SphereBooster : MonoBehaviour {
// 加える力の大きさ
[SerializeField]
float forceMagnitude = 10.0f;
@todorok1
todorok1 / Attribute.cs
Last active April 12, 2018 08:50
Unityチュートリアル・Inspectorの入力値制限のスクリプト。
// 複数のAttributeの書き方
// カンマ区切り
[SerializeField, Range(0f, 90f)]
float forceAngle = 45.0f;
// 逆もいける
[Range(0f, 90f), SerializeField]
float forceAngle = 45.0f;
@todorok1
todorok1 / AttributeDemo.cs
Last active April 12, 2018 06:58
Unityチュートリアル・Inspectorの入力値制限のスクリプト。
// 相反するAttributeの実験
// Inspectorに表示できるSerializeFieldと、
// publicな変数であってもInspectorから隠すHideInInspectorで実験
// どちらが優先されるんでしょうか。
[SerializeField, HideInInspector]
float forceMagnitude = 10.0f;
@todorok1
todorok1 / SphereBooster_13.cs
Last active April 12, 2018 16:23
Unityチュートリアル・ボールの飛距離を計算するスクリプト。
void FixedUpdate(){
Debug.Log("transform x : " + gameObject.transform.position.x.ToString());
Debug.Log("IsSleeping : " + rb.IsSleeping());
if (!isBoostPressed){
// キーまたはボタンが押されていなければ
// 処理の切り替えをせず抜ける
return;
}
// イカ省略
@todorok1
todorok1 / TutorialDistance_1.cs
Last active April 13, 2018 06:02
Unityチュートリアル・ボールの飛距離を計算するスクリプト。
// 距離測定中フラグ
bool isCheckingDistance = false;
// Sphereオブジェクトの停止位置格納用ベクトル
Vector3 stopPosition = Vector3.zero;
@todorok1
todorok1 / TutorialDistance_2.cs
Last active April 13, 2018 03:53
Unityチュートリアル・ボールの飛距離を計算するスクリプト。
void FixedUpdate(){
// 距離の測定
CheckDistance();
if (!isBoostPressed){
// キーまたはボタンが押されていなければ
// 処理の切り替えをせず抜ける
return;
}
if (isFlying){