Hi very new to coding with C# and have a little experience with unity. Question is basically what the title says.
Script 1 (Logic Manager):
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class LogicManager : MonoBehaviour
{
public Sprite[] ballSpritesArray;
public float[] ballScalesArray;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}
Script 2 (Ball Selection):
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BallSelection : MonoBehaviour
{
public int ballNumber = 0;
public Transform transformer;
public SpriteRenderer spriteRenderer;
public CircleCollider2D circleCollider;
private Vector3 ballScale = Vector3.one;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown("b"))
{
ballNumber = Random.Range(0, 10);
ballSelect(ballNumber);
}
}
public void ballSelect(int ballID)
{
spriteRenderer.sprite = ballSpritesArray[ballID];
ballScale = new Vector3(ballScalesArray[ballID], ballScalesArray[ballID]);
transform.localScale = ballScale;
}
}
I’m not sure how to have lines 33 and 34 in script 2, reference the arrays created in script 1.
Any help would be greatly appreciated and if an explaination could be provided as well that would be even better as I would prefer to understand it rather than just have it work. Also sorry if theres a lot of irelivant code I wasn’t too sure if other parts would be nessasary or not.