本文整理汇总了C#中UnityEngine.Gradient类的典型用法代码示例。如果您正苦于以下问题:C# Gradient类的具体用法?C# Gradient怎么用?C# Gradient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Gradient类属于UnityEngine命名空间,在下文中一共展示了Gradient类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: DrawGradientRect
/// <summary>
/// Draws gradient rectangle on texture
/// </summary>t
public static void DrawGradientRect(this Texture2D texture, int x, int y, int blockWidth, int blockHeight,
Gradient gradient, Directions progressionDirection)
{
Func<int, int, Color> getColor;
switch (progressionDirection)
{
case Directions.Left:
getColor = (_x, _y) => gradient.Evaluate(1 - (float) _x/(float) blockWidth);
break;
case Directions.Right:
getColor = (_x, _y) => gradient.Evaluate((float) _x/(float) blockWidth);
break;
case Directions.Down:
getColor = (_x, _y) => gradient.Evaluate(1 - (float) _y/(float) blockHeight);
break;
case Directions.Up:
getColor = (_x, _y) => gradient.Evaluate((float) _y/(float) blockHeight);
break;
default:
Debug.LogError("Not supported direction: " + progressionDirection);
return;
}
var colors = new Color[blockWidth*blockHeight];
for (int _y = 0; _y < blockHeight; _y++)
{
for (int _x = 0; _x < blockWidth; _x++)
{
colors[_x + _y*blockWidth] = getColor(_x, _y);
}
}
texture.SetPixels(x, y, blockWidth, blockHeight, colors);
}
开发者ID:rickoskam,项目名称:ShepherdGame,代码行数:36,代码来源:TextureE.cs
示例2: DebugCreateTonsOfPresets
public void DebugCreateTonsOfPresets()
{
int num = 150;
string str = "Preset_";
for (int i = 0; i < num; i++)
{
List<GradientColorKey> list = new List<GradientColorKey>();
int num3 = Random.Range(3, 8);
for (int j = 0; j < num3; j++)
{
list.Add(new GradientColorKey(new Color(Random.value, Random.value, Random.value), Random.value));
}
List<GradientAlphaKey> list2 = new List<GradientAlphaKey>();
int num5 = Random.Range(3, 8);
for (int k = 0; k < num5; k++)
{
list2.Add(new GradientAlphaKey(Random.value, Random.value));
}
Gradient presetObject = new Gradient {
colorKeys = list.ToArray(),
alphaKeys = list2.ToArray()
};
this.Add(presetObject, str + (i + 1));
}
}
开发者ID:CarlosHBC,项目名称:UnityDecompiled,代码行数:25,代码来源:GradientPresetLibrary.cs
示例3: OnGUI
internal static void OnGUI()
{
if(!initialized)
GetPreferences();
GUILayout.Label("Settings", z_GUI.headerTextStyle);
rebuildNormals = EditorGUILayout.Toggle(gc_rebuildNormals, rebuildNormals);
hideWireframe = EditorGUILayout.Toggle(gc_hideWireframe, hideWireframe);
lockBrushSettings = EditorGUILayout.Toggle(gc_lockBrushSettings, lockBrushSettings);
fullStrengthColor = EditorGUILayout.ColorField(gc_fullStrengthColor, fullStrengthColor);
try
{
EditorGUI.BeginChangeCheck();
object out_gradient = z_ReflectionUtil.Invoke( null,
typeof(EditorGUILayout),
"GradientField",
new System.Type[] { typeof(GUIContent), typeof(Gradient), typeof(GUILayoutOption[]) },
BindingFlags.NonPublic | BindingFlags.Static,
new object[] { gc_BrushGradient, gradient, null });
gradient = (Gradient) out_gradient;
if(EditorGUI.EndChangeCheck())
SetPreferences();
}
catch
{
// internal editor gripe about something unimportant
}
}
开发者ID:alex-carlson,项目名称:PixelitisGGJ,代码行数:32,代码来源:z_GlobalSettingsEditor.cs
示例4: DrawInternal
private void DrawInternal(Rect rect, Gradient gradient)
{
if (gradient != null)
{
GradientEditor.DrawGradientWithBackground(rect, GradientPreviewCache.GetGradientPreview(gradient));
}
}
开发者ID:CarlosHBC,项目名称:UnityDecompiled,代码行数:7,代码来源:GradientPresetLibrary.cs
示例5: Gradient
/// <summary>
/// Creates a gradient between two colors
/// </summary>
public static Gradient Gradient(Color from, Color to)
{
var g = new Gradient();
g.SetKeys(new[] {new GradientColorKey(from, 0), new GradientColorKey(to, 1)},
new[] {new GradientAlphaKey(from.a, 0), new GradientAlphaKey(to.a, 1)});
return g;
}
开发者ID:liamzebedee,项目名称:hackagong2015,代码行数:10,代码来源:ColorE.cs
示例6: GenerateColorsEvenGradient
/// <summary>
/// Generate colors evely spaced out on a given gradient.
/// </summary>
/// <param name="colorCount"></param>
/// <param name="gradient"></param>
/// <param name="jitter"></param>
/// <returns></returns>
public static List<Color> GenerateColorsEvenGradient(
int colorCount,
Gradient gradient,
float jitter)
{
return gradient.SampleEvenly(colorCount, jitter).ToList();
}
开发者ID:MRGS,项目名称:ArcadeRoyale,代码行数:14,代码来源:ProceduralPalette.cs
示例7: Deserialize
public static bool Deserialize(string str, out Gradient gradient)
{
gradient = null;
string[] arrays = str.Split('\n');
if(arrays.Length < 2)
return false;
string[] colors_str = arrays[0].Split('|');
string[] alphas_str = arrays[1].Split('|');
if(colors_str.Length < 2 || alphas_str.Length < 2)
return false;
List<GradientColorKey> colors = new List<GradientColorKey>();
List<GradientAlphaKey> alphas = new List<GradientAlphaKey>();
foreach(string s in colors_str)
{
string[] key = s.Split('&');
if(key.Length < 2)
continue;
Color value;
float time;
if(!TryParseColor(key[0], out value))
continue;
if(!float.TryParse(key[1], out time))
continue;
colors.Add( new GradientColorKey(value, time) );
}
foreach(string s in alphas_str)
{
string[] key = s.Split('&');
if(key.Length < 2)
continue;
float alpha, time;
if(!float.TryParse(key[0], out alpha))
continue;
if(!float.TryParse(key[1], out time))
continue;
alphas.Add( new GradientAlphaKey(alpha, time) );
}
gradient = new Gradient();
gradient.SetKeys(colors.ToArray(), alphas.ToArray());
return true;
}
开发者ID:alex-carlson,项目名称:PixelitisGGJ,代码行数:59,代码来源:z_GradientSerializer.cs
示例8: CreateGradientTexture
public static Texture2D CreateGradientTexture(Gradient gradient)
{
Texture2D preview = new Texture2D(256, 2, TextureFormat.ARGB32, false);
preview.wrapMode = TextureWrapMode.Clamp;
preview.hideFlags = HideFlags.HideAndDontSave;
GradientEditor.RefreshPreview(gradient, preview);
return preview;
}
开发者ID:BlakeTriana,项目名称:unity-decompiled,代码行数:8,代码来源:GradientEditor.cs
示例9: RefreshPreview
public static void RefreshPreview(Gradient gradient, Texture2D preview)
{
Color[] colors = new Color[512];
for (int index = 0; index < 256; ++index)
colors[index] = colors[index + 256] = gradient.Evaluate((float) index / 256f);
preview.SetPixels(colors);
preview.Apply();
}
开发者ID:BlakeTriana,项目名称:unity-decompiled,代码行数:8,代码来源:GradientEditor.cs
示例10: Init
private void Init(Gradient newGradient)
{
this.m_Gradient = newGradient;
if (this.m_GradientEditor != null)
{
this.m_GradientEditor.Init(newGradient, 0);
}
base.Repaint();
}
开发者ID:randomize,项目名称:VimConfig,代码行数:9,代码来源:GradientPicker.cs
示例11: Init
public void Init(Gradient gradient, int numSteps)
{
this.m_Gradient = gradient;
this.m_TextureDirty = true;
this.m_NumSteps = numSteps;
this.BuildArrays();
if (this.m_RGBSwatches.Count <= 0)
return;
this.m_SelectedSwatch = this.m_RGBSwatches[0];
}
开发者ID:BlakeTriana,项目名称:unity-decompiled,代码行数:10,代码来源:GradientEditor.cs
示例12: constructor
static public int constructor(IntPtr l) {
try {
UnityEngine.Gradient o;
o=new UnityEngine.Gradient();
pushValue(l,true);
pushValue(l,o);
return 2;
}
catch(Exception e) {
return error(l,e);
}
}
开发者ID:xclouder,项目名称:godbattle,代码行数:12,代码来源:Lua_UnityEngine_Gradient.cs
示例13: constructor
public static int constructor(IntPtr l)
{
try {
UnityEngine.Gradient o;
o=new UnityEngine.Gradient();
pushValue(l,o);
return 1;
}
catch(Exception e) {
LuaDLL.luaL_error(l, e.ToString());
return 0;
}
}
开发者ID:BobLChen,项目名称:hugula,代码行数:13,代码来源:Lua_UnityEngine_Gradient.cs
示例14: Add
public override void Add(object presetObject, string presetName)
{
Gradient gradient = presetObject as Gradient;
if (gradient == null)
{
Debug.LogError("Wrong type used in GradientPresetLibrary");
return;
}
Gradient gradient2 = new Gradient();
gradient2.alphaKeys = gradient.alphaKeys;
gradient2.colorKeys = gradient.colorKeys;
this.m_Presets.Add(new GradientPresetLibrary.GradientPreset(gradient2, presetName));
}
开发者ID:guozanhua,项目名称:UnityDecompiled,代码行数:13,代码来源:GradientPresetLibrary.cs
示例15: Replace
public override void Replace(int index, object newPresetObject)
{
Gradient gradient = newPresetObject as Gradient;
if (gradient == null)
{
Debug.LogError("Wrong type used in GradientPresetLibrary");
return;
}
Gradient gradient2 = new Gradient();
gradient2.alphaKeys = gradient.alphaKeys;
gradient2.colorKeys = gradient.colorKeys;
this.m_Presets[index].gradient = gradient2;
}
开发者ID:guozanhua,项目名称:UnityDecompiled,代码行数:13,代码来源:GradientPresetLibrary.cs
示例16: Reset
protected virtual void Reset()
{
Ramp = new Gradient();
Ramp.colorKeys = new GradientColorKey[] {
new GradientColorKey(Color.black, 0f),
new GradientColorKey(Color.white, 1f)
};
Ramp.alphaKeys = new GradientAlphaKey[] {
new GradientAlphaKey(1f, 0f),
new GradientAlphaKey(1f, 1f)
};
UpdateGradientCache();
}
开发者ID:pryd0008,项目名称:GGJ2016,代码行数:14,代码来源:GradientRampDynamic.cs
示例17: GetModule
public override ModuleBase GetModule()
{
// check that has inputs
if(type != COLORTYPE.COLOR) {
for(int i = 0; i < inputs.Length; i++) {
if(inputs[i] == null) {
return null;
}
}
}
// get module
switch(type) {
case COLORTYPE.GRADIENT:
if(gradient == null) {
gradient = new Gradient();
if(gradientColorKeys != null)
gradient.colorKeys = SerializableGradientColorKey.ToGradientColorKeys(gradientColorKeys);
if(gradientAlphaKeys != null)
gradient.alphaKeys = SerializableGradientAlphaKey.ToGradientColorKeys(gradientAlphaKeys);
}
if(gradientColorKeys == null)
gradientColorKeys = SerializableGradientColorKey.FromGradientColorKeys(gradient.colorKeys);
if(gradientAlphaKeys == null)
gradientAlphaKeys = SerializableGradientAlphaKey.FromGradientColorKeys(gradient.alphaKeys);
module = new GradientModule(inputs[0].GetModule(), gradient);
break;
case COLORTYPE.ADD:
module = new AddColorModule(inputs[0].GetModule(), inputs[1].GetModule());
break;
case COLORTYPE.MULTIPLY:
module = new MultiplyColorModule(inputs[0].GetModule(), inputs[1].GetModule());
break;
case COLORTYPE.BLEND:
module = new BlendColorModule(inputs[0].GetModule(), inputs[1].GetModule(), inputs[2].GetModule());
break;
case COLORTYPE.COLOR:
module = new ColorSource(color.ToColor());
break;
case COLORTYPE.OVERLAY:
module = new OverlayColorModule(inputs[0].GetModule(), inputs[1].GetModule());
break;
}
SetOutputOptions();
return this.module;
}
开发者ID:kurtdog,项目名称:DoubleTapp,代码行数:49,代码来源:ColorNode.cs
示例18: ColorNode
public ColorNode(int x, int y)
: base("Color Node", new SerializableRect(x, y, 200, 150))
{
type = lastType = ColorNode.COLORTYPE.COLOR;
gradient = new Gradient();
if(gradientColorKeys != null && gradientAlphaKeys != null) {
gradient.colorKeys = SerializableGradientColorKey.ToGradientColorKeys(gradientColorKeys);
gradient.alphaKeys = SerializableGradientAlphaKey.ToGradientColorKeys(gradientAlphaKeys);
}
color = new SerializableColor(Color.black);
SetInputs();
}
开发者ID:kurtdog,项目名称:DoubleTapp,代码行数:15,代码来源:ColorNode.cs
示例19: Awake
void Awake()
{
drawTexture = Texture2D.whiteTexture; // get an empty white texture
gradient = PanelWaveform.GetColorGradient(startColor, endColor); // get a color gradient.
if (audioSources.Count == 0) // if we haven't assigned any audio sources
{
if (this.GetComponent<AudioSource>() != null) // try to grab one from this gameobject
{
audioSources.Add(this.GetComponent<AudioSource>());
}
else
{
Debug.LogError("Error! no audio sources attached to AudioSampler.css");
}
}
}
开发者ID:gcanedo,项目名称:globalgamejam2016,代码行数:16,代码来源:AudioSampler.cs
示例20: GetLerp
/// <summary>
/// Returns a gradient that represents a linear interpolation between two colors.
/// </summary>
/// <param name="color1"></param>
/// <param name="color2"></param>
/// <returns></returns>
public static Gradient GetLerp(Color color1, Color color2)
{
var gradient = new Gradient();
var leftColorKey = new GradientColorKey(color1, 0);
var rightColorKey = new GradientColorKey(color2, 1);
var leftAlphaKey = new GradientAlphaKey(color1.a, 0);
var rightAlphaKey = new GradientAlphaKey(color1.a, 1);
gradient.SetKeys(
new[]{leftColorKey, rightColorKey},
new[]{leftAlphaKey, rightAlphaKey});
return gradient;
}
开发者ID:MRGS,项目名称:ArcadeRoyale,代码行数:22,代码来源:GradientExtensions.cs
注:本文中的UnityEngine.Gradient类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论