Have two decal objects with the script(Decal) and I need to run this on both objects, it this correct?
for(int i=0;i<decalObjects.Length;i++)
{
Decal Decal = decalObjects*.GetComponentInChildren<Decal>();*
-
Decal.affectInactiveRenderers=true;*
-
Decal.updateDecal=true;*
-
if(Decal.HasChanged())*
-
{*
-
Debug.Log("Decal was updated");*
-
Decal.ClearDecals();*
-
if(Decal.checkAutomatically){GetAffectedObjects(Decal);}*
-
Decal.CalculateDecal();*
-
}*
}
Here is the problem:
Decal Decal = decalObjects*.GetComponentInChildren<Decal>();*
Your Decal is a class not an instance, you should do this instead:
Decal someDecal = decalObjects*.GetComponentInChildren();*
//and then use it as someDecal
P.S. Also make sure that decalObjects or one of its child actually has Decal script in it.
Thanks for advice, seems like for some reason (still not sure why) one of the objects would not find the objects affected by the decal and thus it wasnt able to calculate the decal… This seemed to happen randomly to one or the other. I solved it by calling another function from the decal script, so I don’t think it had anything to do with the for loop after all…
This is the decal system from the Bootcamp demo.
void Start(){
// update all decals
// find decals
decalObjects[0] = GameObject.Find("DecalLeft");
decalObjects[1] = GameObject.Find("DecalRight");
if(decalObjects.Length!=0){ // if decals exist
decalObjects[0].transform.parent=decalLeft.transform;
decalObjects[0].transform.localPosition= new Vector3(0,0,0); //
decalObjects[0].transform.localRotation= Quaternion.identity;
decalObjects[0].transform.localScale= new Vector3(1,1,1);
decalObjects[1].transform.parent=decalRight.transform;
decalObjects[1].transform.localPosition= new Vector3(0,0,0); //
decalObjects[1].transform.localRotation= Quaternion.identity;
decalObjects[1].transform.localScale= new Vector3(1,1,1);
for(int i=0;i<decalObjects.Length;i++)
{
Decal decal = decalObjects*.GetComponentInChildren<Decal>();*
-
//decal.affectInactiveRenderers=true;*
-
decal.CalculateBounds();*
-
decal.updateDecal=true;*
-
if(decal.HasChanged())*
-
{*
-
Debug.Log("Decal was updated");*
-
decal.ClearDecals();*
-
if(decal.checkAutomatically){GetAffectedObjects(decal);}*
-
decal.CalculateDecal();*
-
}*
-
} *
-
}*
}