Search Unity

Character creation question

Discussion in 'Scripting' started by gudula, May 25, 2015.

  1. gudula

    gudula

    Joined:
    May 20, 2015
    Posts:
    125
    Hi

    I would like to have a character creation system on my scene. Im trying to figure out how I can have this dynamic while starting the game.
    I know in c# you can create objects with C#
    GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
    How can I do something like this with C# but to load an external character from my harddrive?
    ie. I would like to load meshes/pbx in the game from another directory. How can that be achieved?
     
  2. krougeau

    krougeau

    Joined:
    Jul 1, 2012
    Posts:
    456
    Is there any particular reason that you need to pull them from other directories on your hard drive? I think it would be more efficient and practical to import your models into Unity directly. Once you have them imported, you can create prefabs of them which can be instantiated as needed through scripting, or dragged directly into your scenes.
     
  3. sluice

    sluice

    Joined:
    Jan 31, 2014
    Posts:
    416
    By putting them in your resource folder, you can load meshes with
    Code (csharp):
    1. Resources.Load()
    .
    Alternatively, you could look into AssetBundles (much better...)

    But, still it would be much easier to have everything imported in Unity and make prefabs.
    Why would you want to load them externally, anyway?
     
    krougeau likes this.
  4. gudula

    gudula

    Joined:
    May 20, 2015
    Posts:
    125
    I would like to create a game that can be expanded in future to buy maybe more guns from a shop that has new fbx model. This way I dont have to recompile the game and make people download it. Is this possible with Unity3d? If so Im really interested.
    There is something called WWW.LoadFromCacheOrDownload which looks like it can do something but Im not sure how to handle pbx files and prefabs with this.
     
  5. sluice

    sluice

    Joined:
    Jan 31, 2014
    Posts:
    416
    krougeau likes this.
  6. gudula

    gudula

    Joined:
    May 20, 2015
    Posts:
    125
    Thanks