У меня есть холст, панель и некоторые текстовые элементы пользовательского интерфейса (несколько). На холсте у меня есть два простых сценария, которые просто включают и выключают элементы, в зависимости от времени (код в конце, прикрепленные скриншоты), в частности, сценарии включают и выключают текстовые элементы на панели. На панели ничего не изменилось. В текстовых элементах у меня есть сценарий, который очень простой, который типит в текстовой букве по букве (код в конце, прикрепленные скриншоты).
работает. Но если я возьму копию этого холста и помесчу его в другую сцену или в эту сцену (не имеет значения), он все равно будет «работать», но введет только первую букву из текста (код в конце, прикрепленные скриншоты). Если я скину каждый прикрепленный сценарий, он покажет текст. Мне очень сложно правильно описать эту проблему, так как у меня нет абсолютно понятия, почему она так работает, но, короче говоря, у меня есть холст, который показывает текстовую букву по букве, если я скопирую этот холст и использую его в другом месте, он будет вводить только на экране первой буквы текста. src = "https://i.sstatic.net/ke7ps6pb.png"/>
exaterOneWorkSfinePedIntext
/> exampleTwowHathAppensWithThecopy < /p>
< /p>
Панель
public class TriggerTime : MonoBehaviour
{
public GameObject myobject;
public GameObject lightEnemy;
public float timer;
void Start()
{
myobject.SetActive(true);
lightEnemy.SetActive(false);
StartCoroutine(TurnOn());
}
IEnumerator TurnOn()
{
yield return new WaitForSeconds(timer);
myobject.SetActive(false);
lightEnemy.SetActive(true);
}
}
< /code>
public class ThreeTimesThree : MonoBehaviour
{
public GameObject myobject;
public GameObject lightEnemy;
public GameObject objThree;
public GameObject objFour;
public float timer;
public float timerTwo;
public float timerThree;
void Start()
{
if (myobject != null)
myobject.SetActive(true);
if (lightEnemy != null)
lightEnemy.SetActive(false);
if (objThree != null)
objThree.SetActive(false);
if (objFour != null)
objFour.SetActive(false);
StartCoroutine(TurnOn());
StartCoroutine(TurnOnSecond());
StartCoroutine(TurnOnThird());
}
IEnumerator TurnOn()
{
yield return new WaitForSeconds(timer);
if (myobject != null)
myobject.SetActive(false);
if (lightEnemy != null)
lightEnemy.SetActive(true);
else
Debug.Log("lightEnemy not assigned");
}
IEnumerator TurnOnSecond()
{
yield return new WaitForSeconds(timerTwo);
if (lightEnemy != null)
lightEnemy.SetActive(false);
if (objThree != null)
objThree.SetActive(true);
else
Debug.Log("objThree not assigned");
}
IEnumerator TurnOnThird()
{
yield return new WaitForSeconds(timerThree);
if (objThree != null)
objThree.SetActive(false);
if (objFour != null)
objFour.SetActive(true);
else
Debug.Log("objFour not assigned");
}
}
< /code>
public class TypingEffect : MonoBehaviour
{
public TMP_Text textMeshPro;
[TextArea] public string inputText;
[TextArea] public string inputTextRU;
[TextArea] public string inputTextUA;
public float typingSpeed = 0.05f;
private string fullTextEN;
private string fullTextRU;
private string fullTextUA;
public bool ua;
public bool ru;
public bool en;
void Awake()
{
if (ua)
{
fullTextUA = inputTextUA.Normalize();
textMeshPro.text = "";
}
if (ru)
{
fullTextRU = inputTextRU.Normalize();
textMeshPro.text = "";
}
if (en)
{
fullTextEN = inputText.Normalize();
textMeshPro.text = "";
}
}
void Start()
{
StartCoroutine(TypeText());
}
IEnumerator TypeText()
{
if (en)
{
for (int i = 0; i < fullTextEN.Length; i++)
{
textMeshPro.text += fullTextEN;
yield return new WaitForSeconds(typingSpeed);
}
}
if (ru)
{
for (int i = 0; i < fullTextRU.Length; i++)
{
textMeshPro.text += fullTextRU;
yield return new WaitForSeconds(typingSpeed);
}
}
if (ua)
{
for (int i = 0; i < fullTextUA.Length; i++)
{
textMeshPro.text += fullTextUA;
yield return new WaitForSeconds(typingSpeed);
}
}
}
}
< /code>
First of all, yes, I am a beginner, but I don't think that I am doing anything crazy here (also I am working on the project for a year now, so I know something, but not so good with UI), yes, code is horrible, but it should work (GPT at least didn't find anything wrong with my scripts), and once again, there is nothing crazy complicated here, it is basic and simple.
What I tried, mostly worked with GPT, tried almost everything that he suggested (at least what made sense).
Turning off scripts helps, yes, just display the text, not a solution tho.
Change font, settings (hex), the problem is not there, because it would not show the text at all.
Change textMeshPro to legacy, no doesn't help.
Change the code I am using, didn't help, I did it several times, GPT checked it many times, it should work (there is almost nothing in the scripts).
Check for hidden characters, I am strongly convinced that the problem is not with the language I am using (whole point is to build a system where user can change language in the game) or with the scripts, it should be somewhere with how Unity handles UI logic but I have no idea what to check or change, as for my level I tried everything I know.
This is not everything I tried but a part of it, because I am fighting with this issues for days, and no result.
If there is anything not clear in my message, I will clarify it, or give you additional screenshots or anything.
At last I searched the internet but didn't find anything remotly similar to my problem.
Подробнее здесь: https://stackoverflow.com/questions/797 ... e-original
Единство. Копия холста не работает как оригинал ⇐ C#
Место общения программистов C#
-
Anonymous
1756043616
Anonymous
У меня есть холст, панель и некоторые текстовые элементы пользовательского интерфейса (несколько). На холсте у меня есть два простых сценария, которые просто включают и выключают элементы, в зависимости от времени (код в конце, прикрепленные скриншоты), в частности, сценарии включают и выключают текстовые элементы на панели. На панели ничего не изменилось. В текстовых элементах у меня есть сценарий, который очень простой, который типит в текстовой букве по букве (код в конце, прикрепленные скриншоты).
работает. Но если я возьму копию этого холста и помесчу его в другую сцену или в эту сцену (не имеет значения), он все равно будет «работать», но введет только первую букву из текста (код в конце, прикрепленные скриншоты). Если я скину каждый прикрепленный сценарий, он покажет текст. Мне очень сложно правильно описать эту проблему, так как у меня нет абсолютно понятия, почему она так работает, но, короче говоря, у меня есть холст, который показывает текстовую букву по букве, если я скопирую этот холст и использую его в другом месте, он будет вводить только на экране первой буквы текста. src = "https://i.sstatic.net/ke7ps6pb.png"/>
exaterOneWorkSfinePedIntext
/> exampleTwowHathAppensWithThecopy < /p>
< /p>
Панель
public class TriggerTime : MonoBehaviour
{
public GameObject myobject;
public GameObject lightEnemy;
public float timer;
void Start()
{
myobject.SetActive(true);
lightEnemy.SetActive(false);
StartCoroutine(TurnOn());
}
IEnumerator TurnOn()
{
yield return new WaitForSeconds(timer);
myobject.SetActive(false);
lightEnemy.SetActive(true);
}
}
< /code>
public class ThreeTimesThree : MonoBehaviour
{
public GameObject myobject;
public GameObject lightEnemy;
public GameObject objThree;
public GameObject objFour;
public float timer;
public float timerTwo;
public float timerThree;
void Start()
{
if (myobject != null)
myobject.SetActive(true);
if (lightEnemy != null)
lightEnemy.SetActive(false);
if (objThree != null)
objThree.SetActive(false);
if (objFour != null)
objFour.SetActive(false);
StartCoroutine(TurnOn());
StartCoroutine(TurnOnSecond());
StartCoroutine(TurnOnThird());
}
IEnumerator TurnOn()
{
yield return new WaitForSeconds(timer);
if (myobject != null)
myobject.SetActive(false);
if (lightEnemy != null)
lightEnemy.SetActive(true);
else
Debug.Log("lightEnemy not assigned");
}
IEnumerator TurnOnSecond()
{
yield return new WaitForSeconds(timerTwo);
if (lightEnemy != null)
lightEnemy.SetActive(false);
if (objThree != null)
objThree.SetActive(true);
else
Debug.Log("objThree not assigned");
}
IEnumerator TurnOnThird()
{
yield return new WaitForSeconds(timerThree);
if (objThree != null)
objThree.SetActive(false);
if (objFour != null)
objFour.SetActive(true);
else
Debug.Log("objFour not assigned");
}
}
< /code>
public class TypingEffect : MonoBehaviour
{
public TMP_Text textMeshPro;
[TextArea] public string inputText;
[TextArea] public string inputTextRU;
[TextArea] public string inputTextUA;
public float typingSpeed = 0.05f;
private string fullTextEN;
private string fullTextRU;
private string fullTextUA;
public bool ua;
public bool ru;
public bool en;
void Awake()
{
if (ua)
{
fullTextUA = inputTextUA.Normalize();
textMeshPro.text = "";
}
if (ru)
{
fullTextRU = inputTextRU.Normalize();
textMeshPro.text = "";
}
if (en)
{
fullTextEN = inputText.Normalize();
textMeshPro.text = "";
}
}
void Start()
{
StartCoroutine(TypeText());
}
IEnumerator TypeText()
{
if (en)
{
for (int i = 0; i < fullTextEN.Length; i++)
{
textMeshPro.text += fullTextEN[i];
yield return new WaitForSeconds(typingSpeed);
}
}
if (ru)
{
for (int i = 0; i < fullTextRU.Length; i++)
{
textMeshPro.text += fullTextRU[i];
yield return new WaitForSeconds(typingSpeed);
}
}
if (ua)
{
for (int i = 0; i < fullTextUA.Length; i++)
{
textMeshPro.text += fullTextUA[i];
yield return new WaitForSeconds(typingSpeed);
}
}
}
}
< /code>
First of all, yes, I am a beginner, but I don't think that I am doing anything crazy here (also I am working on the project for a year now, so I know something, but not so good with UI), yes, code is horrible, but it should work (GPT at least didn't find anything wrong with my scripts), and once again, there is nothing crazy complicated here, it is basic and simple.
What I tried, mostly worked with GPT, tried almost everything that he suggested (at least what made sense).
Turning off scripts helps, yes, just display the text, not a solution tho.
Change font, settings (hex), the problem is not there, because it would not show the text at all.
Change textMeshPro to legacy, no doesn't help.
Change the code I am using, didn't help, I did it several times, GPT checked it many times, it should work (there is almost nothing in the scripts).
Check for hidden characters, I am strongly convinced that the problem is not with the language I am using (whole point is to build a system where user can change language in the game) or with the scripts, it should be somewhere with how Unity handles UI logic but I have no idea what to check or change, as for my level I tried everything I know.
This is not everything I tried but a part of it, because I am fighting with this issues for days, and no result.
If there is anything not clear in my message, I will clarify it, or give you additional screenshots or anything.
At last I searched the internet but didn't find anything remotly similar to my problem.
Подробнее здесь: [url]https://stackoverflow.com/questions/79744900/unity-copy-of-the-canvas-doesnt-work-as-the-original[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия