private void UpdatePlaceholder(Grid3D grid, Vector3Int tileLocation) { // Update the placeholder if the object is changed if (PlaceholderName != CurrentObject && PlaceholderObject != null) { Destroy(PlaceholderObject.gameObject); } // Create a new placeholder object if it's null if (PlaceholderObject == null && CurrentObject != "") { PlaceholderName = CurrentObject; PlaceholderData = Grid3D.GetObjectData(CurrentObject).Value; // Generate a copy of the object PlaceholderObject = Instantiate(Grid3D.GetObjectData(CurrentObject).Key); PlaceholderObject.rotation = Quaternion.AngleAxis((int)PlaceholderDirection * 90, Vector3.up); PlaceholderObject.name = CurrentObject + " (Placeholder)"; PlaceholderObject.parent = transform; // Make transparent UpdateAllMaterials(PlaceholderObject.gameObject, PlaceholderMaterial); CullUnnecessaryComponents(PlaceholderObject.gameObject); } bool isValid = grid.IsObjectValid(PlaceholderData, tileLocation, PlaceholderDirection); Color col = isValid ? Color.green : Color.red; PlaceholderMaterial.color = new Color(col.r, col.g, col.b, 0.5f); // Update location Vector3 worldLocation = new Vector3(); grid.TileToWorld(tileLocation, out worldLocation); PlaceholderObject.transform.position = worldLocation; // Update visual PlaceholderObject.gameObject.SetActive(true); }