Example #1
0
    // OnInspectorGUI exposes public Tracker settings in Inspector
    // WorldCenterMode: Defines how the relative transformation that is returned
    //                  by the QCAR Tracker is applied. Either the camera is
    //                  moved in the scene with respect to a "world center" or
    //                  all the targets are moved with respect to the camera.
    public override void OnInspectorGUI()
    {
        QCARBehaviour tb = (QCARBehaviour)target;

        DrawDefaultInspector();

        tb.SetWorldCenterMode((QCARBehaviour.WorldCenterMode)
                              EditorGUILayout.EnumPopup("World Center Mode",
                                                        tb.WorldCenterModeSetting));

// We assume Unity 3.2 as minimum requirement.
#if (UNITY_3_3 || UNITY_3_2)
        if (tb.WorldCenterModeSetting == QCARBehaviour.WorldCenterMode.USER)
        {
            tb.SetWorldCenter((TrackableBehaviour)
                              EditorGUILayout.ObjectField("World Center", tb.WorldCenter,
                                                          typeof(TrackableBehaviour)));
        }
#else
        bool allowSceneObjects = !EditorUtility.IsPersistent(target);
        if (tb.WorldCenterModeSetting == QCARBehaviour.WorldCenterMode.USER)
        {
            tb.SetWorldCenter((TrackableBehaviour)
                              EditorGUILayout.ObjectField("World Center", tb.WorldCenter,
                                                          typeof(TrackableBehaviour),
                                                          allowSceneObjects));
        }
#endif
    }
Example #2
0
    // OnInspectorGUI exposes public Tracker settings in Inspector
    // WorldCenterMode: Defines how the relative transformation that is returned
    //                  by the QCAR Tracker is applied. Either the camera is
    //                  moved in the scene with respect to a "world center" or
    //                  all the targets are moved with respect to the camera.
    public override void OnInspectorGUI()
    {
        EditorGUIUtility.LookLikeInspector();

        QCARBehaviour tb = (QCARBehaviour)target;

        DrawDefaultInspector();

        tb.SetWorldCenterMode((QCARBehaviour.WorldCenterMode)
                              EditorGUILayout.EnumPopup("World Center Mode",
                                                        tb.WorldCenterModeSetting));

        bool allowSceneObjects = !EditorUtility.IsPersistent(target);

        if (tb.WorldCenterModeSetting == QCARBehaviour.WorldCenterMode.USER)
        {
            tb.SetWorldCenter((TrackableBehaviour)
                              EditorGUILayout.ObjectField("World Center", tb.WorldCenter,
                                                          typeof(TrackableBehaviour),
                                                          allowSceneObjects));
        }

        if (GUI.changed)
        {
            // Let Unity know that there is new data for serialization.
            EditorUtility.SetDirty(tb);
        }
    }
Example #3
0
    // OnInspectorGUI exposes public Tracker settings in Inspector
    // WorldCenterMode: Defines how the relative transformation that is returned
    //                  by the QCAR Tracker is applied. Either the camera is
    //                  moved in the scene with respect to a "world center" or
    //                  all the targets are moved with respect to the camera.
    public override void OnInspectorGUI()
    {
        EditorGUIUtility.LookLikeInspector();

        QCARBehaviour tb = (QCARBehaviour)target;

        DrawDefaultInspector();

        tb.SetWorldCenterMode((QCARBehaviour.WorldCenterMode)
                              EditorGUILayout.EnumPopup("World Center Mode",
                                                        tb.WorldCenterModeSetting));

        bool allowSceneObjects = !EditorUtility.IsPersistent(target);

        if (tb.WorldCenterModeSetting == QCARBehaviour.WorldCenterMode.SPECIFIC_TARGET)
        {
            var trackable = (TrackableBehaviour)
                            EditorGUILayout.ObjectField("World Center", tb.WorldCenter,
                                                        typeof(TrackableBehaviour),
                                                        allowSceneObjects);


            // Word Behaviours cannot be selected as world center
            if (trackable is WordBehaviour)
            {
                trackable = null;
                EditorWindow.focusedWindow.ShowNotification(
                    new GUIContent("Word behaviours cannot be selected as world center."));
            }

            tb.SetWorldCenter(trackable);
        }

        if (GUI.changed)
        {
            // Let Unity know that there is new data for serialization.
            EditorUtility.SetDirty(tb);
        }
    }