When I Click A Button Other Button Function Is Working.why?

I am trying to click one button(load) but the button(delete) next to it is working .Why is that?I looked at the bounds but looks perfect.It is not colliding with Load button.Any idea.

DangerousTemptingAngelwingmussel

public void ListMap()
    {
        Listobject.Clear();
       

        panellist.SetActive(true);
        string mainpath = Application.persistentDataPath;
        DirectoryInfo dir = new DirectoryInfo(mainpath);

        infos = dir.GetFileSystemInfos("*.json").OrderBy(i => i.CreationTime).ToArray();
    
      
        for(int i = 1;i<=infos.Length;i++)
        {
           
            //orderedFiles[i-1] = infos[i-1];
            if (Parentcontent.childCount > 0)
            {
                GameObject gg = Parentcontent.GetChild(i - 1).gameObject;
                Destroy(gg);
                Debug.Log("Name is = " + gg.name);



            }

            lisobj = Instantiate(prefabpanellist);
            Listobject.Add(lisobj);



        }

      

        for (int i = 0; i < infos.Length; i++)
        {



            Listobject[i].transform.SetParent(Parentcontent);
            var index = i;
           // var button = Listobject[i].GetComponentInChildren<Button>(true);
            var button = Listobject[i].transform.GetChild(3).GetComponent<Button>();
            var Loadbutton=Listobject[i].transform.GetChild(2).GetComponent<Button>();

            button.onClick.AddListener(() => Deleteinformation(index));
         

            var numText = Listobject[i].transform.GetChild(0).GetComponent<Text>();
            numText.text = (i+1).ToString();
           // Debug.Log("Numtxt =  " +numText.text);

            var filenameText = Listobject[i].transform.GetChild(1).GetComponent<Text>();
            filenameText.text = infos[i].Name;
            string Filename = filenameText.text;
            Loadbutton.onClick.AddListener(() => Load(Filename));
          //Debug.Log("filenameText =  " + filenameText.text);
           // mapnamedb.text = infos[i].Name;
        }

      

     
    }

    public void Deleteinformation(int index)
    {
        Debug.Log("Index is " + index);

      //  Debug.Log("Path is " + infos[index].FullName);
      
     
      
     
        File.Delete(infos[index].FullName);




       // Listobject.RemoveAt(index);
       Destroy(Listobject[index]);


        BackMap();
      
      
    }

public void Load(string flname)
    {

        Debug.Log("FileName is first === " + flname);

        //May be used to check In UnityARHitTestExample whether Load button is pressed
        Clickloaded = 1;

        GameObject gg=null;

        for (int i = 0; i < UnityARHitTestExample.HittestInstance.ContainerObject.Count; i++)
        {
            Destroy(UnityARHitTestExample.HittestInstance.ContainerObject[i]);
        }

        if(UnityARHitTestExample.HittestInstance.ContainerObject != null)
        {

            UnityARHitTestExample.HittestInstance.ContainerObject.Clear();
        }


        //Loading file from persistent path
        if (File.Exists(Application.persistentDataPath + "/"+flname))
        {


            Debug.Log("FileName is === " + flname);
            panellist.SetActive(false);
            string jsonLoadstring;
            using (FileStream fs = new FileStream(Application.persistentDataPath + "/" + flname, FileMode.Open))
            {

                BinaryReader filereader = new BinaryReader(fs);
                jsonLoadstring = filereader.ReadString();
                fs.Close();
              //  Debug.Log("JsonLoaded String==" + jsonLoadstring);
            }

           
              
            }


        }
        else
        {
            Debug.Log("No file Exists in that path");

        }



      
        Debug.LogFormat("Loading ARWorldMap {0}", path);
        var worldMap = ARWorldMap.Load(path);
        if (worldMap != null)
        {
            m_LoadedMap = worldMap;
            Debug.LogFormat("Map loaded. Center: {0} Extent: {1}", worldMap.center, worldMap.extent);

            UnityARSessionNativeInterface.ARSessionShouldAttemptRelocalization = true;

            var config = m_ARCameraManager.sessionConfiguration;
            config.worldMap = worldMap;
           UnityARSessionRunOption runOption = UnityARSessionRunOption.ARSessionRunOptionRemoveExistingAnchors | UnityARSessionRunOption.ARSessionRunOptionResetTracking;

            Debug.Log("Restarting session with worldMap");
           session.RunWithConfigAndOptions(config, runOption);

        }


    }

Make sure the text object on the delete button isn’t actually covering the load button.
Make sure your load buttons image target isn’t the delete button instead.
If you move the buttons further apart, see if they work. Or turn off the delete button and see if it works.

1 Like

Make sure the text object on the delete button isn’t actually covering the load button…This was the problem… Ty …:slight_smile:

No problem! Glad it’s fixed for you. Those child objects sometimes get overlooked.