Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question about "Toon City People" asset...

Discussion in 'Prefabs' started by Chief_Ed, Nov 8, 2021.

  1. Chief_Ed

    Chief_Ed

    Joined:
    Jul 7, 2013
    Posts:
    4
    Hello,
    I am looking for a little help with the programming of the Toon City People (TCP).

    I have reached out to SICS Games (publisher of TCP), and was told they could not help me with C# access to the asset.

    I am working on a simulation, and have a few questions. Can someone help me (or do you know WHO might know) how to instantiate these prefabs and programatically change some of their parameters? I can do this flawlessly at develop-time, but need to do this at runtime.

    Thanks for any assistance you can give!

    Fire Chief Ed Raposo (ret)
     
  2. Peter_Olsted

    Peter_Olsted

    Unity Technologies

    Joined:
    Apr 19, 2021
    Posts:
    74
    There are two ways to instantiate these assets. In the editor, it's prefered to use PrefabUtility.InstantiatePrefab(...) as it retains the connection to the prefab.

    However in runtime, PrefabUtility doesn't exist and you have to use
    Object.Instantiate(...) instead. This doesn't retain the prefab connection, but that is fine as in runtime (a build) you cannot modify assets anyway.
     
    Last edited: Nov 10, 2021
  3. Chief_Ed

    Chief_Ed

    Joined:
    Jul 7, 2013
    Posts:
    4
    Thank you Peter, let me see how far that takes me...
     
  4. Chief_Ed

    Chief_Ed

    Joined:
    Jul 7, 2013
    Posts:
    4
    Question about PREFABS
    - I have one prefab asset assigned to a "blank" Game Object. Is there a way to assign a different prefab to the Game Object at runtime or do I need to create multiple Game Objects for each of the prefabs and disable them until I need that particular base-prefab? Seems like a waste of resources to me since I have 23 different prefabs...

    Thanks!