This file contains 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
void Awake () { | |
//Debug.Log("Awake"); | |
} | |
void OnEnable () { | |
//Debug.Log("OnEnable"); | |
} | |
// Use this for initialization | |
void Start () { |
This file contains 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 static T GetComponentUpward<T>(GameObject gObj) where T: Component | |
{ | |
T comp = gObj.GetComponent<T>(); | |
if(comp != null){ | |
return comp; | |
}else{ | |
Transform parentTrans = gObj.transform.parent; | |
if( parentTrans != null){ | |
return GetComponentUpward<T>(parentTrans.gameObject); | |
}else{ |
This file contains 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
void DrawCross(Vector3 pos) | |
{ | |
float size = 0.20f; | |
Debug.DrawLine(pos - new Vector3(0,0,size), pos + new Vector3(0,0,size), Color.red); | |
Debug.DrawLine(pos - new Vector3(size,0,0), pos + new Vector3(size,0,0), Color.red); | |
} |
This file contains 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
Vector3 p0 = new Vector3(-1,0,0); | |
Vector3 p1 = new Vector3(1,0,0); | |
Vector3 p2 = new Vector3(0,-1,0); | |
Vector3 p3 = new Vector3(0,1,0); | |
Gizmos.DrawLine(p0, p1); | |
Gizmos.DrawLine(p2, p3); | |
Vector3 pt = getCrossPoint(p0, p2, p1, p3); | |
Gizmos.DrawWireSphere( pt, 0.1f); | |
// http://imagingsolution.blog107.fc2.com/blog-entry-137.html |
This file contains 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
// http://answers.unity3d.com/questions/416169/finding-pitchrollyaw-from-quaternions.html | |
Quaternion q = shipTrans.localRotation; | |
float x = q.x; | |
float y = q.y; | |
float z = q.z; | |
float w = q.w; | |
float _pitch = Mathf.Atan2(2*x*w - 2*y*z, 1 - 2*x*x - 2*z*z) * Mathf.Rad2Deg; | |
float _yaw = Mathf.Atan2(2*y*w - 2*x*z, 1 - 2*y*y - 2*z*z) * Mathf.Rad2Deg; | |
float _roll = Mathf.Asin(2*x*y + 2*z*w) * Mathf.Rad2Deg; |
This file contains 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
// http://forum.unity3d.com/threads/what-is-the-unity-5-3-equivalent-of-the-old-particlesystem-emissionrate.373106/ | |
public static class ParticleSystemExtension | |
{ | |
public static void EnableEmission(this ParticleSystem particleSystem, bool enabled) | |
{ | |
var emission = particleSystem.emission; | |
emission.enabled = enabled; | |
} | |
public static float GetEmissionRate(this ParticleSystem particleSystem) |
This file contains 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
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
#if UNITY_EDITOR | |
using UnityEditor; | |
#endif | |
[ExecuteInEditMode] | |
public class EditorTemplate : MonoBehaviour { |
This file contains 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 enum MONITOR_MODE | |
{ | |
IDLE = 0, LIVE, REPLAY | |
} | |
public static MONITOR_MODE IntToMONITOR_MODE(int id) | |
{ | |
return (MONITOR_MODE)( ( System.Enum.GetValues( typeof(MONITOR_MODE) ) ).GetValue(id) ); | |
} | |
public static int MONITOR_MODE_ToInt(MONITOR_MODE mode) | |
{ |
This file contains 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
// https://www.dropbox.com/s/em7iqkax0771qb0/Unity%E9%81%93%E5%A0%B4%E3%82%B9%E3%83%9A%E3%82%B7%E3%83%A3%E3%83%AB%E5%8D%9A%E5%A4%9A-yasuhara.pdf?dl=0 | |
差分 = 目標の値 x 現在の値^-1 | |
Quaternion delta = target_rot * Quaternion.Inverse(current_rot); | |
-- | |
this.transform.rotation = originalRotation * addRotation; |
This file contains 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
float a = 11.11f;//減速加速度 | |
float stopDistance = Mathf.Abs( (targetSpeed * targetSpeed - currentSpeed * currentSpeed) / (2 * a) ); |
OlderNewer