Exemple #1
0
    // Start is called before the first frame update
    void Start()
    {
        if (!myHand)
        {
            Debug.LogError("RubiksFaceFinder: OVR Grabber hand was not found!");
        }
        if (!myCollider)
        {
            Debug.LogError("RubiksFaceFinder: My Collider was not found!");
        }

        var grabbables    = GameObject.FindGameObjectsWithTag("PuzzleCube");
        var rubiksPresent = false;

        foreach (GameObject go in grabbables)
        {
            rubiksScript = go.GetComponent <RotateRubiks>();
            if (rubiksScript != null)
            {
                rubiksPresent = true;
                break;
            }
        }
        if (!rubiksPresent || !rubiksScript.useNewPointingSystem)
        {
            gameObject.SetActive(false);
        }

        rubiksFaceColliders = new List <Collider>();
    }
    public RotateRubiks.Symbol GetActiveSymbol()
    {
        var symbol = RotateRubiks.Symbol.None;

        var results     = new Collider[10];
        var center      = transform.position;
        var halfExtents = myCollider.bounds.size / 4; // Delar på 4 istället för 2 för att kompensera att rubiks-kuben är skala 0.7
        int hits        = Physics.OverlapBoxNonAlloc(center, halfExtents, results, transform.rotation, LayerMask.GetMask("RubiksFace"));

        if (hits > 0)
        {
            symbol = RotateRubiks.GetSymbol(results[0].tag);
            // if (hits > 1)
            //     Debug.Log("Many hits! Second: "+RotateRubiks.GetSymbol(results[1].tag)+", collider size: "+myCollider.bounds.size);
        }
        return(symbol);
    }
    // Start is called before the first frame update
    void Start()
    {
        GameObject resetObjectVolume = GameObject.FindGameObjectWithTag("ResetStartingPoint");

        if (useResetStartingPoint && resetObjectVolume)
        {
            startingPosition = resetObjectVolume.transform.position;
            startingArea     = resetObjectVolume.GetComponent <BoxCollider>();
        }
        else
        {
            startingPosition = transform.position;
        }

        rb                     = GetComponent <Rigidbody>();
        myCollider             = GetComponent <Collider>();
        originalColliderBounds = myCollider.bounds.size;

        grabbableScript        = GetComponent <OVRGrabbable_EventExtension>();
        attachableTargetScript = GetComponent <AttachableTarget>();
        attachableScript       = GetComponent <Attachable>();

        rubiksScript = GetComponent <RotateRubiks>();

        if (renderers.Length > 0)
        {
            materials = new Material[renderers.Length];
            for (int i = 0; i < renderers.Length; i++)
            {
                materials[i] = renderers[i].material;
            }
        }
        else
        {
            materials    = new Material[1];
            materials[0] = GetComponentInChildren <Renderer>().material;
        }

        if (!rb)
        {
            Debug.LogError(gameObject.name + ": Rigidbody was not found!");
        }
        if (!materials[0])
        {
            Debug.LogError(gameObject.name + ": Material was not found!");
        }
        if (!myCollider)
        {
            Debug.LogError(gameObject.name + ": Collider was not found!");
        }
        if (!grabbableScript)
        {
            Debug.LogError(gameObject.name + ": Grabber script was not found!");
        }

        originalScale = transform.localScale;

        if (!resetSoundSource)
        {
            Debug.LogError(gameObject.name + ": Reset sound Audio Source was not found!");
        }
        startingPitch = resetSoundSource.pitch;
        if (!resetOutSound)
        {
            Debug.LogError(gameObject.name + ": Reset OUT sound Audio Clip was not found!");
        }
        if (!resetInSound)
        {
            Debug.LogError(gameObject.name + ": Reset IN sound Audio Clip was not found!");
        }
    }