Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Join us on March 30, 2023, between 5 am & 1 pm EST, in the Performance Profiling Dev Blitz Day 2023 - Q&A forum and Discord where you can connect with our teams behind the Memory and CPU Profilers.
    Dismiss Notice

Calling a javascript function from TypeScript file

Discussion in 'Project Tiny' started by Antumarin, Nov 17, 2020.

  1. Antumarin


    May 21, 2017
    As the title says, I'm trying to call a function coded in the html in js from inside a ts file in the project. I'm using Tiny 0.13.2. I know it's a very outdated version of Tiny but it's the one I've been told to use and honestly right now this is the only issue I can't seem to solve.
  2. brunocoimbra


    Sep 2, 2015
    0.13.2 is not meant to be used anymore and is not compatible with newer versions at all, I doubt you will find any support for that version
  3. Antumarin


    May 21, 2017
    Not sure why you decided to reply just to give no answer but we still ended up finding the solution.

    Firstly, in the project's files (next to the Assets folder), you create a "External" folder, and inside you add the javascript file with whichever name you want (in my case I called it "cta.js") with the following code:
    Code (JavaScript):
    1. function callToAction () {
    2.   FbPlayableAd.onCTAClick();
    3. }
    Then you create a "tsconfig.override.json" file on the Tiny project with this code:
    Code (Json):
    1. {
    2.   "compilerOptions": {
    3.     "allowJs": true
    4.   },
    5.   "include": ["External/cta.js"]
    6. }
    And finally, inside your project's script, you just call the function "callToAction();".