public void OnEnable()
    {
        ImageTargetAbstractBehaviour target = (ImageTargetAbstractBehaviour)base.target;

        if (QCARUtilities.GetPrefabType(target) != PrefabType.Prefab)
        {
            if (!SceneManager.Instance.SceneInitialized)
            {
                SceneManager.Instance.InitScene();
            }
            IEditorImageTargetBehaviour it = target;
            if (!it.InitializedInEditor && !EditorApplication.isPlaying)
            {
                ConfigData.ImageTargetData data;
                ConfigDataManager.Instance.GetConfigData("--- EMPTY ---").GetImageTarget("--- EMPTY ---", out data);
                UpdateAspectRatio(target, data.size);
                UpdateScale(target, data.size);
                UpdateMaterial(target);
                it.SetDataSetPath("--- EMPTY ---");
                it.SetNameForTrackable("--- EMPTY ---");
                it.SetInitializedInEditor(true);
            }
            else if (!EditorApplication.isPlaying)
            {
                CheckMesh(it);
            }
            it.SetPreviousScale(target.transform.localScale);
        }
    }
Exemplo n.º 2
0
    // Initializes the Image Target when it is drag-dropped into the scene.
    public void OnEnable()
    {
        ImageTargetBehaviour itb = (ImageTargetBehaviour)target;

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

        // Make sure the scene and config.xml file are synchronized.
        if (!SceneManager.Instance.SceneInitialized)
        {
            SceneManager.Instance.InitScene();
        }

        IEditorImageTargetBehaviour editorItb = itb;

        // Only setup target if it has not been set up previously.
        if (!editorItb.InitializedInEditor && !EditorApplication.isPlaying)
        {
            ConfigData.ImageTargetData itConfig;

            ConfigData dataSetData = ConfigDataManager.Instance.GetConfigData(QCARUtilities.GlobalVars.DEFAULT_DATA_SET_NAME);
            dataSetData.GetImageTarget(QCARUtilities.GlobalVars.DEFAULT_TRACKABLE_NAME, out itConfig);

            UpdateAspectRatio(itb, itConfig.size);
            UpdateScale(itb, itConfig.size);
            UpdateMaterial(itb);
            editorItb.SetDataSetPath(QCARUtilities.GlobalVars.DEFAULT_DATA_SET_NAME);
            editorItb.SetNameForTrackable(QCARUtilities.GlobalVars.DEFAULT_TRACKABLE_NAME);
            editorItb.SetInitializedInEditor(true);
        }
        else if (!EditorApplication.isPlaying)
        {
            CheckMesh(editorItb);
        }

        // Cache the current scale of the target:
        editorItb.SetPreviousScale(itb.transform.localScale);
    }