
Error en C# Script Unity3D
Publicado por José Antonio (1 intervención) el 14/05/2023 01:20:17
Buenas compañeros!
Me ha surgido un error de compilación en un Script que he creado para Unity 3D. He declarado como variables unas arrays y las recorro con un 'for'. Me falla en la línea 'this.createdDecals.Lenght'. Me da el siguiente error de compilación:
error CS1061: 'GameObject[]' does not contain a definition for 'Lenght' and no accessible extension method 'Lenght' accepting a first argument of type 'GameObject[]' could be found (are you missing a using directive or an assembly reference?)
¿Dónde puede estar el error?¿Cómo lo soluciono?
¡¡Muchas gracias de antemano!!
Me ha surgido un error de compilación en un Script que he creado para Unity 3D. He declarado como variables unas arrays y las recorro con un 'for'. Me falla en la línea 'this.createdDecals.Lenght'. Me da el siguiente error de compilación:
error CS1061: 'GameObject[]' does not contain a definition for 'Lenght' and no accessible extension method 'Lenght' accepting a first argument of type 'GameObject[]' could be found (are you missing a using directive or an assembly reference?)
¿Dónde puede estar el error?¿Cómo lo soluciono?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
public class Shooter : MonoBehaviour
{
private Ray rayo;
private RaycastHit hit;
public float distanciaDisparo;
private Camera camara;
private Vector2 centroCamara;
public GameObject[] decalsPrefabs; //Array de los Prefabs
public GameObject[] createdDecals; //Array para crear los Decals
public int decalIndex;
public float tiempoDisparo;
private float tiempoUltimoDisparo;
private Quaternion rotDecal;
private Vector3 posDecal;
public LayerMask decalLayerMask;
// Awake is called before the pay the game
void Awake()
{
this.camara = gameObject.transform.GetChild(0).GetComponent<Camera>();
this.centroCamara.x = Screen.width / 2;
this.centroCamara.y = Screen.height / 2;
this.tiempoUltimoDisparo = Time.time;
for(int decalNum=0;decalNum<this.createdDecals.Lenght;decalNum++)
{
this.createdDecals[decalNum] = GameObject.Instantiate(this.decalsPrefabs[0], Vector3.zero, Quaternion.identity) as GameObject;
this.createdDecals[decalNum].GetComponent<Renderer>().enabled = false;
}
this.decalIndex = 0;
}
// Update is called once per frame
void Update()
{
if(Input.GetButtonDown("Fire1"))
{
if((Time.time-this.tiempoUltimoDisparo)>this.tiempoDisparo)
{
this.rayo = this.camara.ScreenPointToRay(this.centroCamara);
this.tiempoUltimoDisparo = Time.time;
if(Physics.Raycast(this.rayo,out this.hit,this.distanciaDisparo,this.decalLayerMask))
{
this.rotDecal = Quaternion.FromToRotation(Vector3.forward, this.hit.normal);
this.posDecal = this.hit.point + this.hit.normal * 0.01f;
this.createdDecals[this.decalIndex].transform.position = this.posDecal;
this.createdDecals[this.decalIndex].transform.rotation = this.rotDecal;
this.createdDecals[this.decalIndex].GetComponent<Renderer>().enabled = true;
this.decalIndex++;
if(this.decalIndex>9)
{
this.decalIndex = 0;
}
}
}
}
}
}
¡¡Muchas gracias de antemano!!
Valora esta pregunta


0