Esempio n. 1
0
    private static void AddVirtualButton(ImageTargetBehaviour it,
                                         ConfigData.VirtualButtonData vb)
    {
        IEditorVirtualButtonBehaviour newVBBehaviour =
            it.CreateVirtualButton(vb.name, new Vector2(0.0f, 0.0f),
                                   new Vector2(1.0f, 1.0f));

        if (newVBBehaviour != null)
        {
            newVBBehaviour.SetPosAndScaleFromButtonArea(
                new Vector2(vb.rectangle[0], vb.rectangle[1]),
                new Vector2(vb.rectangle[2], vb.rectangle[3]));

            VirtualButtonEditor.CreateVBMesh(newVBBehaviour);

            // Load default material.
            VirtualButtonEditor.CreateMaterial(newVBBehaviour);

            newVBBehaviour.enabled = vb.enabled;

            // Add Component to destroy VirtualButton meshes at runtime.
            newVBBehaviour.gameObject.AddComponent <TurnOffBehaviour>();

            // Make sure Virtual Button is correctly aligned with Image Target
            newVBBehaviour.UpdatePose();
        }
        else
        {
            Debug.LogError("VirtualButton could not be added!");
        }
    }
    private static void AddVirtualButton(ImageTargetAbstractBehaviour it, ConfigData.VirtualButtonData vb)
    {
        IEditorVirtualButtonBehaviour behaviour = it.CreateVirtualButton(vb.name, new Vector2(0f, 0f), new Vector2(1f, 1f));

        if (behaviour != null)
        {
            behaviour.SetPosAndScaleFromButtonArea(new Vector2(vb.rectangle[0], vb.rectangle[1]), new Vector2(vb.rectangle[2], vb.rectangle[3]));
            VirtualButtonEditor.CreateVBMesh(behaviour);
            VirtualButtonEditor.CreateMaterial(behaviour);
            behaviour.enabled = vb.enabled;
            BehaviourComponentFactory.Instance.AddTurnOffBehaviour(behaviour.gameObject);
            behaviour.UpdatePose();
        }
        else
        {
            Debug.LogError("VirtualButton could not be added!");
        }
    }