Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Accented character in file name isn't showing in Prefab!?

Discussion in 'Scripting' started by Slyrfecso1, Sep 10, 2015.

  1. Slyrfecso1

    Slyrfecso1

    Joined:
    Jul 16, 2012
    Posts:
    100
    Hi,

    I have a lot of prefab with accented character in name.
    I'm importing them to inventory list.
    If the name of file has "Ü" , then Unity can't load the images or prefabs.
    I don't understand why, because everywhere else is correct this character.



    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using System.Text.RegularExpressions;
    4. using System.Text;
    5.  
    6.  
    7. [System.Serializable]
    8. public class Item {
    9.  
    10.     public string itemName;
    11.     public int itemID;
    12.     public string itemDesc;
    13.     public Texture2D itemIcon;
    14.     public ItemType itemType;
    15.     public GameObject itemPrefab;
    16.  
    17.     public enum ItemType {
    18.         Comfort,
    19.         Stark,
    20.         AlexStandard,
    21.         Targyalo,
    22.         PlusszTermekek,
    23.         Szekreny,
    24.         Szekek
    25.     }
    26.  
    27.  
    28.     public Item(string name, int id, string desc, ItemType type)
    29.     {
    30.  
    31.         itemName = name;
    32.         itemID = id;
    33.         itemDesc = desc;
    34.        itemIcon = Resources.Load<Texture2D> ("Item Icons/" + name + "_ICON");
    35.         itemPrefab = Resources.Load ("Prefabs/"+name) as GameObject;
    36.         itemType = type;
    37.  
    38.  
    39.     }
    40.     public Item()
    41.     {
    42.  
    43.     }
    44. }


     
    Last edited: Sep 11, 2015
  2. Slyrfecso1

    Slyrfecso1

    Joined:
    Jul 16, 2012
    Posts:
    100
  3. Slyrfecso1

    Slyrfecso1

    Joined:
    Jul 16, 2012
    Posts:
    100
    I have solved that, but it is madness...
    I added more than 100 lines in my Inventory script.
    If I attached the ICONs manualy in Inspector, then Unity can use the accented files,
    but when I try to load them automaticly with folder path, then Unity can't see them.
    Why?????

    This is my solution:
    Code (CSharp):
    1. public Texture2D newIcon501; //AS-8.6
    2. ...
    3. inventory19[21].itemIcon = newIcon501;
     
    Last edited: Sep 12, 2015
  4. Slyrfecso1

    Slyrfecso1

    Joined:
    Jul 16, 2012
    Posts:
    100
    One more new idea:

    Before I save the name of the object then I replace the Ü to U.
    AllgameObjectsSave.name = AllgameObjectsSave.name.Replace("Ü","U").Trim();


    When I load the object then I replace the U to Ü.
    spawnedObject.name = spawnedObject.name.Replace("U","Ü").Trim();