Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
Hylasss's avatar
Hylasss
Honored Guest
2 years ago

Array of Anchor Prefabs not working.

Im working on a simple script that deactivates and reactivates certain gameobjects spawned with the Anchor Prefab Spawner. I put tags on the prefabs and am referencing them through that and placing them in an array. bellow is my code. 

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PTToggle : MonoBehaviour
{
    public GameObject[] ptWalls;

    // Start is called before the first frame update

    void Start()
    {
        ptWalls = GameObject.FindGameObjectsWithTag("pt remove");   
    }

    // Update is called once per frame

    void Update()
    {
        for (int i = 0; i < ptWalls.Length; i++)
        {
            if (OVRInput.Get(OVRInput.RawButton.RIndexTrigger))
            {
                ptWalls[i].SetActive(false);
            }

            if (OVRInput.Get(OVRInput.RawButton.LIndexTrigger))
            {
                ptWalls[i].SetActive(true);
            }
        }
    }

This script works fine when running on desktop but when I deploy to Quest 3 it wont. Whats really confusing me is if I move the 

ptWalls = GameObject.FindGameObjectsWithTag("pt remove");   

into the update function Im able to deactivate the objects but not reactivate them. This leads me to believe the controller input is being recognized and this has something to do with how the array is being made at the start. 

Any insight would be super helpful so thanks in advance! 

1 Reply

Replies have been turned off for this discussion
  • MetaStoreHelp's avatar
    MetaStoreHelp
    Community Manager

    Hi there!

    Thanks for reaching out on the Meta Developer Forum.

    We have a great Developer Support Center that might provide some insight if you find yourself running into roadblocks!

     

    Check out the troubleshooting article we have on Shared Spatial Anchors, it might help at least point you in the right direction.

    We hope you manage to crack the problem, all the best from us on the Support team!!