The default color now is mixed of colors with the default material :
I want that at runtime or before running the game if i set the mode to None set the whole linerenderer in red color :
I tried this but this coloring the linerenderer in white even if i set the color property to red :
IEnumerator SelectAnimation(AnimationType animType)
{
switch (animType)
{
case AnimationType.SingleColorMorph:
yield return RandomSingleColorMorphing(myLineRenderer, morphTime);
break;
case AnimationType.MultiColorMorph:
yield return RandomMultiColorMorphing(myLineRenderer, morphTime);
break;
case AnimationType.Shuffle:
yield return ShuffleGradient(myLineRenderer, .5f);
break;
case AnimationType.Shift:
yield return AnimateLoop(myLineRenderer);
break;
default:
yield return ggg(Color.red);
break;
}
}
private Color ggg(Color color)
{
Material whiteDiffuseMat = new Material(Shader.Find("Unlit/Texture"));
whiteDiffuseMat.color = Color.red;
myLineRenderer.material = whiteDiffuseMat;
return color;
}
I also tried inside the method ggg to set myLineRenderer startcolor and endcolor to red without changing the material but it didn't change anything.
I managed to solve this problem. Here I will explain how you can change the color of a two-point gradient, for example, but it is up to you to add the desired details. First you need to define a gradient with some key-point's, and since the gradient cannot be lerp into another gradient directly, you need to lerp its colors. A main hint is to display the gradient on the line renderer, you need a material that supports it. I used Particle/ Standard Unlit that work's fine.
Ok Here I setup the lineRenderer with a two-point red and blue gradient (for e.g):
private LineRenderer _lineRenderer;
void Start()
{
_lineRenderer = GetComponent<LineRenderer>();
// how to create gradient in script?
var gradient = new Gradient();
gradient.mode = GradientMode.Blend;
var gradientColorKeys = new GradientColorKey[2]
{
new GradientColorKey(Color.red, .2f),
new GradientColorKey(Color.blue, .8f)
};
var alphaKeys = new GradientAlphaKey[2]
{
new GradientAlphaKey(1f, .2f),
new GradientAlphaKey(1f, .8f)
};
gradient.SetKeys(gradientColorKeys, alphaKeys);
_lineRenderer.colorGradient = gradient;
// This enumerator changes color within a specified time
StartCoroutine(MorphToColor(Color.green, Color.magenta, 2f));
}
I also wrote a color change Enumarator in the same class that lerps the color of two specific points:
public IEnumerator MorphToColor(Color color1, Color color2, float morphTime = 1f)
{
Debug.Log("start morph");
var c1 = _lineRenderer.colorGradient.Evaluate(.2f);
var c2 = _lineRenderer.colorGradient.Evaluate(.8f);
var fade = 0f;
while (fade <= 1)
{
var gradient = new Gradient();
gradient.mode = GradientMode.Blend;
var gradientColorKeys = new GradientColorKey[2]
{
new GradientColorKey(Color.Lerp(c1, color1, fade), .2f),
new GradientColorKey(Color.Lerp(c2, color2, fade), .8f)
};
var alphaKeys = new GradientAlphaKey[2]
{
new GradientAlphaKey(1f, .2f),
new GradientAlphaKey(1f, .8f)
};
gradient.SetKeys(gradientColorKeys, alphaKeys);
_lineRenderer.colorGradient = gradient;
yield return new WaitForEndOfFrame();
fade += Time.deltaTime/morphTime;
}
}
As you can see, the result will be like this. I hope it be useful.
Related
Before 5.5 particle system variables could be accessed via ParticleSystem and were read/write. Now they're accessed via ParticleSystem.MainModule and thus a lot of code has become obsolete. The API Updater has not been able to fix most of the issues. I've read through the new documentation but I can't figure out how the new variable types are supposed to be used. For example in JetParticleEffect.cs this line causes a warning:
// set the original properties from the particle system
m_OriginalLifetime = m_System.startLifetime;
The warning states: 'ParticleSystem.startLifetime' is obsolete: 'startLifetime property is deprecated. Use main.startLifetime or main.startLifetimeMultiplier instead.'
I've tried the following:
m_OriginalLifetime = m_System.main.startLifetime;
// error: Cannot implicitly convert type 'UnityEngine.ParticleSystem.MinMaxCurve' to 'float'
I believe the answer has something to do with the minMaxCurve constant variables as this compiles:
m_OriginalLifetime = m_System.main.startLifetime.constant;
But there is almost no explaination in the docs. Can anyone shed some light on this?
Also, where do the new multipliers fit in? I assume where previously you could do this:
particle.startSize *= myMultiplier
... you should now do this?
particle.main.startSizeMultiplier = myMultiplier
particle.startLifetime:
First of all, what Unity did in Unity 5.5 was to add new futures to the ParticleSystem. They also exposed some ParticleSystem API that was hidden before.
ParticleSystem.MainModule.startLifetime is now a type of MinMaxCurve instead of float like ParticleSystem.startLifetime.
By doing this, you are now given more options such as modifying the startLifetime as a curve.
Reading or writing to ParticleSystem.MainModule.startLifetime depends on the value of ParticleSystem.MainModule.startLifetime.mode which is set through the Editor or via code.
The default value of ParticleSystem.MainModule.startLifetime.mode is ParticleSystemCurveMode.Constant
So your m_OriginalLifetime = m_System.main.startLifetime.constant; is fine.
If startLifetime is dynamically or randomly changed to another mode during run-time, then you will have to do something like this:
ParticleSystem m_System = GetComponent<ParticleSystem>();
ParticleSystem.MainModule main = m_System.main;
ParticleSystem.MinMaxCurve minMaxCurve = main.startLifetime;
if (minMaxCurve.mode == ParticleSystemCurveMode.Constant)
{
m_OriginalLifetime = m_System.main.startLifetime.constant;
}
else if (minMaxCurve.mode == ParticleSystemCurveMode.Curve)
{
AnimationCurve animCurveLifetime = m_System.main.startLifetime.curve;
}
...
particle.startSize:
The-same thing apply to particle.startSize.
The particle.startSize property is now m_System.main.startSize;
Although you can't do m_System.main.startSize.constant *= myMultiplier; because your old code was particle.startSize *= myMultiplier.
You need to get m_System.main.startSize, modify it then assign the modified m_System.main.startSize back to m_System.main.startSize.
particle.startSize *= myMultiplier should be:
ParticleSystem m_System = GetComponent<ParticleSystem>();
ParticleSystem.MainModule main = m_System.main;
ParticleSystem.MinMaxCurve minMaxCurve = main.startSize; //Get Size
minMaxCurve.constant *= myMultiplier; //Modify Size
main.startSize = minMaxCurve; //Assign the modified startSize back
Then, what are particle.main.startSizeMultiplier and particle.main.startSize used for?
This two variables can also be used to change startLifetime and startSize. It's main advantage is that it is very efficient. It does not not require that you make a copy of MinMaxCurve like we did above, in order to change startSize or startSizeMultiplier.
ParticleSystem m_System = GetComponent<ParticleSystem>();
ParticleSystem.MainModule main = m_System.main;
main.startSizeMultiplier = 5;
and
ParticleSystem m_System = GetComponent<ParticleSystem>();
ParticleSystem.MainModule main = m_System.main;
main.startLifetimeMultiplier = 8;
Use them if your ParticleSystem.MainModule.startLifetime.mode is constant. This will to change the overall lifetime multiplier or the the overall size multiplier efficiently.
Changing Color and Color Modes
Color:
There is an implicit operator that lets you use:
ParticleSystem.MainModule main = trailPartical.main;
main.startColor = Color.red;
but startColor is not actually type of Color. The startColor variable is now a type of ParticleSystem.MinMaxGradient.
This is how you should be changing the particle startColor:
//Create Color
ParticleSystem.MinMaxGradient color = new ParticleSystem.MinMaxGradient();
color.mode = ParticleSystemGradientMode.Color;
color.color = Color.red;
//Assign the color to your particle
ParticleSystem.MainModule main = trailPartical.main;
main.startColor = color;
Gradient:
public ParticleSystem particleSystem;
void Start()
{
//Create Gradient key
GradientColorKey[] gradientColorKey;
gradientColorKey = new GradientColorKey[3];
gradientColorKey[0].color = Color.red;
gradientColorKey[0].time = 0f;
gradientColorKey[1].color = Color.blue;
gradientColorKey[1].time = 0.5f;
gradientColorKey[2].color = Color.green;
gradientColorKey[2].time = 1f;
//Create Gradient alpha
GradientAlphaKey[] gradientAlphaKey;
gradientAlphaKey = new GradientAlphaKey[3];
gradientAlphaKey[0].alpha = 1.0f;
gradientAlphaKey[0].time = 0.0f;
gradientAlphaKey[1].alpha = 0.5f;
gradientAlphaKey[1].time = 0.5f;
gradientAlphaKey[2].alpha = 1f;
gradientAlphaKey[2].time = 1f;
//Create Gradient
Gradient gradient = new Gradient();
gradient.SetKeys(gradientColorKey, gradientAlphaKey);
//Create Color from Gradient
ParticleSystem.MinMaxGradient color = new ParticleSystem.MinMaxGradient();
color.mode = ParticleSystemGradientMode.Gradient;
color.gradient = gradient;
//Assign the color to particle
ParticleSystem.MainModule main = particleSystem.main;
main.startColor = color;
}
Random Between Two Colors:
//Create Color from Gradient
ParticleSystem.MinMaxGradient color = new ParticleSystem.MinMaxGradient();
color.mode = ParticleSystemGradientMode.TwoColors;
color.colorMin = Color.red;
color.colorMax = Color.green;
//Assign the color to the particle
ParticleSystem.MainModule main = particleSystem.main;
main.startColor = color;
Random Between Two Gradients:
public ParticleSystem particleSystem;
void Start()
{
//Create Gradient key Min
GradientColorKey[] gradientColorKeyMin;
gradientColorKeyMin = new GradientColorKey[3];
gradientColorKeyMin[0].color = Color.red;
gradientColorKeyMin[0].time = 0f;
gradientColorKeyMin[1].color = Color.blue;
gradientColorKeyMin[1].time = 0.5f;
gradientColorKeyMin[2].color = Color.green;
gradientColorKeyMin[2].time = 1f;
//Create Gradient alpha Min
GradientAlphaKey[] gradientAlphaKeyMin;
gradientAlphaKeyMin = new GradientAlphaKey[3];
gradientAlphaKeyMin[0].alpha = 1.0f;
gradientAlphaKeyMin[0].time = 0.0f;
gradientAlphaKeyMin[1].alpha = 0.5f;
gradientAlphaKeyMin[1].time = 0.5f;
gradientAlphaKeyMin[2].alpha = 1f;
gradientAlphaKeyMin[2].time = 1f;
//Create Gradient key Max
GradientColorKey[] gradientColorKeyMax;
gradientColorKeyMax = new GradientColorKey[3];
gradientColorKeyMax[0].color = Color.red;
gradientColorKeyMax[0].time = 0f;
gradientColorKeyMax[1].color = Color.blue;
gradientColorKeyMax[1].time = 0.5f;
gradientColorKeyMax[2].color = Color.green;
gradientColorKeyMax[2].time = 1f;
//Create Gradient alpha Max
GradientAlphaKey[] gradientAlphaKeyMax;
gradientAlphaKeyMax = new GradientAlphaKey[3];
gradientAlphaKeyMax[0].alpha = 1.0f;
gradientAlphaKeyMax[0].time = 0.0f;
gradientAlphaKeyMax[1].alpha = 0.5f;
gradientAlphaKeyMax[1].time = 0.5f;
gradientAlphaKeyMax[2].alpha = 1f;
gradientAlphaKeyMax[2].time = 1f;
//Create Gradient Min
Gradient gradientMin = new Gradient();
gradientMin.SetKeys(gradientColorKeyMin, gradientAlphaKeyMin);
//Create Gradient Max
Gradient gradientMax = new Gradient();
gradientMax.SetKeys(gradientColorKeyMax, gradientAlphaKeyMax);
//Create Color from Gradient
ParticleSystem.MinMaxGradient color = new ParticleSystem.MinMaxGradient();
color.mode = ParticleSystemGradientMode.TwoGradients;
color.gradientMin = gradientMin;
color.gradientMax = gradientMax;
//Assign the color to the particle
ParticleSystem.MainModule main = particleSystem.main;
main.startColor = color;
}
Random Color:
public ParticleSystem particleSystem;
void Start()
{
//Create Gradient key Min
GradientColorKey[] gradientColorKeyMin;
gradientColorKeyMin = new GradientColorKey[3];
gradientColorKeyMin[0].color = Color.red;
gradientColorKeyMin[0].time = 0f;
gradientColorKeyMin[1].color = Color.blue;
gradientColorKeyMin[1].time = 0.5f;
gradientColorKeyMin[2].color = Color.green;
gradientColorKeyMin[2].time = 1f;
//Create Gradient alpha Min
GradientAlphaKey[] gradientAlphaKeyMin;
gradientAlphaKeyMin = new GradientAlphaKey[3];
gradientAlphaKeyMin[0].alpha = 1.0f;
gradientAlphaKeyMin[0].time = 0.0f;
gradientAlphaKeyMin[1].alpha = 0.5f;
gradientAlphaKeyMin[1].time = 0.5f;
gradientAlphaKeyMin[2].alpha = 1f;
gradientAlphaKeyMin[2].time = 1f;
//Create Gradient key Max
GradientColorKey[] gradientColorKeyMax;
gradientColorKeyMax = new GradientColorKey[3];
gradientColorKeyMax[0].color = Color.red;
gradientColorKeyMax[0].time = 0f;
gradientColorKeyMax[1].color = Color.blue;
gradientColorKeyMax[1].time = 0.5f;
gradientColorKeyMax[2].color = Color.green;
gradientColorKeyMax[2].time = 1f;
//Create Gradient alpha Max
GradientAlphaKey[] gradientAlphaKeyMax;
gradientAlphaKeyMax = new GradientAlphaKey[3];
gradientAlphaKeyMax[0].alpha = 1.0f;
gradientAlphaKeyMax[0].time = 0.0f;
gradientAlphaKeyMax[1].alpha = 0.5f;
gradientAlphaKeyMax[1].time = 0.5f;
gradientAlphaKeyMax[2].alpha = 1f;
gradientAlphaKeyMax[2].time = 1f;
//Create Gradient Min
Gradient gradientMin = new Gradient();
gradientMin.SetKeys(gradientColorKeyMin, gradientAlphaKeyMin);
//Create Gradient Max
Gradient gradientMax = new Gradient();
gradientMax.SetKeys(gradientColorKeyMax, gradientAlphaKeyMax);
//Create Color from Gradient
ParticleSystem.MinMaxGradient color = new ParticleSystem.MinMaxGradient();
color.mode = ParticleSystemGradientMode.RandomColor;
color.gradientMin = gradientMin;
color.gradientMax = gradientMax;
//Assign the color to the particle
ParticleSystem.MainModule main = particleSystem.main;
main.startColor = color;
}
I am using color.lerp on a sprite renderer to interpolate between yellow and red based on values I have in a dataset. I also want the transparency of the sprites to depend on the value so lower values will be more transparent. The color.lerp works fine but I am now having trouble getting the alpha levels of the sprite to depend on the value as well! Here is my code so far:
using UnityEngine;
using System.Collections;
public class Intensity : MonoBehaviour {
public float value;
private float alpha;
void Start() {
if (GetComponent<SpriteRenderer> ()) {
SpriteRenderer r = GetComponent<SpriteRenderer> ();
r.color = new Color32 ();
r.color = Color.Lerp (Color.yellow, Color.red, value / 100);
}
if (GetComponent<MeshRenderer> ()) {
MeshRenderer r = GetComponent<MeshRenderer> ();
Material m = r.material;
Color c = new Color ();
m.color = c;
alpha = Mathf.Lerp(0, 1, value/100) ;
c.a = alpha;
}
}
}
Any ideas to make this work would be greatly appreciated!
Thank you,
Jen
In this code:
Material m = r.material;
Color c = new Color ();
m.color = c;
alpha = Mathf.Lerp(0, 1, value/100) ;
c.a = alpha;
Because Color is a struct, any get and set properties such as Material.color will pass by value. This means that c and m.color are separate values that don't affect each other.
You can avoid that by assigning to m.color last:
Color c = Color.Lerp(newYellow, Color.red, value / 100);
c.a = Mathf.Lerp(0, 1, value/100);
m.color = c;
If that doesn't make sense, see if you can understand why this won't work:
m.color.a = 0;
You instead have to get the value, make a change, and assign the new value:
Color c = m.color;
c.a = 0;
m.color = c;
I'm trying to do a fade between two colors on a weather system in C#. I'm using the following code to fade the color of the keys of a gradient used by the clouds:
void ChangeWeather(string to)
{
Gradient g = skyController.WispyColorGradientColor[0];
GradientColorKey[] gck = new GradientColorKey[5];
GradientAlphaKey[] gak = new GradientAlphaKey[2];
gak[0].alpha = 1f;
gak[1].alpha = 1f;
gak[0].time = 0f;
gak[1].time = 100f;
Color color = new Color();
skyController.WispyColorGradientColor[0] = g;
//Set the initial value
gck[0] = g.colorKeys[0];
gck[1] = g.colorKeys[1];
gck[2] = g.colorKeys[2];
gck[3] = g.colorKeys[3];
gck[4] = g.colorKeys[4];
//refer te variables
g.colorKeys[0] = gck[0];
g.colorKeys[1] = gck[1];
g.colorKeys[2] = gck[2];
g.colorKeys[3] = gck[3];
g.colorKeys[4] = gck[4];
//set the times
gck[0].time = .209f;
gck[1].time = .238f;
gck[2].time = .50f;
gck[3].time = .756f;
gck[4].time = .791f;
if (to == "clear")
{
ColorUtility.TryParseHtmlString(cleanCloudsColors[0], out color);
gck[0].color = Color.Lerp(g.colorKeys[0].color, color, changeSpeed * Time.deltaTime);
gck[4].color = Color.Lerp(g.colorKeys[4].color, color, changeSpeed * Time.deltaTime);
ColorUtility.TryParseHtmlString(cleanCloudsColors[1], out color);
gck[1].color = Color.Lerp(g.colorKeys[1].color, color, changeSpeed * Time.deltaTime);
gck[3].color = Color.Lerp(g.colorKeys[3].color, color, changeSpeed * Time.deltaTime);
ColorUtility.TryParseHtmlString(cleanCloudsColors[2], out color);
gck[2].color = Color.Lerp(g.colorKeys[2].color, color, changeSpeed * Time.deltaTime);
Debug.Log("Changing");
}
}
The "skyController.WispyColorGradientColor[0]" refers to a Gradient in a array list and "ColorUtility.TryParseHtmlString" just convert a hex color (like #fff) to RGB. It log "Changing" but, well, the clouds were changing color without fade, so I made these changes and it does not change more. I NEED THE FADE, but nothing seems to work. :(
EDIT: I used a code like it to try to fade between colors in 5 seconds:
float fadeTime = 5f;
void Update(){
//...
if (param)
StartCoroutine(fadeColor(0, Color.grey, Color.white));
//...
}
IEnumerator fadeColor (int index, Color from, Color to){
float counter = 0;
while (counter < fadeTime){
counter += Time.deltaTime;
gradient.colorKeys[index].color = Color.Lerp(from, to, counter / fadeTime);
}
yield return null;
}
It change the color, but change instantly and I want to change over time.
Not able to understand your code and but all I know is that you want to fade between two Colors. This should be done with Coroutine. The function below should fade between two colors in any GameObject. You can easily modify it to suit whatever you are doing.
The function call below will change the GameObject's color to red in 5 seconds.
StartCoroutine(fadeColor(obj, Color.red, 5));
Fade Function:
IEnumerator fadeColor(GameObject objectToFade, Color newColor, float fadeTime = 3)
{
int mode = 0;
Color currentColor = Color.clear;
SpriteRenderer tempSPRenderer = objectToFade.GetComponent<SpriteRenderer>();
Image tempImage = objectToFade.GetComponent<Image>();
RawImage tempRawImage = objectToFade.GetComponent<RawImage>();
Renderer tempRenderer = objectToFade.GetComponent<Renderer>();
//Check if this is a Sprite
if (tempSPRenderer != null)
{
currentColor = tempSPRenderer.color;
mode = 0;
}
//Check if Image
else if (tempImage != null)
{
currentColor = tempImage.color;
mode = 1;
}
//Check if RawImage
else if (tempRawImage != null)
{
currentColor = tempRawImage.color;
mode = 2;
}
//Check if 3D Object
else if (tempRenderer != null)
{
currentColor = tempRenderer.material.color;
mode = 3;
}
else
{
yield break;
}
float counter = 0;
while (counter < fadeTime)
{
counter += Time.deltaTime;
switch (mode)
{
case 0:
tempSPRenderer.color = Color.Lerp(currentColor, newColor, counter / fadeTime);
break;
case 1:
tempImage.color = Color.Lerp(currentColor, newColor, counter / fadeTime);
break;
case 2:
tempRawImage.color = Color.Lerp(currentColor, newColor, counter / fadeTime);
break;
case 3:
tempRenderer.material.color = Color.Lerp(currentColor, newColor, counter / fadeTime);
break;
}
yield return null;
}
}
So I am working on a menu for my game. Here's the code for a single button:
// button class
public class ButtonGUI
{
public SpriteFont spriteFont;
string btnTxt;
public Rectangle btnRect;
Color colour;
public ButtonGUI(string newTxt, Rectangle newRect, SpriteFont newSpriteFont, Color newColour)
{
spriteFont = newSpriteFont;
btnRect = newRect;
btnTxt = newTxt;
colour = newColour;
}
public void Draw(SpriteBatch spriteBatch)
{
// TextOutliner() is a static helper class for drawing bordered spritefonts I made
TextOutliner.DrawBorderedText(spriteBatch, spriteFont, btnTxt, btnRect.X, btnRect.Y, colour);
}
}
// TitleScreen.cs
ButtonGUI btnPlay, btnPlay_2;
bool indexPlay;
string[] menuTxt;
SpriteFont GameFontLarge, GameFontLargeHover;
// LoadContent() method:
// Load both spritefonts....
menuTxt = new string[4];
menuTxt[0] = "Play Game";
menuTxt[1] = "Achievements";
menuTxt[2] = "Settings";
menuTxt[3] = "Exit Game";
btnPlay = new ButtonGUI(menuTxt[0], new Rectangle(150, 300, (int)GameFontLarge.MeasureString(menuTxt[0]).X, (int)GameFontLarge.MeasureString(menuTxt[0]).Y), GameFontLarge, Color.White);
btnPlay_2 = new ButtonGUI(menuTxt[0], new Rectangle(150, 300, (int)GameFontLargeHover.MeasureString(menuTxt[0]).X, (int)GameFontLargeHover.MeasureString(menuTxt[0]).Y), GameFontLargeHover, Color.Yellow);
// Update() method:
MouseState mouseState = Mouse.GetState();
Rectangle mouseRect = new Rectangle(mouseState.X, mouseState.Y, 1, 1);
if (mouseRect.Intersects(btnPlay.btnRect))
{
indexPlay = true;
if (mouseState.LeftButton == ButtonState.Pressed) Game1.CurrentGameState = Game1.GameState.playScreen;
}
else indexPlay = false;
// Draw() method:
if (indexPlay)
{
btnPlay_2.Draw(spriteBatch);
}
else btnPlay.Draw(spriteBatch);
So I do all of this for 4 different buttons. The 2 sprite fonts are of the same font but with different size. Now when I test the game, when I mouse-hover on each of the buttons, the text changes from white to yellow and becomes larger. But since the button coordinates are done with x = left-most; y = top-most when the font changes the bigger font is drawn at the same position as the smaller one was. I want to get a decent "scale" effect when mouse-hovering. I mean I know I set the button position to that when initializing, but still I need some type of algorithm to find a way and draw the bigger font on the center of the older... What would be your approach?
You could change the position of your hover button based on the size difference:
var sizeDifference = btnPlay_2.btnRect.Size - btnPlay.btnRect.Size;
btnPlay_2.btnRect.Offset(-sizeDifference.X/2, -sizeDifference.Y/2);
I want to apply a texture or a color on a game object. I wrote this code so far but the color part is not working. The texture is applied, so at least something is right. Depends of the type of the object i am applying a texture or a color, not both at the same time.
If i play the scene i can see a new material getting assign (i see it in the inspector panel) but with a white color.
GameObject o = GameObject.Find(items[i].name + "/" + ifv.field_details.name);
if (o != null){
if (ifv.field_details.type_id.Equals(Strings.colorType)){
//set the color
string[] c = ifv.value.Split(',');
Color color = new Color(float.Parse(c[1]),float.Parse(c[2]),float.Parse(c[3]),float.Parse(c[0]));
Material material = new Material(Shader.Find("Diffuse"));
material.color = color;
o.renderer.material = material;
}
if (ifv.field_details.type_id.Equals(Strings.textureType)){
//set the texture
string url = Strings.texturesHost + ifv.value;
WWW www = new WWW (url);
yield return www;
o.renderer.material.mainTexture = www.texture;
}
}
Any idea why the color if statement is not working ?
The answer was : divide each number by 255. I don't know the explanaition but it looks that new Color() expects the parameters to be between 0 and 1.