I2 Localize destroys a game object.
8 years 2 months ago - 8 years 2 months ago #1780
by Aksel
I2 Localize destroys a game object. was created by Aksel
Hi!
Somehow I have managed to get a problem where a game object keeps disappearing, even in editor when I click on it. See screenshot:
If I try to change the term regarding that object, it says:
"Destroying assets is not permitted to avoid data loss" and points to the "DoLocalize_Child(string MainTranslation, string SecondaryTranslation) function
in Localize script.
When I play the game the first child of the game object is destroyed. Also a "DontDestroyOnLoad" appears.
I have tried deleting the term and making a new one, but it seems to be linked somehow regarding the game object. If I remove the Localize component from
the game object it stops bugging and works.
Hmm. Now when inspecting more, all of the turret objects I have are with the same problem. The first child gets destroyed.
Any idea what is wrong?
EDIT:
Ok, so what I'm doing is that I want each turret to have a string, describing the name, I made the shop menu such that it will display the name in the shop. I can then use the Localize script to localize them. So when a turret is bought/built I fetch the term from the built turret object when the player wants to tweak it.
I have added the Localize component directly on the Turret object. Perhaps this is wrong? Should I add an empty child and put the localize object on that instead? Or is there yet a better way of doing it?
EDIT 2:
I added empty childs to each object and put the localize component on that. It seems to work now, but is this at all proper? Let me know if you have ideas Thank you for a great tool.
Somehow I have managed to get a problem where a game object keeps disappearing, even in editor when I click on it. See screenshot:
If I try to change the term regarding that object, it says:
"Destroying assets is not permitted to avoid data loss" and points to the "DoLocalize_Child(string MainTranslation, string SecondaryTranslation) function
in Localize script.
When I play the game the first child of the game object is destroyed. Also a "DontDestroyOnLoad" appears.
I have tried deleting the term and making a new one, but it seems to be linked somehow regarding the game object. If I remove the Localize component from
the game object it stops bugging and works.
Hmm. Now when inspecting more, all of the turret objects I have are with the same problem. The first child gets destroyed.
Any idea what is wrong?
EDIT:
Ok, so what I'm doing is that I want each turret to have a string, describing the name, I made the shop menu such that it will display the name in the shop. I can then use the Localize script to localize them. So when a turret is bought/built I fetch the term from the built turret object when the player wants to tweak it.
I have added the Localize component directly on the Turret object. Perhaps this is wrong? Should I add an empty child and put the localize object on that instead? Or is there yet a better way of doing it?
EDIT 2:
I added empty childs to each object and put the localize component on that. It seems to work now, but is this at all proper? Let me know if you have ideas Thank you for a great tool.
Last edit: 8 years 2 months ago by Aksel.
Please Log in or Create an account to join the conversation.
8 years 2 months ago - 8 years 2 months ago #1781
by Frank
Are you Give I2L 5 stars!
Are you Please lets us know how to improve it!
Replied by Frank on topic I2 Localize destroys a game object.
Hi,
The issue is that the Child Term Type was meant for instantiate a copy of a prefab and then automatically delete it after its done.
If you are assigning a child object, then it will be deleted. I have been thinking in adding a new term type "Child Visibility" that instead of instantiating a prefab, just toggle the visibility of a child object.
That should allow you to keep all your children gameObjects and enable/disable the one that should be visible.
I think this new term is actually more useful than the current Child term type (or at least will be used more commonly), but because of no one asking for it, I have been de-prioritizing it.
I just added this feature to the roadmap , if you think it will be helpful for you, please, give it a vote!
Another workaround with the current Child Term Type, is to make localized Child a separated prefab instead of adding it as a child of the main object.
The issue is that the Child Term Type was meant for instantiate a copy of a prefab and then automatically delete it after its done.
If you are assigning a child object, then it will be deleted. I have been thinking in adding a new term type "Child Visibility" that instead of instantiating a prefab, just toggle the visibility of a child object.
That should allow you to keep all your children gameObjects and enable/disable the one that should be visible.
I think this new term is actually more useful than the current Child term type (or at least will be used more commonly), but because of no one asking for it, I have been de-prioritizing it.
I just added this feature to the roadmap , if you think it will be helpful for you, please, give it a vote!
Another workaround with the current Child Term Type, is to make localized Child a separated prefab instead of adding it as a child of the main object.
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: 8 years 2 months ago by Frank.
Please Log in or Create an account to join the conversation.
8 years 2 months ago #1783
by Aksel
Replied by Aksel on topic I2 Localize destroys a game object.
Hi, Frank!
Thank you for the answer. I'm not quite sure if I understood you correctly.
When I add the Localize script to my turret object it automatically wants to target either "prefab" or "SpriteRenderer". It also automatically sets the term key name as the same as the first child of the turret object. When I add an empty child, and add the Localize script to that instead, it sets target as none.
Is there a way to add the Localize script without assigning a target?
What I need for my game is to have a specific term associated with each turret, so that I can display the name in multiple languages simply by getting the term from the turret itself. I've been adding a Localize script to each turret and then assigning the term through the script. Maybe there is a much better way to do this?
Thank you for the answer. I'm not quite sure if I understood you correctly.
When I add the Localize script to my turret object it automatically wants to target either "prefab" or "SpriteRenderer". It also automatically sets the term key name as the same as the first child of the turret object. When I add an empty child, and add the Localize script to that instead, it sets target as none.
Is there a way to add the Localize script without assigning a target?
What I need for my game is to have a specific term associated with each turret, so that I can display the name in multiple languages simply by getting the term from the turret itself. I've been adding a Localize script to each turret and then assigning the term through the script. Maybe there is a much better way to do this?
Please Log in or Create an account to join the conversation.
8 years 2 months ago #1784
by Frank
Are you Give I2L 5 stars!
Are you Please lets us know how to improve it!
Replied by Frank on topic I2 Localize destroys a game object.
Hi,
If you need to just add a term, you can create an script with a string containing the term (or add the string to any other script in that turret).
The issue with strings, is that they don't show the nice popup for selecting the Term. To solve this issue, the plugin has the [TermPopup] attribute that renders the poup instead of the TextField in the inspector:
That way, instead of adding a Localize component, just add that ExampleScript and use the _Term variable.
Hope that helps,
Frank
If you need to just add a term, you can create an script with a string containing the term (or add the string to any other script in that turret).
The issue with strings, is that they don't show the nice popup for selecting the Term. To solve this issue, the plugin has the [TermPopup] attribute that renders the poup instead of the TextField in the inspector:
using UnityEngine;
using System.Collections;
using I2.Loc;
public class ExampleScript : MonoBehaviour
{
[TermsPopup]
public string _Term;
}
That way, instead of adding a Localize component, just add that ExampleScript and use the _Term variable.
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
Please Log in or Create an account to join the conversation.
8 years 2 months ago #1785
by Aksel
Replied by Aksel on topic I2 Localize destroys a game object.
That's perfect! Thank you.
A quick question. Is "DontDestroyOnLoad" something that I2 adds to the scene? Just wondering if I've messed up something since I did not see it there previously and if it is something to worry about.
A quick question. Is "DontDestroyOnLoad" something that I2 adds to the scene? Just wondering if I've messed up something since I did not see it there previously and if it is something to worry about.
Please Log in or Create an account to join the conversation.
Time to create page: 0.157 seconds