- Home /
How to pass a Swift string into Unity iOS game?
I have an enum RemoteCommand that I am trying to pass the values of into my Unity iOS game. Abridged Swift code:
enum RemoteCommand:String {
case none
case open = "Open"
case closed = "Closed"
}
func showAndSendCommand (_ command:RemoteCommand) {
DispatchQueue.main.async {
if command == .open {
print(command)
} else if command == .closed {
print(command)
}
}
}
I am looking for best practices on how to pass this command value that's being printed into my Unity iOS build. The above code lives in the ViewController.swift file, and calculations that are performed on the native iOS side concurrently with the Unity game running should determine that command value. I've looked into embedding the Unity game in my XCode project, but one of the drawbacks I've read is that "embedding Unity can cause problems withing the game, especially graphics ones."
Essentially, I just want to pass a simple string into my Unity game. This string is determined by calculations that need to run in Swift while the game is ongoing. The game will fetch this string value every frame.
Your answer
Follow this Question
Related Questions
Custom swift framework in Unity iOS game 0 Answers
Writing unity ios plugin in Swift 1 Answer
Android Activity equal in ios 0 Answers