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!");
        }
    }
Exemple #2
0
        private static void AddVirtualButton(ImageTargetAbstractBehaviour it, ConfigData.VirtualButtonData vb)
        {
            VirtualButtonAbstractBehaviour virtualButtonAbstractBehaviour = it.CreateVirtualButton(vb.name, new Vector2(0f, 0f), new Vector2(1f, 1f));

            if (virtualButtonAbstractBehaviour != null)
            {
                SerializedObject serializedObject = new SerializedObject(virtualButtonAbstractBehaviour);
                using (serializedObject.Edit())
                {
                    VirtualButtonEditor.GetSensitivityProperty(serializedObject).enumValueIndex = (int)vb.sensitivity;
                }
                virtualButtonAbstractBehaviour.SetPosAndScaleFromButtonArea(new Vector2(vb.rectangle[0], vb.rectangle[1]), new Vector2(vb.rectangle[2], vb.rectangle[3]));
                VirtualButtonEditor.CreateVBMesh(virtualButtonAbstractBehaviour.gameObject);
                VirtualButtonEditor.CreateMaterial(virtualButtonAbstractBehaviour.gameObject);
                virtualButtonAbstractBehaviour.enabled = vb.enabled;
                BehaviourComponentFactory.Instance.AddTurnOffBehaviour(virtualButtonAbstractBehaviour.gameObject);
                virtualButtonAbstractBehaviour.UpdatePose();
                return;
            }
            Debug.LogError("VirtualButton could not be added!");
        }