将鼠标悬停在颜色选择器和移动对象上
我有一个颜色选择器,仅当我单击另一个 gui 纹理按钮时才会出现。我还有一个对象,其后面有一个旋转脚本。当我使用颜色选择器时,如何告诉对象不旋转?
这是轮换脚本。
function LateUpdate () {
if (isCameraInputIgnored() ) {
return;
}
if (target && Input.GetMouseButton(0)) {
x += Input.GetAxis("Mouse X") * xSpeed * 0.02;
y -= Input.GetAxis("Mouse Y") * ySpeed * 0.02;
y = ClampAngle(y, yMinLimit, yMaxLimit);
var rotation = Quaternion.Euler(y, x, 0);
var position = rotation * Vector3(0.0, 10.0, -distance) + target.position;
transform.rotation = rotation;
transform.position = position;
}
}
如果鼠标位于 2 个始终存在的图形纹理上,则此函数返回 true。
function isCameraInputIgnored () : boolean {
var mousePos : Vector3 = Input.mousePosition;
// invert the y-coordinate
mousePos.y = Screen.height - mousePos.y;
if ( tilesBlock.Contains(mousePos) || wallBlock.Contains(mousePos))
return true;
return false; //if mouse isn't over gui's
}
Declaration :
private var tilesBlock : Rect = Rect(0,0,570,182) ; //tiles rectangle
private var wallBlock : Rect = Rect(670,0,590,172) ; //walls rectangle
在 LateUpdate 函数中,我使用此代码不旋转我的对象:
if (isCameraInputIgnored() ) {
return;
}
我的问题是,按下第二个 gui 纹理按钮之一后,会出现一个颜色选择器,其声明类似于 GuiLayout.BeginArea(Rect) ,当我拖动鼠标通过时颜色 我的房子在移动的同时也在改变颜色。我希望在使用颜色选择器时修复我的房子。
I have a color picker that appears only when i click on another gui texture button. also i have an object that has a rotating script behind it. how can i tell the object to not rotate when i am using the color picker ?
This is the rotating script.
function LateUpdate () {
if (isCameraInputIgnored() ) {
return;
}
if (target && Input.GetMouseButton(0)) {
x += Input.GetAxis("Mouse X") * xSpeed * 0.02;
y -= Input.GetAxis("Mouse Y") * ySpeed * 0.02;
y = ClampAngle(y, yMinLimit, yMaxLimit);
var rotation = Quaternion.Euler(y, x, 0);
var position = rotation * Vector3(0.0, 10.0, -distance) + target.position;
transform.rotation = rotation;
transform.position = position;
}
}
This function returns true if the mouse is over the 2 always present guitextures.
function isCameraInputIgnored () : boolean {
var mousePos : Vector3 = Input.mousePosition;
// invert the y-coordinate
mousePos.y = Screen.height - mousePos.y;
if ( tilesBlock.Contains(mousePos) || wallBlock.Contains(mousePos))
return true;
return false; //if mouse isn't over gui's
}
Declaration :
private var tilesBlock : Rect = Rect(0,0,570,182) ; //tiles rectangle
private var wallBlock : Rect = Rect(670,0,590,172) ; //walls rectangle
In the LateUpdate functon i use this code to not rotate my object :
if (isCameraInputIgnored() ) {
return;
}
My problem is that after one of the second gui texture buttons is pressed a color picker appear that is declares like a GuiLayout.BeginArea(Rect) and when i drag my mouse through color my house is movng and changing colors at the same time. I want my house fixed when i am using the color picker.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论