public void OnEnable() { MultiTargetAbstractBehaviour target = (MultiTargetAbstractBehaviour)base.target; if (QCARUtilities.GetPrefabType(target) != PrefabType.Prefab) { if (!SceneManager.Instance.SceneInitialized) { SceneManager.Instance.InitScene(); } IEditorMultiTargetBehaviour mt = target; if (!mt.InitializedInEditor && !EditorApplication.isPlaying) { ConfigData.MultiTargetData data; ConfigDataManager.Instance.GetConfigData("--- EMPTY ---").GetMultiTarget("--- EMPTY ---", out data); mt.SetDataSetPath("--- EMPTY ---"); mt.SetNameForTrackable("--- EMPTY ---"); UpdateParts(mt, data.parts.ToArray()); mt.SetInitializedInEditor(true); } else if (!EditorApplication.isPlaying) { CheckMesh(target); } mt.SetPreviousScale(target.transform.localScale); } }
// Initializes the Multi Target when it is drag-dropped into the scene. public void OnEnable() { MultiTargetBehaviour mtb = (MultiTargetBehaviour)target; // We don't want to initialize if this is a prefab. if (QCARUtilities.GetPrefabType(mtb) == PrefabType.Prefab) { return; } // Make sure the scene and config.xml file are synchronized. if (!SceneManager.Instance.SceneInitialized) { SceneManager.Instance.InitScene(); } IEditorMultiTargetBehaviour editorMtb = mtb; // Only setup target if it has not been set up previously. if (!editorMtb.InitializedInEditor && !EditorApplication.isPlaying) { ConfigData.MultiTargetData mtConfig; ConfigData dataSetData = ConfigDataManager.Instance.GetConfigData(QCARUtilities.GlobalVars.DEFAULT_DATA_SET_NAME); dataSetData.GetMultiTarget(QCARUtilities.GlobalVars.DEFAULT_TRACKABLE_NAME, out mtConfig); editorMtb.SetDataSetPath(QCARUtilities.GlobalVars.DEFAULT_DATA_SET_NAME); editorMtb.SetNameForTrackable(QCARUtilities.GlobalVars.DEFAULT_TRACKABLE_NAME); List <ConfigData.MultiTargetPartData> prtConfigs = mtConfig.parts; UpdateParts(editorMtb, prtConfigs.ToArray()); editorMtb.SetInitializedInEditor(true); } else if (!EditorApplication.isPlaying) { CheckMesh(mtb); } // Cache the current scale of the target: editorMtb.SetPreviousScale(mtb.transform.localScale); }