2021年10月17日
2021年10月15日
[筆記]比較UTC時間
new Date是非常好用的語法,不管是給UTC時間、還是地區時間,都可以幫你無痛轉成UTC的時間。
比較也是很簡單!直接做比較運算子就好!
比較也是很簡單!直接做比較運算子就好!
let nowDate: Date = new Date();
let endDate: Date = new Date( "2021-10-15T12:00:00+00:00");
let myDate: Date = new Date( "2021-10-15T16:22:00");
console.log(nowDate);
console.log(endDate);
console.log(myDate);
if (nowDate > endDate){
console.log("Bigger");
}else{
console.log("Smaller");
}
if (nowDate > myDate){
console.log("Bigger");
}else{
console.log("Smaller");
}
結果:
[LOG]: nowDate: "2021-10-15T08:22:47.110Z" [LOG]: endDate: "2021-10-15T12:00:00.000Z" [LOG]: myDate: "2021-10-15T08:22:00.000Z" [LOG]: nowDate vs endDate => "Smaller" [LOG]: nowDate vs myDate => "Bigger"
2021年9月2日
[筆記]讓金幣依照菱形圖案去跳舞
private List CoinPos = new List();
private void CreateCoinPos()
{
Vector3 offset = new Vector3(0, 20, 0);
CoinPos.Clear();
int _Diameter = 4;
int _Distance = 60;
for (int x = -_Diameter; x < _Diameter + 1; x++)
{
int r = Math.Abs(x % 2);
int dis = _Diameter - Math.Abs(x);
for (int y = -dis; y < dis + 1; y++)
{
int ry = Math.Abs(y % 2);
if (ry != r)
continue;
Vector3 _Pos = new Vector3(x * _Distance, y * _Distance, 0);
_Pos += offset;
CoinPos.Add(_Pos);
}
}
CoinPos.Sort(delegate(Vector3 a, Vector3 b)
{
float ad = Vector3.Distance(a, Vector3.zero);
float bd = Vector3.Distance(b, Vector3.zero);
if (ad < bd) return -1;
if (ad > bd) return 1;
return 0;
});
}
public void DropCoin(int Length)
{
}
2021年5月15日
渲染順序 Rendering order
最近有同事在研究NGUI與UGUI的渲染順序關係(假如用同一個camera下),不過今天不是想講這個議題,而是來講講渲染順序。
當然也是有參考一些網路上的文章,本文主要是我看完後吸收到的結論。
以下圖片是實作渲染順序,如果看不懂…請再跟我說。(以下皆使用2017.4.3f1)
當然也是有參考一些網路上的文章,本文主要是我看完後吸收到的結論。
以下圖片是實作渲染順序,如果看不懂…請再跟我說。(以下皆使用2017.4.3f1)
2020年2月5日
[工具]替換Component(Script)小工具
2019年7月4日
2019年6月13日
2019年4月15日
【筆記】Unity5.4.3取得Animator現在的執行動畫(AnimatorState)的播放影格/時間
Animator m_FirstAnim, m_SecondAnim;
m_FirstAnim.Play("Loop", 0, 0);
.....
.....
float myTime = 0;
AnimatorStateInfo animationState = m_FirstAnim.GetCurrentAnimatorStateInfo(0);
float newNormalIzedTime = animationState.normalizedTime - (float)System.Math.Truncate(animationState.normalizedTime);
AnimatorClipInfo[] targetAnimatorClip = m_FirstAnim.GetCurrentAnimatorClipInfo(0);
if (targetAnimatorClip.Length > 0)
{
myTime = targetAnimatorClip[0].clip.length * newNormalIzedTime;
}
else
{
myTime = newNormalIzedTime;
}
m_SecondAnim.Play("Loop", 0, myTime);
2018年5月17日
Inspecter 基本架構紀錄
[CustomEditor(typeof(Tool))]
public class ToolInspecter : Editor
{
protected Tool m_Tool;
///
/// Component每一次顯示在Inspector上就會重新呼叫一次
///
private void OnEnable()
{
//DO init
m_Tool = target as Tool;
}
///
/// Component從Inspector上移除的瞬間執行
///
private void OnDestroy()
{
//Do origin
}
///
/// 該Component每一次有改變就會呼叫一次
///
public override void OnInspectorGUI()
{
//Do Draw GUI
DrawDefaultInspector();
}
訂閱:
文章 (Atom)
