Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by VigilantePanda · Jun 08, 2015 at 10:57 AM · c#androidioswindowsinterface

Can I use platform-specific UIs

Short version: Is it possible to make separate UIs for each platform natively so that I can show real Windows Phone / iOS / Android UI elements while still using Unity?

Long Version: I started a project a few months ago where I was attempting to use a native UI for each of the mobile platforms and have the platform-specific code talk back and forth with the Unity code. I had this working in a Windows Universal App by modifying the main XAML and XAML.cs files. I mostly used UnityEngine to do the communication.

So now it has been a few months and it is no longer working. I get errors about not being able to call some of the UnityEngine methods on a non-main thread. I used a dispatcher to invoke my code on a UI thread and that still does not seem to be helping.

Is there a way that I can accomplish what I'm explaining? Like I mentioned, I did have this working for a Windows Universal App at some point, but something has changed. I did not do much with iOS or Android yet.

Edit: I am using a very similar method to what is described in the docs for communication between a Windows Phone 8 app and Unity. http://docs.unity3d.com/Manual/wp8-unity-interaction.html

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Diet-Chugg · Jun 08, 2015 at 07:58 PM

You will find this quite handy: http://docs.unity3d.com/ScriptReference/RuntimePlatform.html

Make a script that is called DisableOnPlatformMismatch.cs

 public class DisableOnPlatformMismatch : Monobehaviour
 {
 public RuntimePlatform runtimePlatform;
 void OnEnable()
 {
 if(Application.platform != runtimePlatform)
 gameObject.SetActive(false);
 }
 }

Make a UI for each platform and place this script on them all. Set the runtimeplatform to the corresponding match and you should be good to go.

The downside to this approach is all the versions of your UI will be included in the build which depending on the complexity of your UIs could cause longer load times. On the plus side you don't have to have multiple copies of your project with a different UI on it.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image VigilantePanda · Jun 09, 2015 at 03:51 AM 0
Share

I'm sorry if my question wasn't clear enough, but I don't think that quite helps me accomplish what I am looking for. It seems like this will allow me to create different UIs for each platform in Unity. What I meant by "native" UI is a platform-specific UI built using that platform's tools.

For example, I want to create the UI in Visual Studio or Xcode and have that code talk to Unity. I have followed the example in the link at the bottom of my original post. This method used to work for me, but no longer does in a Windows Universal App. I did not try a similar solution for iOS or Android yet.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Can a windows and an android app use the same assetbundle specified with no target?,Can Windows and Android apps run assetsbundles with notarget? 0 Answers

Touch Input with Event Trigger. How to handle with it properly. 0 Answers

Unity Editor & iOS - Download MP4 to Streaming Assets Folder 0 Answers

Unity Like Facebook Page through app 3 Answers

How to get result message from System.Diagnostics.Process 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges