I have created a game in Unity and am deploying to an iPhone by building the project for Xcode and going from there. Unity wraps its projects up and generates the objective-C files in Xcode for you;
I have worked with Swift in the past and have always delayed my launch screens (I know this is bad practice but I am working with someone who would like the splash screen displayed for 3 seconds before the game instead just appearing briefly) by having the application sleep
for a few seconds in the applicationDidFinishLaunching
method. I need to know how to do this with a Unity project generated with objective-c-
I have tried putting [NSThread sleepForTimeInterval:6.0];
in the
- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
function in my UnityAppController.mm file, and while this seems to be the right place the splash screen is still displayed for maybe a second.
How can I delay the splash in a unity project in Xcode?
Actually you can implement this request in the Unity itself.
Create a 2D canvas in your first scene, and make it over everything else like this:
Render Mode: Screen Space - Overlay
Change your splash screen image texture type to Sprite like this
Texture Type: Sprite (2D and UI)
Create an UI Image and assign above sprite as Source Image to cover all screen
Source Image: SplashScreenImage
Create a start script component into canvas object like this one
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class CanvasBehaviour : MonoBehaviour
{
public Image backgroundImage;
void Awake() {
StartCoroutine(RemoveBackgroundImage());
}
private IEnumerator RemoveBackgroundImage()
{
Debug.Log("Before Waiting 3 seconds");
yield return new WaitForSeconds(3);
backgroundImage.gameObject.SetActive(false);
Destroy(backgroundImage);
}
}
By doing this, after splash screen, user will only see the same image so he/she will not understand that anything changed.
Since you don't block the UI Thread by making sleep, you can show some basic animation in the canvas and/or prepare your scene behind the background image.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.