I'm quite new to Unity.
I have a few questions to ask:
----------------------------------------------------------------- Question 1 -----------------------------------------------------------------------------------
1. How do I add a custom Class type, for example, let's say a "Ball" class with these variables?
Code: Select all
public class Ball : MonoBehaviour
{
public Vector2 ballLocation;
public bool ballBounce;
}
3. Should I replace all the error keywords with my class Name?
--------------------------------------------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------- Question 2 ---------------------------------------------------------------------------------
1. If I manage to add the customer class "Ball" type, will it work if I add it to a List<T> then saving the list directly as such:
Code: Select all
public class GameManager : MonoBehaviour
{
List<Ball> ballList = new List<Ball>();
Piece ballObj = new Piece();
ballObj = GetComponent<Ball>();
ballObj.position.x = 2.0f;
ballObj.position.y = 2.0f;
ballObj.ballBounce = true;
ballList.Add(ballObj);
ES2.Save(ballList, "Match1.txt?tag=runnerUp");
}
--------------------------------------------------------------------------------------------------------------------------------------------------------------
Thanks in advance.
Regards,
Chan