AtomControlle

PHOTO EMBED

Thu Nov 03 2022 10:21:38 GMT+0000 (Coordinated Universal Time)

Saved by @Shivaprasad_K_M

using System.Collections;
using System.Collections.Generic;
using UnityEditor.Experimental.GraphView;
using UnityEngine;
using UnityEngine.UIElements;

public class AtomController : MonoBehaviour
{
    // Start is called before the first frame update
    public GameObject atomPrefab;
    
    public int atomCount = 1;

    private void Update()
    {
        if (Input.GetMouseButtonDown(0))
           
        {
            StartCoroutine(PlaceAtom());
        }
    }
    private IEnumerator PlaceAtom()
    {
        Vector2 position = transform.position;
        position.x = Mathf.Round(position.x);
        position.y = Mathf.Round(position.y);

        GameObject atom = Instantiate(atomPrefab, position, Quaternion.identity);
        yield return atom;
    }


}
content_copyCOPY