<pre><pre>using System.Collections; using System.Collections.Generic; using UnityEngine; [RequireComponent(typeof(Block))] public class pathFinder : MonoBehaviour { Block block; [SerializeField] Block startPoint, endPoint; Dictionary<Vector2Int, Block> pathMap = new Dictionary<Vector2Int, Block>(); // Start is called before the first frame update void Start() { var block = FindObjectsOfType<Block>(); LoadBlocks(); } void LoadBlocks() { Vector2Int poS = block.GetGridPos(); foreach (Block point in block) { /* Overlapping block should be skipped while other should be added to dictionary*/ if (pathMap.ContainsKey(poS)) { Debug.Log("Overlapping Object: " + point); } else { pathMap.Add(poS, block); } } } void StartEndPointColor() { startPoint.SetTopColor(Color.black); } }
foreach
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)