Question by
GameDeveloperAf · Apr 04, 2021 at 12:11 PM ·
arrayarraysclassclasses
[SOLVED] Increase and Decrease size of Class Array in Unity C#
I want to store positions, rotations, ID, texture ID, inside of classes array like this
[System.Serializable]
public class ObjectDetails
{
public int ObjectID, TextureID;
public Vector3[] ObjectPositions;
public Quaternion ObjectRotations;
}
public class ObjectScript: MonoBehaviour
{
public ObjectDetails[] objectdetails;
void Update()
{
// How to add something into ObjectDetails class array
// I mean how to increase size of the array
}
}
How to increase size of ObjectDetails classes.
Comment
Best Answer
Answer by GameDeveloperAf · Apr 04, 2021 at 04:34 PM
I found how to add.
public class MyDatas
{
public Vector position;
}
public List<MyDatas> myDatas;
if (Input.GetKeyDown(KeyCode.N))
{
myDatas.Add(new MyDatas());
}
Your answer
Follow this Question
Related Questions
Having problems with custom objects in my array - BCE0019 0 Answers
(SOLVED) Accessing (string) arrays by enumerations from another class 0 Answers
Managing In-Game Variables of Different Data Types 1 Answer
Unity 3D C# - Making Classes Act Like An Array 3 Answers
Getting an error when using an Array of String Arrays 0 Answers