问题描述
我正在将Vuforia和unity用于我的AR应用程序.其中有2个以上的模型/图像目标.为了放大和缩小,我使用了Lean Touch.但是问题是,两者都将在捏捏上变得越来越大.我只想放大当前检测到的一个.我想在DefaultTrackableEventHandler的OnTrackingLost()函数上重置3D模型的3D模型的比例组件,以便当它检测到另一幅时以原始比例显示(因为我将检测到的最大模拟图像设置为一个).谢谢!
I'm using Vuforia and unity for my AR App. which has more than 2 models/image targets. To zoom in and out I used Lean Touch.But the problem is both will get zoom on pinching .I want only one to zoom which is currently detected.. ORI want reset Scale component of my 3D model/models on OnTrackingLost() function in DefaultTrackableEventHandler so that when it detects other one it shows on original scale (as i set max sim images detected to one).Thanks !
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class rscale : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (Input.GetKey (KeyCode.V)) {
transform.localScale = new Vector3 (4f, 4f, 4f);
Debug.Log("scaling to 4");
}
}
}
这个简单的脚本也不起作用吗?
BUT THIS SIMPLE SCRIPT IS ALSO NOT WORKING ?
推荐答案
这里的问题是Vuforia不会停用连接到图像目标的3D对象,它只会停用他的渲染器组件和对撞机,因此您不能放置一个过滤器,要求游戏对象的活动状态为@Everts sugest.
The trouble here is that Vuforia doesn't deactivate the 3D object attached to the image target, it only deactivates his renderer component and the colliders so you can't put a filter asking for the active state of the game object as @Everts sugest.
相反,您可以拥有一个脚本,在该脚本中可以同时公开引用两个3D游戏对象,并可以将两个对象的比例设置为一个方法,每当丢失图像目标时,都应调用该函数和两个游戏对象将他的比例尺设置为一.
Instead you can have an script where you have a public reference to both 3D game objects and a method where you set the scale of both objects to one, every time you lost your image target you should call that function and both game objects will be his scale set to one.
另一个解决方案是,Vuforia知道找到了标记,因此当您检测到标记时,可以激活将游戏对象设置为遭受缩放效果的对象.
Another solutios is, Vuforia knows wich marker found so when you detect a marker you can activate set that game object to be the one to suffer the scale efects.
这篇关于在unity和vuforia中重置图像目标中模型的缩放比例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!