// Use this for initialization void Start() { instance = this; float horizontalSpacing = Mathf.Abs((bottomLeft.x - topRight.x) / (columns - 1)); float verticalSpacing = Mathf.Abs((bottomLeft.y - topRight.y) / (rows - 1)); for (int i = 0; i < rows; ++i) { for (int j = 0; j < columns; ++j) { GameObject go = Instantiate(connectionPrefab, bottomLeft + Vector3.right * j * horizontalSpacing + Vector3.up * i * verticalSpacing, Quaternion.identity); go.name = "Connection " + i + " " + j; go.transform.SetParent(transform); } } }
private void Awake() { spriteRenderer = GetComponent <SpriteRenderer>(); if (connectionType == ConnectionType.INPUT) { spriteRenderer.color = Color.white; } else { spriteRenderer.color = Color.grey; } connectionSpawner = FindObjectOfType <ConnectionSpawner>(); logicGate = GetComponentInParent <IGate>(); }