Version: 5.4
Features currently not supported by Unity Tizen
Windows

Building Plugins for Tizen

This page describes Native Code Plugins for the Tizen platform.

Building an Application with a Native Plugin for Tizen

  1. Defina su método externo en el archivo C# como sigue:
[DllImport ("PluginName")]
private static extern float FooPluginFunction();
  1. Set the editor to the Tizen build target
  2. Create a Tizen Native Shared Library project from the Tizen IDE.
  3. All native functions that you want to use from managed code need to have the EXPORT_API attribute added to their definitions. The header tizen.h also needs to be included for access to the EXPORT_API macro.
#include <tizen.h>

EXPORT_API float FooPluginFunction();

Si estás usando C++ (.cpp) para implementar el plugin, debes asegurarte que las funciones sean declaradas con enlazamientos en C para evitar problemas de resolución de nombres.

extern "C" {
  EXPORT_API float FooPluginFunction();
}

Plugins written in C do not need this since these languages do not use name-mangling.

Utilizando Su Plugin desde C#

Once built, the shared library should be copied to the Assets->Plugins->Tizen->libs folder. Unity will then find it by name when you define a function like the following in the C# script:

[DllImport ("PluginName")]
private static extern float FooPluginFunction ();

Favor notar que el PluginName no debe incluir el prefijo (‘lib’) ni la extensión (‘.so’) que hay en el nombre de archivo. Se debe envolver todos los métodos de código nativo con una capa adicional de código en C#. Este código debe revisar a Application.platform y llamar a los métodos nativos solo cuando la aplicación está ejecutándose en el dispositivo actual; algunos valores de prueba pueden ser devueltos desde el código en C# cuando está ejecutándose en el editor. Se pueden también usar las definiciones de plataforma para controlar la compilación de código dependiente de la plataforma.

LLamando C# / JavaScript devuelta desde código nativo

Unity Tizen supports limited native-to-managed callback functionality via UnitySendMessage:

UnitySendMessage("GameObjectName1", "MethodName1", "Message to send");

Esta función tiene tres parámetros : el nombre del GameObject objetivo, el método script a ser llamado en ese objeto y el string de mensaje en ser pasado para el método llamado.

Limitaciones conocidas:

  1. Únicamente los métodos script que corresponden a la siguiente signatura pueden ser llamados desde código nativo: function MethodName(message:string)
  2. Llamadas a UnitySendMessage son asincrónicas y tienen una demora de un cuadro (frame).
Features currently not supported by Unity Tizen
Windows