我有一个静态事件,每当玩家单击“左键单击”按钮时都会触发。
我有一个正在侦听此事件的游戏对象列表,但是该功能仅在if value != '.':
my_list.append(value)
为until [ $(aws ssm get-automation-execution --automation-execution-id "$id" --query 'AutomationExecution.AutomationExecutionStatus' --output text) = *"InProgress"* ];
do
echo "Automation is running......"
sleep 1m
done
status=$(aws ssm get-automation-execution --automation-execution-id "$id" --query 'AutomationExecution.AutomationExecutionStatus' --output text)
if [ "$status" == "Success" ]; then
echo "Automation $status"
elif [ "$status" == "Failed" -o "$status" == "Cancelled" -o "$status" == "Timed Out" ]; then
echo "Automation $status"
fi
时才执行。
即使它为false,也似乎要执行。我确实有一个函数,该函数调用一个使列表ableToShoot
中的下一个对象成为对象的函数,
但这似乎使它陷入无限循环。
这是LeftClickEvent脚本。
true
这是侦听LeftClickEvent的脚本:
ableToShoot = true
这是机械脚本,它将下一个游戏对象AbleToShoot变为true。
public class InputManager : MonoBehaviour
{
public delegate void ShootProjectile();
public static event ShootProjectile Shoot;
private void Update()
{
if (Input.touchCount > 0)
{
if (Input.GetTouch(0).phase == TouchPhase.Began)
{
if (Shoot != null)
{
Shoot();
}
}
}
else if (Input.GetMouseButtonDown(0))
{
if (Shoot != null)
{
Shoot();
}
}
}
}
因此,我感到该事件被放入某种队列,该队列在public class ProjectileMovement : MonoBehaviour
{
public float speed = 3;
private bool ableToShoot;
public int itemInList = 0;
public StartLevelMechanics mechanics;
HitParticles particles;
public bool AbleToShoot
{
get
{
return ableToShoot;
}
set
{
ableToShoot = value;
}
}
private void Awake()
{
InputManager.Shoot += ShootProjectile;
particles = GameObject.Find("HitParticles").GetComponent<HitParticles>();
AbleToShoot = false;
}
public void ShootProjectile()
{
if (AbleToShoot)
{
GetComponentInChildren<Animator>().SetTrigger("Shoot");
iTween.MoveTo(this.gameObject, iTween.Hash("position", new Vector3(transform.position.x, 10, transform.position.z),
"easetype", iTween.EaseType.spring, "time", 1f, "oncomplete", "DestroyProjectile", "oncompletetarget",
this.gameObject));
mechanics.NewBall();
return;
}
}
}
时执行,但是我在文档中找不到任何内容。
答案 0 :(得分:0)
我认为这是因为它创建了该类的多个副本。不知道在哪里使用它,这只是一个猜测。尝试对其进行更改,以便仅存在一个变量ableToShoot的副本:
private static bool ableToShoot;