Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

[SOLVED] get platform.

Discussion in 'Project Tiny' started by Anton_hc, Apr 2, 2019.

  1. Anton_hc

    Anton_hc

    Joined:
    Jul 6, 2012
    Posts:
    15
    It possible, to get platform (Android\iOS)? or possible way, to execute .js code for use navigator.userAgent?

    i was try to add TSproject\tsconfig.override.json, but it seems, that it does not work.
    {
    "compilerOptions":
    {
    "allowJs": true
    },
    "include":[
    "External/*.js"
    ]
    }

    (TSproject\External\Platform.js)

    import m = require("platform"); not work too. I get error "TypeScriptError: Cannot compile modules using option 'outFile' unless the '--module' flag is 'amd' or 'system'."
     
  2. Pakor

    Pakor

    Joined:
    Feb 2, 2017
    Posts:
    32
    Is this what you are looking for?

    Code (JavaScript):
    1. console.log(clientInformation.platform);
    You can just add this to a normal typescript script. You can also get any other userAgent data this way.
     
    Anton_hc likes this.
  3. Anton_hc

    Anton_hc

    Joined:
    Jul 6, 2012
    Posts:
    15
    it does not work. i get ReferenceError: clientInformation is not defined =(
     
  4. Pakor

    Pakor

    Joined:
    Feb 2, 2017
    Posts:
    32
    Code (JavaScript):
    1. namespace game
    2. {
    3.     export class ExampleSystem extends ut.ComponentSystem
    4.     {
    5.          OnUpdate(): void
    6.          {
    7.                 console.log(window.navigator.userAgent);
    8.          }
    9.     }
    10. }
    This should work. If not then I don't know what the issue is
     
    Anton_hc likes this.
  5. Anton_hc

    Anton_hc

    Joined:
    Jul 6, 2012
    Posts:
    15
    Thanks, it's work, Great!

    *But i think, i still need to use javascript for another purpose. And i not found solution for this =(
     
  6. Pakor

    Pakor

    Joined:
    Feb 2, 2017
    Posts:
    32
    What do you need it for? Maybe I can help if you give some details
     
    Anton_hc likes this.
  7. Anton_hc

    Anton_hc

    Joined:
    Jul 6, 2012
    Posts:
    15
    it's look like minify not work with UTiny.PlayableAD. I think, it possible to solve this problem with use the MRAID directly.

    Error message:
    Idle process detected. See console for more details.
    UnityEngine.Debug:LogError(Object)
    Unity.Tiny.TinyShell:WaitForProcess(Process, StringBuilder, Int32) (at Library/PackageCache/com.unity.tiny@0.14.3-preview/Editor/Utility/TinyShell.cs:294)
    Unity.Tiny.TinyShell:RunInShell(String, ShellProcessArgs) (at Library/PackageCache/com.unity.tiny@0.14.3-preview/Editor/Utility/TinyShell.cs:190)
    Unity.Tiny.TinyShell:RunTool(String, String[]) (at Library/PackageCache/com.unity.tiny@0.14.3-preview/Editor/Utility/TinyShell.cs:71)
    Unity.Tiny.BuildStepGenerateHTML:Run(TinyBuildContext) (at Library/PackageCache/com.unity.tiny@0.14.3-preview/Editor/Export/HTML5/TinyHTML5Builder.cs:928)
    Unity.Tiny.TinyBuildPipeline:RunBuildSteps(ProgressBarScope, TinyBuildContext) (at Library/PackageCache/com.unity.tiny@0.14.3-preview/Editor/Export/TinyBuildPipeline.cs:554)
    Unity.Tiny.TinyBuildPipeline:Build(TinyBuildOptions) (at Library/PackageCache/com.unity.tiny@0.14.3-preview/Editor/Export/TinyBuildPipeline.cs:520)
    Unity.Tiny.TinyBuildPipeline:BuildAndLaunch() (at Library/PackageCache/com.unity.tiny@0.14.3-preview/Editor/Export/TinyBuildPipeline.cs:410)
    Unity.Tiny.TinySettingsProvider:DrawProjectSettings(TinyProject) (at Library/PackageCache/com.unity.tiny@0.14.3-preview/Editor/Windows/TinySettingsProvider.cs:130)
    Unity.Tiny.TinySettingsProvider:OnGUI(String) (at Library/PackageCache/com.unity.tiny@0.14.3-preview/Editor/Windows/TinySettingsProvider.cs:41)
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)
    Build step 'Generating HTML' failed with exception: System.Exception: Tiny:
    at Unity.Tiny.TinyShell.RunInShell (System.String command, Unity.Tiny.ShellProcessArgs args) [0x002d2] in D:\PROJECTS\TinyBowMaster2\Library\PackageCache\com.unity.tiny@0.14.3-preview\Editor\Utility\TinyShell.cs:217
    at Unity.Tiny.TinyShell.RunTool (System.String name, System.String[] args) [0x00031] in D:\PROJECTS\TinyBowMaster2\Library\PackageCache\com.unity.tiny@0.14.3-preview\Editor\Utility\TinyShell.cs:71
    at Unity.Tiny.TinyHTML5Builder+BuildStepGenerateHTML.Run (Unity.Tiny.TinyBuildContext context) [0x002f1] in D:\PROJECTS\TinyBowMaster2\Library\PackageCache\com.unity.tiny@0.14.3-preview\Editor\Export\HTML5\TinyHTML5Builder.cs:928
    at Unity.Tiny.TinyBuildPipeline.RunBuildSteps (Unity.Tiny.TinyEditorUtility+ProgressBarScope progress, Unity.Tiny.TinyBuildContext context) [0x00060] in D:\PROJECTS\TinyBowMaster2\Library\PackageCache\com.unity.tiny@0.14.3-preview\Editor\Export\TinyBuildPipeline.cs:554
    UnityEngine.Debug:LogError(Object)
    Unity.Tiny.TinyBuildPipeline:RunBuildSteps(ProgressBarScope, TinyBuildContext) (at Library/PackageCache/com.unity.tiny@0.14.3-preview/Editor/Export/TinyBuildPipeline.cs:563)
    Unity.Tiny.TinyBuildPipeline:Build(TinyBuildOptions) (at Library/PackageCache/com.unity.tiny@0.14.3-preview/Editor/Export/TinyBuildPipeline.cs:520)
    Unity.Tiny.TinyBuildPipeline:BuildAndLaunch() (at Library/PackageCache/com.unity.tiny@0.14.3-preview/Editor/Export/TinyBuildPipeline.cs:410)
    Unity.Tiny.TinySettingsProvider:DrawProjectSettings(TinyProject) (at Library/PackageCache/com.unity.tiny@0.14.3-preview/Editor/Windows/TinySettingsProvider.cs:130)
    Unity.Tiny.TinySettingsProvider:OnGUI(String) (at Library/PackageCache/com.unity.tiny@0.14.3-preview/Editor/Windows/TinySettingsProvider.cs:41)
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)
     
  8. Pakor

    Pakor

    Joined:
    Feb 2, 2017
    Posts:
    32
    Im afraid I dont know much about playable ads and mraid. You should make a new thread for this problem so other people can help :)
     
    Anton_hc likes this.