顏色漸變丶渲染效果類 Unity自學筆記

2021-08-20 18:52:15 字數 1630 閱讀 2614

using system.collections.generic;

using unityengine;

using unityengine.ui;

/** * 顏色漸變特效類

*/public class gradient : basemesheffect

if (horizontal && vertical) horandvercolor(vh);

//水平或垂直渲染

else if (horizontal) horizontalcolor(vh);

else if (vertical) verticalcolor(vh);

//throw new system.notimplementedexception();

}//水平且垂直顏色渲染

private void horandvercolor(vertexhelper vh)

//獲取開頭和結尾vh.x/vh.y座標

float rightx = vertexs[0].position.x;

float leftx = vertexs[0].position.x;

float topy = vertexs[0].position.y;

float bottomy = vertexs[0].position.y;

for (int i = 1; i < count; i++)

else if (x < leftx)

float y = vertexs[i].position.y;

if (y > topy)

else if (y < bottomy)

}float hor = rightx - leftx;

float ver = topy - bottomy;

for (int i = 0; i < count; i++)

}//水平方向顏色漸變

private void horizontalcolor(vertexhelper vh)

float rightx = vertexs[0].position.x;

float leftx = vertexs[0].position.x;

for (int i = 1; i < count; i++)

else if (x < leftx)

}float hor = rightx - leftx;

for (int i = 0; i < count; i++)

}//垂直方向顏色漸變

private void verticalcolor(vertexhelper vh)

float topy = vertexs[0].position.y;

float bottomy = vertexs[0].position.y;

for (int i = 1; i < count; i++)

else if (y < bottomy)

}float ver = topy - bottomy;

for (int i = 0; i < count; i++)

}//顏色相加

private color32 colorplus(color x, color y)

}

unity3d程式 顏色漸變效果

研究了下,顏色變化時遵從rgb圓環 就是說顏色條對接一下成環 路徑最小變化原則。舉個例子,加入abcde四個顏色點,並且a和e在同一點 了一圈 設定從a變化到c的話,有兩種路徑,一種abc,還一種adc,究竟選擇哪條路徑 就看這兩條路徑哪個更短些了 1 2 3 4 5 6 7 8 9 10 11 1...

Unity3D實現漸變顏色效果

基於unity3d實現漸變顏色的簡單指令碼,很少,就不廢話了,直接上 和效果圖。效果圖 using system using system.collections.generic using unityengine using unityengine.ui namespace extrafounda...

css 按鈕顏色漸變效果

從左到右的漸變效果 顏色可設定雙色 百分比可不要 background moz linear gradient left,ffb9da0 ff98c750 ffffff 100 background webkit linear gradient left,ffb9da0 ff98c750 fffff...