Search Unity

MultiPlatform ToolKit - Multiplatform development, simplified.

Discussion in 'Assets and Asset Store' started by gtjuggler, Oct 18, 2011.

  1. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,160
    i have 30 platform specific objects. it is not easy to click Set one by one. it would be nice to have a button to apply all platform specifics for selected platform from your dropdown.
     
  2. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,160
    i changed EasyPlatform.cs. it works as what i need :) i hope it will help other people.

    Code (csharp):
    1.  
    2. void OnGUI ()
    3.     {
    4.         currentPlatform = (Platform)EditorGUILayout.EnumPopup ("Platform: ", (System.Enum)currentPlatform);
    5.         if (GUI.changed) {
    6.             EditorPrefs.SetString (Platforms.editorPlatformOverrideKey, currentPlatform.ToString ());          
    7.             foreach (GameObject obj in Object.FindObjectsOfType(typeof(GameObject))) {
    8.                 var ps = obj.GetComponent<PlatformSpecifics> ();
    9.                 if (ps != null) {
    10.                     ps.ApplySpecifics (Platforms.platform);
    11.                 }              
    12.             }
    13.         }
    14.     }
    15.  
     
    Last edited: Nov 22, 2012
  3. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,160
    gtjuggler can you define PlatformSpecifics methods like ApplySpecifics as virtual. i will extend this class and add custom properties like camera settings, or 2dtk atlas change setting. i can change your code now, but when i update with your new version i will lost my changes. if you decide to make this changes i can test. or i can do this changes and send it to you. in that way mptk will have a smart extension option.
     
  4. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,160
    where do you initialize addTextureUp field? i examined your code and could not find it. i extended this class and have problem about it is null.

    Code (csharp):
    1. [CustomEditor (typeof(PlatformSpecifics))]
    2. public class PlatformSpecificsEditor : Editor {
    3.    
    4.     public Texture2D addTextureUp;
     
  5. gtjuggler

    gtjuggler

    Joined:
    Nov 13, 2008
    Posts:
    238
    Hi. Thanks for posting your feature additions to the tool above. By the way, any questions about extending the codebase should probably be sent to my support email, support - at - owlchemylabs.com

    The issue is that the default reference assignments are not hooked in. See the screenshot below for info:

    Screenshot

    I believe you have to set your inspector to DEBUG in order to see that information.
     
  6. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,160
    i could not see even i set debug on inspector. my error on PlatformSpecifics class but you use AssetSettingsWindow on your screenshot. i confused on this :) i use unity 4.0. what version of unity do you use?
     
  7. gtjuggler

    gtjuggler

    Joined:
    Nov 13, 2008
    Posts:
    238
    Hey there - I'm not sure why the default reference assignments aren't working for you, but I've made it so that the texture references are grabbed using AssetDatabase.LoadAssetAtPath(). This should fix your issue. An update should be approved tomorrow-ish. Contact me directly if you need the code changes immediately!
     
  8. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,160
    new version works well, thanks ! if you make ApplyXXX methods virtual in PlatformSpecifics class, MPTK will expandable for me, and i will be able to do everything :) In fact now i can make this methods virtual, but i have to change them on each update.
     
  9. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,160
    I have a feature request. sometimes i design my game per resolution group not per platform. for iPhone and ipad 2 i have one set, and for higher resolutions i have another set. with mptk i have to set each platform although i have just 2 different values. if there is a platform group per settings it will be useful. it is like per ratio settings that mptk has. also in this group there should be a language parameter. so for multi language applications i can set scale. i guess coding this will not short, but the result will be useful. would you like to consider adding this feature?
     
  10. gtjuggler

    gtjuggler

    Joined:
    Nov 13, 2008
    Posts:
    238
    Hey Atmuc,

    I'll look into possibly doing it for the future. No promises/time commitments at this time.
     
  11. johnny12345

    johnny12345

    Joined:
    Oct 8, 2012
    Posts:
    45
    in your video tutorial you explain changing the BuildProcess Script,do you have to do that if your only building for iPhone,wont the the unity build process work

    thank you
     
  12. gtjuggler

    gtjuggler

    Joined:
    Nov 13, 2008
    Posts:
    238
    Sure. You can skip out on the buildprocess, unless you have a need to process some items before the build happens, or after the build happens. If you are simply applying platformspecifics, you can just do a Unity build.
     
  13. sathya

    sathya

    Joined:
    Jul 30, 2012
    Posts:
    297
    @gtjuggler: I am using Ngui along with MPTL. I want to change the background textures for each resolutions. I am stuck in a place where i need to swap the texture atlas on ngui depending on the device resolutions(Android) i have different texture atlases for each resolution(800x480,1024,600, etc etc). I can swap the UI atlases using replacement function. This is how i m doing it on iOS

    public GameObject atlasMain; //type reference
    public GameObject atlasSD; //type normal
    public GameObject atlasHD; //type normal
    public bool isRetina;

    void Start()
    {
    UIAtlas atlasMainRef = atlasMain.GetComponent<UIAtlas>();
    UIAtlas atlasSDRef = atlasSD.GetComponent<UIAtlas>();
    UIAtlas atlasHDRef = atlasHD.GetComponent<UIAtlas>();
    if(!isRetina)
    {
    atlasMainRef.replacement = atlasSDRef;
    }
    else
    {
    atlasMainRef.replacement = atlasHDRef;
    }

    }

    I want to know how it can be done on android. Is there any simpler solution for this !

     
  14. gtjuggler

    gtjuggler

    Joined:
    Nov 13, 2008
    Posts:
    238
    Hey there. So, I'm not sure how you're setting isRetina, but you can use if (Platforms.platform == Platform.iPadRetina) / iPhoneRetina, but I'll assume that's taken care of.

    As for Android, right now there's no good way to tell whether some arbitrary Android device should get high resolution texture sets or low, since there are so many types of screens. Ideally you could set up a simple width check, and if it's over x pixels wide, go with the higher one.

    It's simple to add in shortcuts to the Platform class, such as IsAndroidLargeScreen, or other shortcuts to keep your main code clean.

    I hope this helps in some way. If you have more specific issues, let me know.
     
  15. sathya

    sathya

    Joined:
    Jul 30, 2012
    Posts:
    297
    Thanks for the assist. Is there any way i can use your "AspectRatios.CS" to get the android device resolution and use values to change the corresponding NGUI atlas files. a small piece of code would help as i am not a developer. :confused:
     
  16. gtjuggler

    gtjuggler

    Joined:
    Nov 13, 2008
    Posts:
    238
    Hey. There is no correlation between aspect ratio and screen size. A 16:9 widescreen phone may be much smaller than a big 4:3 tablet! You never know. What I would do is create a small android atlas and a large android atlas, then do a screen.width check to see whether to use the small or large asset.
     
  17. sathya

    sathya

    Joined:
    Jul 30, 2012
    Posts:
    297
    NGUI .MakePixelPerfect(); function overrides MPTL scale. I am using multiple resolution NGUI atlases for different resolutions by swapping texture atlases depending on the device resolution

    #if UNITY_ANDROID
    if((HeightPixels > 240 WidthPixels > 320) (HeightPixels <= 320 WidthPixels <= 480)) //support mdpi
    {
    thisGameobjectRef.atlas = atlasMdpiRef;
    }
    else if((HeightPixels > 320 WidthPixels > 480) (HeightPixels <= 480 WidthPixels <= 800)) // support hdpi
    {
    thisGameobjectRef.atlas = atlasHdpiRef;
    }
    else if(HeightPixels > 480 WidthPixels > 800) // support xhdpi
    {
    thisGameobjectRef.atlas = atlasXhdpiRef;
    }
    thisGameobjectRef.MakePixelPerfect();
    #endif

    How do i make MPTL override NGUI settings !
     
  18. gtjuggler

    gtjuggler

    Joined:
    Nov 13, 2008
    Posts:
    238
    That's correct. If my tool is saying "take this sprite and double size it on Android" for example, yet you're telling NGUI to make the sprite "Pixel Perfect", they are very plainly conflicting here. One tool says do this, the other tool says do that.

    Either disable pixel perfect or disable your change in Multiplatform Toolkit. If you really want both, you'd need to ensure that the Pixel Perfect NGUI setting happened before the MPTK settings, so MPTK would effectively be postprocessing the pixel perfect change... so if both are happening in Awake, you could change the compile order, or you could manually call that instance of PlatformSpecifics' ApplySpecifics() function after NGUI does its work.
     
  19. sathya

    sathya

    Joined:
    Jul 30, 2012
    Posts:
    297
    i am calling PlatformSpecifics.Init() and PlatformSpecifics.ApplySpecifics(Platforms.platform); after NGUI.MakePixelperfect() function but still no luck.
     
  20. gtjuggler

    gtjuggler

    Joined:
    Nov 13, 2008
    Posts:
    238
    I took a quick look at NGUI's code and if you're using a SpriteAnimation, it calls makepixelperfect every frame...

    I would revisit your logic as to using both pixelPerfect and MPTK's scale on the same item
     
  21. Omir

    Omir

    Joined:
    Sep 11, 2012
    Posts:
    9
    Hey ! gtjuggler !! thank you for this wonderful tool ..... btw i imported the package into my scene (empty scene ) and i am getting following errors any help would be appreciated
    Code (csharp):
    1. Assets/MultiPlatformToolSuite/Editor/Build Scripts/BuildProcess.cs(279,53): error CS0103: The name `iOSTargetPlatform' does not exist in the current context
    2. Assets/MultiPlatformToolSuite/Editor/Build Scripts/BuildProcess.cs(279,36): error CS0117: `UnityEditor.PlayerSettings.iOS' does not contain a definition for `targetPlatform'
    3. Assets/MultiPlatformToolSuite/Editor/Build Scripts/BuildProcess.cs(322,53): error CS0103: The name `iOSTargetPlatform' does not exist in the current context
    4. Assets/MultiPlatformToolSuite/Editor/Build Scripts/BuildProcess.cs(322,36): error CS0117: `UnityEditor.PlayerSettings.iOS' does not contain a definition for `targetPlatform'
    5. Assets/MultiPlatformToolSuite/Editor/Build Scripts/BuildProcess.cs(350,57): error CS0103: The name `AndroidTargetGraphics' does not exist in the current context
    6. Assets/MultiPlatformToolSuite/Editor/Build Scripts/BuildProcess.cs(350,40): error CS0117: `UnityEditor.PlayerSettings.Android' does not contain a definition for `targetGraphics'
    7.  
    All Errors are in Buildprocess.cs script and is multiplatform toolkit compatible with windows PC
     
  22. gtjuggler

    gtjuggler

    Joined:
    Nov 13, 2008
    Posts:
    238
    Hi. Thanks for pointing this out. MPTK is compatible with Windows, though these offending lines should be wrapped in preprocessor directives, like:

    #if UNITY_IPHONE
    //the line that is failing to compile
    #endif

    or

    #if UNITY_ANDROID
    //the line that is failing to compile
    #endif

    I'll make an update to the product to fix that in the next revision for those who don't have Unity iPhone/Android.
     
  23. Omir

    Omir

    Joined:
    Sep 11, 2012
    Posts:
    9
    Thank You For Replying , Other than waiting is there something i can do as my project is almost ready for build processes for information purpose , i have android pro + unity pro , if i am not wrong are you telling me to comment out some code in script to stop its functionality,
    and why am i getting errors for android as i have android licence

    Code (csharp):
    1.  
    2.  
    3. Assets/MultiPlatformToolSuite/Editor/Build Scripts/BuildProcess.cs(350,57): error CS0103: The name `AndroidTargetGraphics' does not exist in the current context
    4.  
    5. Assets/MultiPlatformToolSuite/Editor/Build Scripts/BuildProcess.cs(350,40): error CS0117: `UnityEditor.PlayerSettings.Android' does not contain a definition for `targetGraphics'
    6.  
    7.  
     
  24. gtjuggler

    gtjuggler

    Joined:
    Nov 13, 2008
    Posts:
    238
    @Omir - Looks like you're using Unity 3.5 on Windows? Email me at support - at - owlchemylabs dot com and I'll take a look at your setup and confirm a few things before giving you improper advice.
     
  25. lzt120

    lzt120

    Joined:
    Apr 13, 2010
    Posts:
    93
    Can this tool support Instantiate ojbects at runtime.
    For example:
    I need instantiate some objects, and the position of the object is random position within the screen.How cound I setup this by your tool ?
     
  26. gtjuggler

    gtjuggler

    Joined:
    Nov 13, 2008
    Posts:
    238
    This is unrelated to Multiplatform Toolkit.
    Instantiation and randomization of position is completely possible in Unity, through scripting.

    You can also instantiate a prefab, with the PlatformSpecifics class on it, and it'll run the platform-specific adjustments when instantiated.
     
  27. Grespon

    Grespon

    Joined:
    Apr 13, 2012
    Posts:
    388
    Does support Unity 3.5 ?????
     
  28. gtjuggler

    gtjuggler

    Joined:
    Nov 13, 2008
    Posts:
    238
    Indeed, it does. Is it not showing up in the store as supporting 3.5?
     
  29. sloopidoopi

    sloopidoopi

    Joined:
    Jan 2, 2010
    Posts:
    244
    Hi,
    just bought this wonderful asset but have some trouble with prefabs and PlatformSpecifics. My prefab has a Platformspecifics component. I make a couple of instances from it in the SceneView and change the material for different platforms in the instances. When I run my scene all my instances change to the default materials that I used in my original prefab( In my case nothing). So I have no chance to make a working prefab with a preassigned Platformspecifics component. It only works when I add the component by hand in the SceneView. Is this a known limitation?
     
  30. gtjuggler

    gtjuggler

    Joined:
    Nov 13, 2008
    Posts:
    238
    How are you doing this? Are you talking about instantiating the prefabs from code? Or are you dragging the prefab into the scene and then changing the linked material on a per-instance basis?

    Keep in mind those platformspecific changes happen on Awake!
     
  31. sloopidoopi

    sloopidoopi

    Joined:
    Jan 2, 2010
    Posts:
    244
    I'm instantiating them via drag&drop into the sceneView. Then I change the materials, but when I hit play the references are lost and switch back to the settings of the original prefab in the ProjectView/AssetDatabase.
     
  32. gtjuggler

    gtjuggler

    Joined:
    Nov 13, 2008
    Posts:
    238
    Do you have any other components on the gameobject(s) in question which could also affect the mesh/renderer/material assignment? If for example, you were using 2D Toolkit or other similar framework and it was a tk2d sprite, you would run the risk of tk2d adjusting your material on Awake, conflicting with MPTK in that case.

    Maybe you can email me at info -at- owlchemylabs.com and we can screenshare to figure it out.
     
  33. Jojo-Batista

    Jojo-Batista

    Joined:
    Dec 5, 2012
    Posts:
    32
    Will it support win store soon?
     
  34. gtjuggler

    gtjuggler

    Joined:
    Nov 13, 2008
    Posts:
    238
    Well, unless it doesn't compile or pass WACK, then it should support Windows Store. Could you list the problems you're having?

    You might be referring to the fact that there is not a WinPhone option in the platform list. It's very easy to add a new platform to the list, and you can do it in about 4 minutes. I can walk you through the procedure over Skype if you need assistance, but you can search for iPhoneRetina or any other specific platform throughout the plugin and basically copypasta the references and make your own WinPhone platform. Then you need to determine whether you want to make it AspectRatio based (like Standalone/Android) or Static (like iPhone/iPad where there are only a few known skus) and you're all set.
     
  35. Jojo-Batista

    Jojo-Batista

    Joined:
    Dec 5, 2012
    Posts:
    32
    I tried adding it manually, but is not saving the values. It would be nice if we can talk on skype for just a sec. I sent you a private message with my skype. Thanks for the quick response!
     
  36. Ox_

    Ox_

    Joined:
    Jun 9, 2013
    Posts:
    93
    Is it possible to add an aspect ratio in the list by myself?

    If no, please, add 5:3 in future updates. Now it's "Custom 800x480", but some Windows 8 phones have 1280x768.

    And thank you for the incredibly inspiring GDC session. Moved to Unity, so happy with this decision. :3
     
    Last edited: Jun 9, 2013
  37. gtjuggler

    gtjuggler

    Joined:
    Nov 13, 2008
    Posts:
    238
    Yes, we will remove the customs and add in the corresponding aspectratios (5:3) in the next update.

    I'm really glad you enjoyed the GDC talk :) We put a lot of effort into packing in a ton of info. Hopefully it helps you out in the future!

    Thanks!
     
  38. Ben-BearFish

    Ben-BearFish

    Joined:
    Sep 6, 2011
    Posts:
    1,204
    Is it compatible with 2D Toolkit by Unikron Software?
     
  39. gtjuggler

    gtjuggler

    Joined:
    Nov 13, 2008
    Posts:
    238
    Indeed! We use MPTK with 2D Toolkit all the time. Some more info for you:

    From our Documentation, you can check out these sections:

    Compatibility and Known Issues with 2D Frameworks
    The MultiPlatform ToolKit has been tested with SpriteManager2 and EZGUI with minimal friction. If your 2d framework works with Transforms in the scene hierarchy that can be scaled and positioned at any time, then it's definitely compatible with the MultiPlatform ToolKit. Here are a few things to consider when dealing with 2d:

    Known Issue: The custom Text classes in 2D frameworks such as SpriteManager's SpriteText are not supported out of the box. For more information, please read the Custom Text Compatibility section.

    Known Issue: Watch out for swapping materials when using atlasted textures! Depending on the atlasing software and how the atlas is generated you might not be able to use MultiPlatform ToolKit to do the swapping.

    Known Issue: Using things like EZLayout or checking Pixel Perfect in SpriteManager2 will of course override any positioning or scaling done by the MultiPlatform ToolKit. Same goes for the "Normalize Scene Sprite Scales" box in the ex2D sprite toolkit.

    Compatibility with text replacement
    The MultiPlatform ToolKit supports replacing text contents on TextMesh objects as well as swapping fonts and font materials. For example, if you want your mobile versions to say "Tap Here!" and your Standalone platforms to say "Click Here!", the Text Mesh Text field will allow you to swap out text for any platform. Or if you want to swap from 60pt font to 24pt font depending on your screen resolution, the toolkit supports that.

    Out of the box, the toolkit only supports changes to the TextMesh class, but it could be easily extended to have another text class in its place, such as GUIText, SpriteManager's SpriteText class, 2D Toolkit's BMTextMesh class, or ex2D's SpriteFont class depending on what you're using. Feel free to extend PlatformSpecifics to support it.

    In order to extend PlatformSpecifics to support custom text solutions, take a look at PlatformSpecifics' function ApplyFont() and ApplyTextMeshText(). Change these to edit your custom class' text field and material/font field. Then, swap out the instances of "<TextMesh>" within the PlatformSpecificsEditor.cs class to your custom class to ensure proper editor functionality of the PlatformSpecifics class. That's pretty much it.

    TLDR: If you're asking "will MPTK work with <insert 2d toolkit here>, pause the game and move the scene transforms around. If your 2d kit uses normal transforms and 3d quads that can be moved around the scene, you should be fully compatible to scale and position based on platform. See above for the gotchas (like avoiding switching materials post-atlasing)
     
  40. TokyoDan

    TokyoDan

    Joined:
    Jun 16, 2012
    Posts:
    1,080
    Hi,

    Is there a video of that GDC talk?
     
  41. gtjuggler

    gtjuggler

    Joined:
    Nov 13, 2008
    Posts:
    238
    It's behind the GDC Vault.
     
  42. Tripwire

    Tripwire

    Joined:
    Oct 12, 2010
    Posts:
    442
    Quick question, i saw that your tool is now in the Madness Sale. Is that sale still on tomorrow? Then i can buy your Asset with the CC from my Boss :)

    EDIT:
    Other question:
    I'm a heavy NGUI user in combination with FastGUI. Does everything multiplatform toolkit work well with NGUI?

    EDIT2:
    NVM the question about NGUI should've read the documentation :)
     
    Last edited: Aug 5, 2013
  43. gtjuggler

    gtjuggler

    Joined:
    Nov 13, 2008
    Posts:
    238
    As a seller I actually didn't know when the sale would begin and whether I'd be in it. That's also the case with the duration - I have no idea when it ends! Silly.
     
  44. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,524
    it shows as requiring unity 4.0 which means the asset was uploaded with unity 4.0.
    When you upload the asset with 3.5 it will show that and allows people with 3.5 to buy.
     
  45. gtjuggler

    gtjuggler

    Joined:
    Nov 13, 2008
    Posts:
    238
    Yep, latest version is now 4.0 minimum. I can provide back-versions for those stuck in 3.5 but won't be able to give add new features to it.
     
  46. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,524
    I'm now installing unity 4 to buy it, I will still be using 3.5 for my projects, I don't need so much new features just a working 3.5 version will be fine.
    Thanks
     
  47. gtjuggler

    gtjuggler

    Joined:
    Nov 13, 2008
    Posts:
    238
    If you have issues downgrading, email me and I'll get you an older version.
     
  48. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,524
    I have one question, is it possible to detect the device for example iphone 4 and iphone 5 and load different textures ?
     
  49. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,524
    +1
     
  50. gtjuggler

    gtjuggler

    Joined:
    Nov 13, 2008
    Posts:
    238
    There is an easy way to pull this off, which we have used in all of our projects. Normally, with 2D Toolkit, our sprite atlases for regular UI/game art are swapped out per-platform anyway (a built in feature of 2D Toolkit), but for large backgrounds and major art pieces of the game (title screen, backgrounds of level select, etc), we do a manual swap. Using this manual swap method, only that platform's asset is loaded into memory! The platform detection in MPTK allows you to write simple code such as:

    Code (csharp):
    1.  
    2. if(Platforms.platform == Platform.iPad) { //ipad 1 and 2
    3.      //load a new texture specific to ipad1/2
    4.      myRenderer.sharedMaterial.mainTexture = Resources.Load("images/ipadTexture");
    5. } else if (Platforms.platform == Platform.iPadRetina) { //ipad 3
    6.      //load a new ipad3 texture
    7.      myRenderer.material.mainTexture = Resources.Load("images/ipad3Texture");
    8. }
    9.  
    Then, you'll want to make sure your material has no texture linked into it, so when the scene loads, on awake, this code runs and picks the proper texture to link in.