Yeah, the tittle pretty much explains it. I have three arrays that goes towards collecting data from different light components found on another array, but when trying to assign these values to the three arrays of the Lights it tells me this…
error CS0029: Cannot implicitly convert type UnityEngine.Color' to
UnityEngine.Color[]’ line 71
error CS0029: Cannot implicitly convert type float’ to
float[]’ lines 72 and 73 x2
So what I’m asking is, what am I doing wrong or what’s a way around this to still get what I want done? Here’s the code where it is going wrong with the for loop and all, thanks in advace:
using UnityEngine;
using System.Collections;
public class LightFlickerPulse : MonoBehaviour {
public enum UseType {Color, Intensity, Range, Off}
public UseType useType;
public enum WaveFunction {Noise, Sin, Tri, Sqr, Saw, SawInv}
public WaveFunction waveFunction;
public float timescaleMinWorking = 0.1f;
public float coreBase = 0.8f;
public float amplitude = 0.4f;
public float phase;
public float frequency = 0.5f;
public bool useOutsideLight;
public Light[] outsideLight;
private Color mainColor;
private float mainValueI;
private float mainValueR;
private Color[] mainOutColor = new Color[50];
private float[] mainOutValueI = new float[50];
private float[] mainOutValueR = new float[50];
private Light lightS;
private bool error1;
private bool error2;
private bool assigned;
private float x;
private float y;
private float z;
void Update(){
if(lightS == null){
if(useOutsideLight){
lightS = outsideLight[1];
}else{
lightS = gameObject.light;
}
}
if(!assigned){
if(GetComponent<Light>() != null){
mainColor = light.color;
mainValueI = light.intensity;
mainValueR = light.range;
if(error1){
Debug.Log ("FIXED ERROR REPORT: The missing Light component on the gameObject " + "'" +gameObject.name + "'" + " has been succesfully re-established!", gameObject);
error1 = false;
}
assigned = true;
}else if(!error1){
Debug.LogError ("ERROR MISSING COMPONENT: The gameObject " + "'" +gameObject.name + "'" + " does not have a Light component attached to it. If you wish to use a Light from another gameObject, please select the boolean variable 'Use Outside Light' for this feature.", gameObject);
error1 = true;
}
if(outsideLight.Length > 0 && outsideLight.Length < 50){
for(int i = 0; i < outsideLight.Length; i++){
if(outsideLight *== null){*
-
error2 = true;*
-
Debug.LogError ("ERROR EMPTY VARIABLE: The gameObject " + "'" +gameObject.name + "'" + " does not have a gameObject with a Light component attached to the variable 'Outside Light' index number " + "[ " + i + " ], to fix this either, assign a gameObject with a Light component in this space or, lowwer the size amount to fix your assigned lights. If you do not wish to use this feature, un-tick the boolean variable 'Use Outside Light.'", gameObject);*
-
Debug.LogError ("VARIABLE ADDITIONAL INFORMATION: This feature does not allow for fixing after the error has occured due to strict limintations of the 'for' loop, you must replay with the Light component attached to the variable 'Outside Light' index number " + "[ " + i + " ], correctly.", gameObject);*
-
}else{*
_ mainOutColor = outsideLight*.color;_
_ mainOutValueI = outsideLight.intensity;
mainOutValueR = outsideLight.range;
}
}
if(!error2){
assigned = true;
}
}else if(!outsideLight.Length < 50){
Debug.LogError ("ERROR EXCEDING ARRAY LIMITATIONS: Due to this script having to pre-load other array variables to gather all the Light components information a desision was made on how many arrays as max should be pre-defined to remove any performance issues. To fix this error you could modify this script to allowcate more avaliable spots located in the defining variables section or remove some or many Light components from the array list on the gameObject " + “'” +gameObject.name + “'. The defined Light components past the 49th index number will not work under this script.”, gameObject);
}
}
if(((!error1 && !useOutsideLight) || (!error2 && useOutsideLight)) && assigned && useType != UseType.Off && Time.timeScale > timescaleMinWorking){
CalWaveFunc();
if(useType == UseType.Color){
lightS.color = mainColor * (z);
}else if(useType == UseType.Intensity){
lightS.intensity = mainValueI * (z);
}else if(useType == UseType.Range){
lightS.range = mainValueR * (z);
}
}
if(lightS != null){
if(mainValueI != lightS.intensity && (useType != UseType.Intensity)){
lightS.intensity = mainValueI;
}
if(mainValueR != lightS.range && (useType != UseType.Range)){
lightS.range = mainValueR;
}
if(mainColor != lightS.color && (useType != UseType.Color)){
lightS.color = mainColor;
}
}
}*_
* void CalWaveFunc(){*
_ x = (Time.time + phase)frequency;
x = x - Mathf.Floor(x);*_
* if(waveFunction == WaveFunction.Sin){*
_ y = Mathf.Sin(x2Mathf.PI);
* }else if(waveFunction == WaveFunction.Tri){
if(x<0.5f){
y=4.0fx-1.0f;
* }else{
y=-4.0fx-3.0f;
* }
}else if(waveFunction == WaveFunction.Sqr){
if(x<0.5f){
y=1.0f;
}else{
y=-1.0f;
}
}else if(waveFunction == WaveFunction.Saw){
y=x;
}else if(waveFunction == WaveFunction.SawInv){
y=1.0f-x;
}else if(waveFunction == WaveFunction.Noise){
y=1-(Random.value2);
* }
z = (yamplitude)+coreBase;
* }
}*_