Created
November 30, 2020 18:49
-
-
Save Oleur/59ec2dddab763b241d36f2ac2fa90695 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class UnityGameActivity : UnityPlayerActivity() { | |
| override fun onCreate(savedInstanceState: Bundle?) { | |
| super.onCreate(savedInstanceState) | |
| mUnityPlayer += MaterialButton(this).apply { | |
| ... | |
| text = "RANDOMIZE COLOR" | |
| setOnClickListener { | |
| val color = listOf("blue", "green", "red", "yellow").random() | |
| UnityPlayer.UnitySendMessage("Capsule", "ChangeColor", color) | |
| } | |
| } | |
| mUnityPlayer += MaterialButton(this).apply { | |
| ... | |
| text = "QUIT" | |
| setOnClickListener { | |
| val intent = Intent(context, MainActivity::class.java).apply { | |
| flags = Intent.FLAG_ACTIVITY_REORDER_TO_FRONT or Intent.FLAG_ACTIVITY_SINGLE_TOP | |
| } | |
| startActivity(intent) | |
| } | |
| } | |
| mUnityPlayer += JoystickView(this).apply { | |
| ... | |
| findViewById<View>(R.id.forward).setOnClickListener { | |
| UnityPlayer.UnitySendMessage("Capsule", "MoveUp", "") | |
| } | |
| ... | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment