我正在从Swift SpriteKit背景学习Unity,其中移动精灵的x位置与运行动作一样直接如下:
let moveLeft = SKAction.moveToX(self.frame.width/5, duration: 1.0)
let delayAction = SKAction.waitForDuration(1.0)
let handSequence = SKAction.sequence([delayAction, moveLeft])
sprite.runAction(handSequence)
Run Code Online (Sandbox Code Playgroud)
我想知道一种等效或类似的方法,将精灵移动到特定持续时间(例如,一秒)的特定位置,并且延迟不必在更新函数中调用.
我想在 Unity 中创建一些萤火虫。我想增加光强度,然后等待几秒钟,然后在 Unity 中减少它。当它们生成时,我希望它们增加光强度,等待几秒钟,然后淡出。我怎样才能以干净的方式创建这个“过程”?
private Light pointLight; // The light component of the firefly
private float minLuminosity = 0; // min intensity
private float maxLuminosity = 1; // max intensity
private float luminositySteps = 0.005f; // factor when increasing / decreasing
private float shineDuration = 3; // wait 3 seconds when faded in
private void Start()
{
pointLight = GetComponent<Light>();
pointLight.intensity = Random.Range(minLuminosity, maxLuminosity); // start with a random intensity
StartCoroutine(ChangeIntensity()); // start the process
}
private IEnumerator ChangeIntensity() …Run Code Online (Sandbox Code Playgroud) 在Unity中是否有类似Toast的消息,类似于GUI,而与android类似。在android中,只需一行代码就很容易。
public void buttonclick()
{
// Message to show
}
Run Code Online (Sandbox Code Playgroud)