本文整理汇总了C#中Color.SetValue方法的典型用法代码示例。如果您正苦于以下问题:C# Color.SetValue方法的具体用法?C# Color.SetValue怎么用?C# Color.SetValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Color
的用法示例。
在下文中一共展示了Color.SetValue方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Fill
public void Fill(Color Color)
{
Color[] colors = new Color[texture.Width * texture.Height];
for (int i = 0; i < colors.Length; i++)
{ colors.SetValue(Color, i); }
texture.SetData<Color>(colors);
}
示例2: GetColourArray
//Get an array of Colours
public static Color[] GetColourArray( string key )
{
Color[] returns = new Color[PlayerPrefs.GetInt("PlayerPrefsArray:Colour:L:"+key)];
int i = 0;
while(i < PlayerPrefs.GetInt("PlayerPrefsArray:Colour:L"+key)){
returns.SetValue(PlayerPrefsPlus.GetColour("PlayerPrefsArray:Colour:"+key + i.ToString()), i);
++i;
}
return returns;
}
示例3: objPrefabToAndroid
//.........这里部分代码省略.........
}
}
newPrefab = PrefabUtility.CreatePrefab(newPrePath, test);
GameObject.DestroyImmediate(test);
foreach (Texture2D t in texs.Values)
{
//Debug.Log("texture:" + t.name);
string cTexPath = androidTexFolder + t.name + "_c.png";
string aTexPath = androidTexFolder + t.name + "_a.png";
if(!File.Exists(cTexPath) && !File.Exists(aTexPath))
{
string texturePath = AssetDatabase.GetAssetPath(t);
TextureImporter textureImporter = (TextureImporter)AssetImporter.GetAtPath(texturePath);
textureImporter.textureType = TextureImporterType.Advanced;
textureImporter.isReadable = true;
textureImporter.mipmapEnabled = false;
AssetDatabase.ImportAsset(texturePath, ImportAssetOptions.ForceUpdate);
//Debug.Log("propertives updated");
Color32[] cols = t.GetPixels32();
Color[] cCols = new Color[cols.Length];
Color[] aCols = new Color[cols.Length];
int id = -1;
foreach (Color32 c in cols)
{
id++;
cCols.SetValue(new Color((float)c.r / 255, (float)c.g / 255, (float)c.b / 255), id);
aCols.SetValue(new Color((float)c.a / 255, (float)c.a / 255, (float)c.a / 255), id);
}
Texture2D colorTexture = new Texture2D(t.width, t.height);
colorTexture.SetPixels(cCols);
colorTexture.Apply();
Texture2D maskTexture = new Texture2D(t.width, t.height);
maskTexture.SetPixels(aCols);
maskTexture.Apply();
// Debug.Log("pixels done");
byte[] byt = colorTexture.EncodeToPNG();
File.WriteAllBytes(cTexPath, byt);
byt = maskTexture.EncodeToPNG();
File.WriteAllBytes(aTexPath, byt);
textureImporter.isReadable = false;
//Debug.Log("-----------------------texture saved");
cTexPath = cTexPath.Replace(Application.dataPath, "Assets");
aTexPath = aTexPath.Replace(Application.dataPath, "Assets");
AssetDatabase.ImportAsset(cTexPath);
AssetDatabase.ImportAsset(aTexPath);
}
}
foreach (Material mat in mats.Values)
{
示例4: Generate
public void Generate()
{
// Highly experimental
// Componer paleta
Color[] tpalette = new Color[paleta_extra.Length];//[256];
int i = 0;
for (int x = 0; x < width; x++)
{
for (int y = 0; y < height; y++)
{
Color color = bitmap.GetPixel(x, y);
if (!tpalette.Contains(color))
{
tpalette.SetValue(color, i);
i++;
}
}
}
// Pasar la paleta a 555Color
palette = new _555Color[tpalette.Length];
for (int j = 0; j < tpalette.Length; j++)
{
//palette.SetValue(new _555Color(tpalette[j]), j);
palette.SetValue(paleta_extra[j], j);
}
// Generar los tiles numericos
int total = width * height;
total_tiles = (ushort)(total / 64);
int current = 0;
int extra_x = 0;
int extra_y = 0;
// array con todos los bytes de los tiles
tiles = new byte[width * height];
while (current < total)
{
for (int y = 0; y < 8; y++)
{
for (int x = 0; x < 8; x++)
{
Color color = bitmap.GetPixel(x + extra_x, y + extra_y);
_555Color color2 = new _555Color(color);
for (int j = 0; j < palette.Length; j++)
{
if (palette[j].Int16 == color2.Int16)
{
// Guardar la posicion del color
tiles.SetValue((byte)j, current);
break;
}
else { tiles.SetValue((byte)0, current); }
}
current++;
}
}
extra_x += 8;
if (extra_x >= width)
{
extra_x = 0;
extra_y += 8;
}
}
}