public void PlayAudio(VirtualButtonBehaviour vb, bool isPlay)
 {
     if (!isPlay)
     {
         vb.GetComponent <AudioSource>().Play();
         isRotate = true;
     }
     else
     {
         vb.GetComponent <AudioSource>().Stop();
         isRotate = false;
     }
 }
 public override void OnButtonReleased(VirtualButtonBehaviour vb)
 {
     base.OnButtonReleased(vb);
     var ar = vb.GetComponent<CC_VirtualButtonEvent>();
     if (ar)
         ar.OnButtonReleased(vb);
 }
Exemplo n.º 3
0
    void Start()
    {
        VirtualButtonBehaviour vbb = vb.GetComponent <VirtualButtonBehaviour>();

        if (vbb)
        {
            vbb.RegisterEventHandler(this);
        }
    }
    /// <summary>
    /// Called when the virtual button has just been pressed:
    /// </summary>
    public void OnButtonPressed(VirtualButtonBehaviour vb)
    {
        Debug.Log("OnButtonPressed: " + vb.VirtualButtonName);
        IActionIcon actionIcon = vb.GetComponent <IActionIcon>();

        if (actionIcon != null)
        {
            actionIcon.ExecuteAction();
        }
    }
	public override void OnButtonPressed(VirtualButtonBehaviour vb)
	{
        if (delayQuit == true) return;

        delayQuit = true;
        //StartCoroutine(DelayPressed());
        base.OnButtonPressed(vb);
        var ar = vb.GetComponent<CC_VirtualButtonEvent>();
        if (ar)
            ar.OnButtonPressed(vb);
    }
Exemplo n.º 6
0
    /// <summary>
    /// Create or destroy the virtual button with the given name.
    /// </summary>
    public void ToggleVirtualButton(string name)
    {
        if (mImageTargetWood.ImageTarget != null)
        {
            // Get the virtual button if it exists.
            VirtualButton vb = mImageTargetWood.ImageTarget.GetVirtualButtonByName(name);

            if (vb != null)
            {
                // Destroy the virtual button if it exists.
                mImageTargetWood.DestroyVirtualButton(name);
            }
            else
            {
                // Get the position and scale originally used for this virtual button.
                Vector3 position, scale;
                if (mVBPositionDict.TryGetValue(name, out position) &&
                    mVBScaleDict.TryGetValue(name, out scale))
                {
                    // Deactivate the dataset before creating the virtual button.
                    ObjectTracker objectTracker = TrackerManager.Instance.GetTracker <ObjectTracker>();
                    DataSet       dataSet       = objectTracker.GetActiveDataSets().First();
                    objectTracker.DeactivateDataSet(dataSet);

                    // Create the virtual button.
                    VirtualButtonBehaviour vbb = mImageTargetWood.CreateVirtualButton(
                        name,
                        new Vector2(position.x, position.z),
                        new Vector2(scale.x, scale.z)) as VirtualButtonBehaviour;

                    if (vbb != null)
                    {
                        // Register the button with the event handler on the Wood target.
                        vbb.RegisterEventHandler(mImageTargetWood.GetComponent <VirtualButtonEventHandler>());

                        // Add a mesh to outline the button.
                        CreateVBMesh(vbb);

                        // If the Wood target isn't currently tracked hide the button.
                        if (mImageTargetWood.CurrentStatus == TrackableBehaviour.Status.NOT_FOUND)
                        {
                            vbb.GetComponent <Renderer>().enabled = false;
                        }
                    }

                    // Reactivate the dataset.
                    objectTracker.ActivateDataSet(dataSet);
                }
            }
        }

        base.CloseMenu();
    }
Exemplo n.º 7
0
    private void Start()
    {
        leftbtn  = false;
        rightbtn = false;
        zinbtn   = false;
        zoutbtn  = false;
        left.GetComponent <VirtualButtonBehaviour>().RegisterEventHandler(this);

        right.GetComponent <VirtualButtonBehaviour>().RegisterEventHandler(this);

        zin.GetComponent <VirtualButtonBehaviour>().RegisterEventHandler(this);

        zout.GetComponent <VirtualButtonBehaviour>().RegisterEventHandler(this);
        sound.GetComponent <VirtualButtonBehaviour>().RegisterEventHandler(this);
        soundon.SetActive(false);
    }
Exemplo n.º 8
0
    // Assign default material to Virtual Button.
    public static void CreateMaterial(VirtualButtonBehaviour vb)
    {
        // Load reference material
        string referenceMaterialPath =
            QCARUtilities.GlobalVars.VIRTUAL_BUTTON_MATERIAL_PATH;
        Material referenceMaterial =
            (Material)AssetDatabase.LoadAssetAtPath(referenceMaterialPath,
                                                    typeof(Material));

        if (referenceMaterial == null)
        {
            Debug.LogError("Could not find reference material at " +
                           referenceMaterialPath +
                           " please reimport Unity package.");
            return;
        }

        // If the texture is null we simply assign a default material
        vb.GetComponent <Renderer>().sharedMaterial = referenceMaterial;

        // Cleanup assets that have been created temporarily.
        EditorUtility.UnloadUnusedAssets();
    }
Exemplo n.º 9
0
 // Use this for initialization
 void Start()
 {
     bh.GetComponent <VirtualButtonBehaviour>();
 }