Topic: click and change, color,size,turn off part of the 3d marker

Hello thanks for everything for the previous help, but now I would like to understand how to change the markers 3D during execution, let me explain: I created a marker that contains streets and buildings and is positioned on the map, I have to interact with these elements such as change color to the roads to highlight them when you click on them, or light up other paths present in the same marker or another example simply light up a certain marker in red when clicked

with my code I can change the color of my prefab present in the scene but the clone object under 3d marker does not change and therefore not even on the map! how can i modify it via code, do i need to recover the clone components? can you give me an example, please


I wish I could change colors, materials, transformations,turn off and on parts of the 3d Marker

Thank you very mutch




for example, here I put the code I use to change the color of the 3d Marker when it is clicked

[SerializeField] Material[] material;
    [SerializeField] Renderer rend1;

    void Start()
    {


        rend1 = GameObject.Find("Pin1").GetComponent<Renderer>();
        rend1.enabled = true;
        rend1.sharedMaterial = material[0];



void Update()
    {

     
        if(Input.touchCount>0 && Input.touches[0].phase==TouchPhase.Began)

        {
            Ray ray2 = Camera.main.ScreenPointToRay(Input.touches[0].position);

            RaycastHit hit2;

            if(Physics.Raycast(ray2,out hit2))

            {
                if (hit2.collider.gameObject.tag == "contenuto1")

                {
                   
                    rend1.sharedMaterial = material[1];
   
                    Debug.Log("contenut1");
                }

Re: click and change, color,size,turn off part of the 3d marker

Hello.

The easiest way is to add MonoBehaviour to the prefab, and use OnMouseUpAsButton.
This way you will be able to modify the marker as if it were a simple GameObject.
https://docs.unity3d.com/ScriptReferenc … utton.html

Or you can use marker events, get an instance, and perform the action you want.
https://infinity-code.com/doxygen/onlin … 20bb0744f5
https://infinity-code.com/doxygen/onlin … 293778120b

Trying to discuss your code is pretty useless because it depends a lot on the context how and where you use it.
But I would recommend not to use GameObject.Find because it is slow and can give you a lot of problems if used incorrectly.

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.