コード例 #1
0
    public override void OnInspectorGUI()
    {
        EditorGUIUtility.LookLikeInspector();
        base.DrawDefaultInspector();
        WordAbstractBehaviour target     = (WordAbstractBehaviour)base.target;
        IEditorWordBehaviour  behaviour2 = target;

        if (QCARUtilities.GetPrefabType(target) == PrefabType.Prefab)
        {
            GUILayout.Label("You can't choose a target for a prefab.", new GUILayoutOption[0]);
        }
        else if (EditorGUILayout.Toggle("Template", behaviour2.IsTemplateMode, new GUILayoutOption[0]))
        {
            behaviour2.SetMode(WordTemplateMode.Template);
        }
        else
        {
            behaviour2.SetMode(WordTemplateMode.SpecificWord);
            string word = EditorGUILayout.TextField("Specific Word", behaviour2.SpecificWord, new GUILayoutOption[0]);
            if (word != behaviour2.SpecificWord)
            {
                if (word.Length == 0)
                {
                    Debug.LogWarning("Empty string used as word: This trackable and its augmentation will never be selected at runtime.");
                }
                behaviour2.SetSpecificWord(word);
            }
        }
        if (GUI.changed)
        {
            UpdateMesh(target);
            EditorUtility.SetDirty(target);
            SceneManager.Instance.SceneUpdated();
        }
    }
コード例 #2
0
    /// <summary>
    /// Initializes the Word-Behaviour when it is drag-dropped into the scene
    /// </summary>
    public void OnEnable()
    {
        var behaviour = (WordBehaviour)target;

        // We don't want to initialize if this is a prefab.
        if (QCARUtilities.GetPrefabType(behaviour) == PrefabType.Prefab)
        {
            return;
        }

        // Initialize scene manager
        if (!SceneManager.Instance.SceneInitialized)
        {
            SceneManager.Instance.InitScene();
        }

        IEditorWordBehaviour editorBehaviour = behaviour;

        if (!editorBehaviour.InitializedInEditor && !EditorApplication.isPlaying)
        {
            //default values
            editorBehaviour.SetMode(WordTemplateMode.Template);
            editorBehaviour.SetSpecificWord("Word");

            //define appearance
            UpdateMesh(behaviour);

            editorBehaviour.SetInitializedInEditor(true);

            // Inform Unity that the behaviour properties have changed.
            EditorUtility.SetDirty(behaviour);
        }
    }
コード例 #3
0
    public override void OnInspectorGUI()
    {
        EditorGUIUtility.LookLikeInspector();

        DrawDefaultInspector();

        var behaviour = (WordBehaviour)target;
        IEditorWordBehaviour editorBehaviour = behaviour;

        if (QCARUtilities.GetPrefabType(behaviour) == PrefabType.Prefab)
        {
            GUILayout.Label("You can't choose a target for a prefab.");
        }
        else
        {
            var templateMode = EditorGUILayout.Toggle("Template", editorBehaviour.IsTemplateMode);
            if (templateMode)
            {
                editorBehaviour.SetMode(WordTemplateMode.Template);
            }
            else
            {
                editorBehaviour.SetMode(WordTemplateMode.SpecificWord);

                var newWord = EditorGUILayout.TextField("Specific Word", editorBehaviour.SpecificWord);
                if (newWord != editorBehaviour.SpecificWord)
                {
                    if (newWord.Length == 0)
                    {
                        Debug.LogWarning("Empty string used as word: This trackable and its augmentation will never be selected at runtime.");
                    }
                    editorBehaviour.SetSpecificWord(newWord);
                }
            }
        }

        if (GUI.changed)
        {
            UpdateMesh(behaviour);
            EditorUtility.SetDirty(behaviour);
            SceneManager.Instance.SceneUpdated();
        }
    }
コード例 #4
0
    public void OnEnable()
    {
        WordAbstractBehaviour target = (WordAbstractBehaviour)base.target;

        if (QCARUtilities.GetPrefabType(target) != PrefabType.Prefab)
        {
            if (!SceneManager.Instance.SceneInitialized)
            {
                SceneManager.Instance.InitScene();
            }
            IEditorWordBehaviour behaviour2 = target;
            if (!behaviour2.InitializedInEditor && !EditorApplication.isPlaying)
            {
                behaviour2.SetMode(WordTemplateMode.Template);
                behaviour2.SetSpecificWord("Word");
                UpdateMesh(target);
                behaviour2.SetInitializedInEditor(true);
                EditorUtility.SetDirty(target);
            }
        }
    }