2018-10-28

Acceder al Text de un Objeto por C# -- Access "Text" property of an Object with script

SCROLL DOWN TO SEE IN ENGLISH

Hoy veremos como acceder / editar el "Text" de un GameObject, utilizando sólo C#, sin necesidad de utilizar el Inspector.

EJEMPLO:

Nombre del GameObject: titulo_opciones
Objetivo: modificar el texto.

1 - Muy sencillo, declaramos la variable al inicio
2 - Luego utilizaremos la segunda línea para buscar, mediante su nombre, el Gameobject.
* Dentro de la misma línea, le diremos que queremos su propiedad "Text" (podemos usar cualquier otra que tenga).
* Lo asignamos a nuestra variable (texto).
3 - En la tercera línea, le modificamos el valor y se reflejará automáticamente en nuestro programa.

       public Text texto;

       ...

       texto = GameObject.Find("titulo_opciones").GetComponent<Text>();

       texto.text = "Opciones";

 

ENGLISH
Today we will see how to access / edit the "Text" of a GameObject, using only C #, without using the Inspector.


EXAMPLE:

Name of the GameObject:
titulo_opciones

Goal: modify the text.


1 - Very simple, we declare the variable at the beginning (texto)

2 - Then we will use the second line to search, through its name, the Gameobject.

* Within the same line, we will tell that we want 
"Text" property (we can use any other that it has).

* We assign it to our variable (texto).

3 - In the third line, we modify the value and it will be automatically reflected in our program.

2018-10-16

Android permissions

* Don´t ask for permissions, android:
<meta-data android:name="unityplayer.SkipPermissionsDialog" android:value="true" />


<uses-permission android:name="android.permission.READ_PHONE_STATE" tools:node="remove" />
(put it on: "GooglePlayGames/Plugins/Android/GooglePlayGamesManifest.plugin", 
inside "AndroidManifest")

2018-10-04

Google Play Game Services en Unity3D

Google Play Game Services en Unity3D:


How to Config:
1) Install in Unity (Import package):
https://github.com/playgameservices/play-games-plugin-for-unity
(current build)

2) Configure in unity: Window > Google Play Games > Setup > Android Setup

- Create "keystore" and save it (game.keystore).
- Get "SHA1" with "keytool" (see point 3).
- Create app/linked app/leaderboard un Google Play Console.


Constant Class: this can be whatever you want, just give it a name

Resource Definition: in your google play console, go to "game services" and to your app (or "Add New game".
 Select either leaderboards (marcadores) or achievements (create them if you've not set them up) and at the bottom you'll see the 'get resources' link. Click that (it will show new window) and paste it into the box in Unity.

Client ID: also in the game services, go down to linked apps (again, assuming you've already set this up) and click on your game from the list. At the bottom copy the string under "OAuth2 Client ID".


3) Code:
SPANISH:
http://edgargomez.es/unity3d-integrando-google-play-game-services/
ENGLISH:
Unity3D-GooglePlayGames-English

*Before Build*
1/2)
edit APP_ID in androidmanifest:

replace "\ " with "\u003

before:
<meta-data android:name="com.google.android.gms.games.APP_ID" android:value="\ 232323232323" />

after:
<meta-data android:name="com.google.android.gms.games.APP_ID" android:value="\u003232323232323" />


DEBUG:
C:\Users\XX\AppData\Local\Android\Sdk\platform-tools> adb logcat -s Unity ActivityManager PackageManager dalvikvm DEBUG

2/2)
*Be sure to uncheck "Development Build" in "File-Build settings", before build.

Unity Remote

Simple solution to not working Unity Remote on your tablet/phone, its easy: ON YOUR DEVICE (tablet , phone): 1) Enable "Developer ...