Welcome, Guest
Username: Password: Remember me

TOPIC: object and gameobject

object and gameobject 1 month 2 days ago #2517

  • gontz
  • gontz's Avatar
  • Offline
  • New Member
  • Posts: 5
  • Karma: 0
Hello,
What is the difference between Object and GameObject ?
How do I use the gameObject?
I tried to add the localization script to the parent (Page1)
and I was expecting the script to activate and dezactivate the relevant gameObjects (children of the Page1 and referenced in localization)

It only shows me on screen the name of the objects
Please advise
The administrator has disabled public write access.

object and gameobject 1 month 2 days ago #2518

  • gontz
  • gontz's Avatar
  • Offline
  • New Member
  • Posts: 5
  • Karma: 0
Is there a way to activate and deactivate objects based on the language selection ?
The administrator has disabled public write access.

object and gameobject 1 month 1 day ago #2519

  • Frank
  • Frank's Avatar
  • Offline
  • Administrator
  • Posts: 897
  • Thank you received: 193
  • Karma: 57
Hi,
The GameObject type is meant to load prefabs dynamically.
The example scene 'I2Localization Standard Components' has an example of loading different prefabs (Cube, Sphere, Cylinder) depending on the language. Which is normally what you want to avoid having lots of disabled objects that are not using in the current language.

Said that, I like to add another Term Type to allow toggling childs depending on the language. Please vote for that and I will prioritize it:
trello.com/c/l3TPWMgM/15-new-term-type-child-visibility

In the mean time, you can do this by using the callbacks. Just create the following script and attach it to your Localize object:
using UnityEngine;

namespace I2.Loc
{

	public class MyChildToggle : MonoBehaviour 
	{
		public void OnModifyLocalization()
		{
			if (string.IsNullOrEmpty(Localize.MainTranslation))
				return;
			
			var tr = Localize.CurrentLocalizeComponent.GetComponent<Transform> ();

			// Find child with the name set in the Translation
			var child = tr.Find (Localize.MainTranslation);

			// if the child is found, change the active state
			if (child != null) 
			{
				// disable all childs except the found one
				foreach (Transform obj in tr)
					obj.gameObject.SetActive (obj == tr);
			}
		}
	}
}

You just need to set the callback in the Localize component as explained here and then type the name of the corresponding child in each translation.
inter-illusion.com/assets/I2LocalizationManual/Callbacks.html

Hope that helps,
Frank
Are you :-) Give I2L 5 stars!
Are you :-( Please lets us know how to improve it!
To get the betas as soon as they are ready, check this out
The administrator has disabled public write access.

object and gameobject 1 month 1 day ago #2520

  • gontz
  • gontz's Avatar
  • Offline
  • New Member
  • Posts: 5
  • Karma: 0
the example does not work or at least the prefab part. it shows for all 3 languages the same prefab...
The administrator has disabled public write access.

object and gameobject 1 month 17 hours ago #2523

  • Frank
  • Frank's Avatar
  • Offline
  • Administrator
  • Posts: 897
  • Thank you received: 193
  • Karma: 57
You are totally right!
It seems that with the latest changes to separate the Localization Targets implementation, the Prefab target got broken.

I fixed it now, and just to make it better, also added a new target to handle visibility of children!!
Let me test this a bit more today and will upload a new version to the beta folder!

Hope that helps,
Frank
Are you :-) Give I2L 5 stars!
Are you :-( Please lets us know how to improve it!
To get the betas as soon as they are ready, check this out
The administrator has disabled public write access.

object and gameobject 1 month 11 hours ago #2524

  • Frank
  • Frank's Avatar
  • Offline
  • Administrator
  • Posts: 897
  • Thank you received: 193
  • Karma: 57
I just uploaded v2.8.1a1 to the beta folder.

That version fixes the GameObject Term's type that was not doing any spawning, and also adds a new term type "Child". This type, enables the child object with the name matching the one in the translations.




Hope that helps,
Frank
Are you :-) Give I2L 5 stars!
Are you :-( Please lets us know how to improve it!
To get the betas as soon as they are ready, check this out
Last Edit: 1 month 11 hours ago by Frank.
The administrator has disabled public write access.
The following user(s) said Thank You: gontz
Time to create page: 0.135 seconds
Colors