示例#1
0
    private void OnDisable()
    {
        MenuHold script = backHold.GetComponent <MenuHold>();

        Destroy(script);

        ClimbARHandhold.HoldLineRendererActive(backHold, false);
    }
示例#2
0
    void attachMenuHoldToHold(Dictionary <string, GameObject> menuItems)
    {
        foreach (string menuItem in menuItems.Keys)
        {
            GameObject menuHold = menuItems[menuItem];
            if (menuHold == null)
            {
                Debug.Log("No hold for menu item " + menuItem);
            }
            else
            {
                // Draw custom hold sprite for menu hold if present in Resources folder
                if (menuSprites[menuItem] != null)
                {
                    GameObject customSpriteObject = GameObject.Instantiate(customHoldSprite);
                    customSpriteObject.transform.SetParent(menuHold.transform);
                    customSpriteObject.transform.localPosition = new Vector3(0, 0, 0);

                    float radius = menuHold.GetComponent <CircleCollider2D>().radius;
                    ClimbARHandhold.DrawHoldSprite(customSpriteObject.GetComponent <SpriteRenderer>(), menuSprites[menuItem],
                                                   radius / camWidth, radius / camWidth);
                }
                // Draw line renderer otherwise
                else
                {
                    ClimbARHandhold.HoldLineRendererActive(menuHold, true);
                    ClimbARHandhold.setHoldColor(menuHold, UnityEngine.Color.cyan);
                }

                GameObject holdText       = new GameObject();
                HoldText   holdTextScript = holdText.AddComponent <HoldText>();
                holdTextScript.setup(menuItem, holdText, menuHold);

                MenuHold menuHoldScript = menuHold.AddComponent <MenuHold>();
                menuHoldScript.setup(menuItem);
            }
        }
    }
示例#3
0
    private void OnDisable()
    {
        foreach (GameObject hold in holds)
        {
            if (hold != null)
            {
                MenuHold mHoldScript = hold.GetComponent <MenuHold>();
                HoldText hTextScript = hold.GetComponent <HoldText>();

                // Hide the rendered sprite
                hold.GetComponent <SpriteRenderer>().enabled = false;
                ClimbARHandhold.DestroyChildren(hold);
                ClimbARHandhold.HoldLineRendererActive(hold, false);
                hold.transform.localScale = new Vector3(0.7f, 0.7f, 0.7f);

                // Reset line renderer to uniform color
                hold.GetComponent <LineRenderer>().startColor = UnityEngine.Color.cyan;
                hold.GetComponent <LineRenderer>().endColor   = UnityEngine.Color.cyan;

                Destroy(mHoldScript);
                Destroy(hTextScript);
            }
        }
    }