Skip to main content
OverflowAI is here! AI power for your Stack Overflow for Teams knowledge community. Learn more

Questions tagged [prefabs]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
0 answers
26 views

Is there a way to rename prefab in unity by cuting a specific part of the name?

I have a lot of old prefabs in unity that should get renamed, doing this by hand would take a while. I there a way to cut the names and save them. I would like it to go from cutpart_2_goodpart to ...
Ivan's user avatar
  • 337
1 vote
1 answer
41 views

Instantiate prefab behind moving player

I'm trying to instantiate a bomb prefab behind the player. The script below works fine when the y rotation is 0,90,180,360. The bomb is instantiated behind the player. But for other angles, the bomb ...
single arrow games's user avatar
0 votes
0 answers
58 views

Getting missing prefab error in unity

Getting the following error while loading a project on unity. I'm usung ubuntu
Vamsi Shankar's user avatar
1 vote
2 answers
258 views

How can I solve this error and this warning when destroying instantiated prefabs?

I'm working on a level in a 2D game that includes two big triggers. Each time the player enters them, I Instantiate an enemy prefab. Then, the player can shoot ...
Ali's user avatar
  • 55
0 votes
1 answer
188 views

Why can't I edit the rotation property in prefab mode so that rotation changes apply to all instances?

I am learning using the Explore Unity Course. In the picture you can see I've instantiated many hats from the same prefab. I want to rotate the hat in prefab mode so that the change will apply to all ...
MoonMoonBird's user avatar
0 votes
0 answers
75 views

Spawn prefabs in a vertical stack with a fixed gap

I am making a simple game with a ball that moves left and right when it hits a wall. I want the game to be like an arcade type game where the ball is on a platform and it keeps jumping up. I've ...
Abraham Titus's user avatar
0 votes
1 answer
55 views

How do I Instantiate a player prefab

I turned my player into a prefab for a endless runner game but how would i instatiate it so that the player is in the scene when the game starts without it currertly being on a seprate platform that ...
charlie's user avatar
  • 11
1 vote
1 answer
365 views

Destroy and instantiate player prefab

I am new to game development. I am trying to change the player prefab every X seconds. For that, I am destroying the previously spawned prefab and instantiating a new prefab. But I don't know how to ...
Vishu Mudgal's user avatar
0 votes
1 answer
28 views

Assigning references to Prefabs placed in each Scene

I am currently working on a small 2D game which has a few different scenes, which are each a different level. I want to use my object prefabs from one scene in the others, but these do not include ...
Jack Johnson's user avatar
0 votes
0 answers
84 views

Initializing prefabs with different scripts

I am creating a tower defense game. Currently I have 2 different tower types 'Shooting tower', amd 'Unit tower'. I have a Scriptable object to initialize the tower. It contains some tower properties ...
Taras Fityo's user avatar
0 votes
1 answer
35 views

I can only access the latest instantiated clone. The script only works with the latest instance

I tried to implement a way of attacking. Fire the spear, then retract it. Just like Thor's hammer. But when I fire multiple spears, I can only retract the latest fired one. I don't know what the ...
YOUNG ETHAN's user avatar
0 votes
0 answers
111 views

AddListener to Button in Prefab

I created a prefab called MapNode and have MapGenerator instantiate a bunch of them at runtime. I want to make the each instance ...
qjk's user avatar
  • 1
0 votes
1 answer
87 views

When are the resources used by a prefab loaded?

For example, I have a scene. The scene has a GameObject. The GameObject has reference to a prefab, like this: ...
Kodra's user avatar
  • 23
0 votes
1 answer
160 views

Changes to in-game object affect prefab

I've created a prefab of a stick object, the stick scales as in a mobile game stick hero, the thing is I want to instantiate the prefab, but the already instantiated stick somehow affects the prefab ...
koogel's user avatar
  • 79
0 votes
1 answer
215 views

Is it possible to mark a Unity prefab variant as deprecated?

I'm building a game at the moment and a classic issue has come up, of having a complicated prefab variant in use, which happens to have a fundamental problem in its design and needs to be replaced. ...
Michael Macha's user avatar
1 vote
1 answer
833 views

How to get data from a Scriptable Object into a Prefab template

I made a Unity Prefab where about 5 things vary. I then made an invisible GameObject where I use Visual Scripting to hardwire the 5 differing items, in order to create the various GameObjects I need. ...
kanamekun's user avatar
  • 369
0 votes
1 answer
158 views

Testing if instantiated prefab is colliding with environment

I'm trying to generate a number of prefabs in a scene where that scene will have procedurally-generated terrain objects. I have tagged each of the terrain objects with ...
erik's user avatar
  • 1,378
0 votes
0 answers
247 views

Unity Prefab icons displayed wrong

Occasionally the prefab icons are displayed wrong. It either displays another icons preview, lets say "Side_Panel_4" displays "Side_Panel_1" icon. Or like the example bellow it ...
theCodeHermit's user avatar
0 votes
1 answer
367 views

Why do I get "the object you want to instantiate is null" when I can see the prefab reference in the Inspector?

I read the solution in this post but still not able to understand it. I have a script (AdvanceWayPoint) attached to a game object ("Cube", with tag "...
chuackt's user avatar
  • 253
0 votes
2 answers
441 views

prefabs not aligned at same horizantal level after instantiating

I have generated a logical grid and trying to place a prefab on top of that grid. Piece is the base class for all pieces Pieces[]...
pavanjoshi914's user avatar
0 votes
1 answer
246 views

How can I cache and read fields on non instantiated prefabs?

Let's say I have a very simple 2D square prefab that has a script like this attached to it: ...
Ginger and Lavender's user avatar
0 votes
1 answer
1k views

Custom inspector values in prefab mode not save to prefab

I have a prefab with a custom GridModel component which has a custom editor. For some reason whenever I edit a value in Prefab Mode, the value doesn't save in the ...
FlorisdG's user avatar
  • 181
-2 votes
1 answer
2k views

How to randomly spawn prefabs on the X axis?

I created an infinite runner game. I need to make random spawning obstacles in 3D. How do I randomly spawn prefabs on the X axis using a C# script?
Саша Ростягай's user avatar
0 votes
1 answer
312 views

How could I put a prefab into a field of a game object using editor API in Unity?

How could I put a prefab into a field of a game object using editor API in Unity? I have a game object. It has a GameObject field. I can drag and drop a prefab from ...
qqqqqqq's user avatar
  • 278
0 votes
2 answers
566 views

If I create a prefab out of an object on scene will my game take more memory in Unity?

If I create a prefab out of an object on scene will my game take more memory in Unity? I have 30 enemies on my scene. I created a prefab for every one of them. I am going to use each of the created ...
qqqqqqq's user avatar
  • 278
0 votes
1 answer
175 views

How to pre-configure a prefab in the editor for multiple similar buttons before instantiating them

Let me explain my problem with my concrete example. I have a button prefab. A button prefab has a lot of configurations: background color, background shape, background image, text, text color, button ...
qqqqqqq's user avatar
  • 278
0 votes
1 answer
468 views

Optimal Way to Create Card Templates in Unity 2D

I have a couple questions involving software architecture and best practices in Unity. Although I have some programming knowledge, I am just starting with Unity and C#, and I would like some input ...
Gergely Kovacs's user avatar
0 votes
1 answer
183 views

How to make an upgrade a building and replace it with the Level 2 prefab?

I want to to have multiple prefabs like canon level 1 and then level 2. When the player has enough coins, they can upgrade it to level 2. I want to make a game similar to Clash of Clans so I will have ...
elliot727's user avatar
0 votes
1 answer
2k views

How to correctly instantiate prefab in Unity

I made a prefab and drag drop it to the Tile Prefab slot as shown in the picture In my code ...
Dew's user avatar
  • 137
0 votes
1 answer
86 views

can't instantiate different objects

I'm trying to instantiate different prefabs at once. But couldn't figure out how. I tried to use Random.Range method but didn't worked for me. It instantiates only one of the prefabs. I want it to ...
Sarp Alemdar's user avatar
0 votes
0 answers
312 views

How can I make a health bar — a UI element — part of a character prefab?

Description I want my character prefabs to come with their own health bar, but I can't simply add one as part of the prefab, because it's a UI element and therefore goes into a Canvas. Potential ...
verified_tinker's user avatar
0 votes
1 answer
280 views

Prefab not working when I import maps form Tiled using Tiled2Unity

I have correctly created the map using Tiled with no errors or warnings, then i imported the package from tiled2unity, imported the map then waited few seconds and the prefab from tiled2unity appears ...
RODOR's user avatar
  • 5
1 vote
1 answer
3k views

Unity: how do I get a list of prefab tiles from the TileMap?

I'm building a 2D strategy game where I've decided to use TileMap for spaces which characters can traverse. My tiles need to be prefabs, because they will have a script attached to them to store ...
Josh Sanders's user avatar
0 votes
1 answer
977 views

Unity: Sprite stretch issue

I have a simple png square 8px x 8px. In Unity I've left the pixels per unit at 100 and added the image to the scene to create a prefab of the item. I then add four items to the screen like so: ...
Tikeb's user avatar
  • 103
0 votes
1 answer
2k views

Check if 2 objects with multiple colliders overlap using bounds

I'm writing a script which instantiates buildings in a scene, but in such a way that 2 buildings don't overlap with each other. Every building consists of approx. 10 parts, of which each has a box ...
Thrindil's user avatar
-1 votes
1 answer
56 views

NullReferenceException when translating instantiated prefab [duplicate]

I keep getting this error: NullReferenceException: Object reference not set to an instance of an object moveBlock.Update () (at Assets/Scripts/moveBlock.cs:27) whenever I press Play in Game or when ...
mavish's user avatar
  • 151
0 votes
0 answers
318 views

I have 240 prefabs to scatter, what is the best way to achieve this?

I'm creating a huge city for which I've made 240 different building prefabs. Now I need to scatter those prefabs randomly with a height, width and depth and rotation randomness variation. I thought ...
Thrindil's user avatar
0 votes
1 answer
708 views

Unity hangs when saving prefab asset

For game saving purposes, I'm keeping track of references to ScriptableObjects through a lookup table, so that I can serialize/deserialize using the SO's position in that table. I have a lot of ...
crass_sandwich's user avatar
0 votes
1 answer
402 views

Using Part of prefab as script parameter

I'm trying add a weapon to Eithan - the third person character. So I want to take his hand, which is part of the prefab Eithan (the weapon location) and use it in the my Player.cs script to ...
roni's user avatar
  • 3
0 votes
0 answers
135 views

Prefabs scaling change also the original prefab

I want to work with a prefab as local and global variable? something like that. So my question is how to change a prefab scale without affecting the original prefab.
khalid mokhliss's user avatar
0 votes
1 answer
182 views

Unity 3D platform spawning problems

I'm making an infinite runner game in Unity 3D. I have it so that platforms spawn and move backwards toward the player and they are destroyed once past the player. Over time when the platforms are ...
Matheson's user avatar
0 votes
1 answer
226 views

Unity: How can I control a Shadergraph effect on multiple enemies with the same prefab?

So I made a simple White Flash -> Dissolve effect with shader graph 2D, it's my 1st time using shaders. I'm controlling the effect using a float inside the shader, with: ...
Alon Talmi's user avatar
0 votes
1 answer
27 views

List to hold copies of a prefab for later deletion

I'm working on a game in which obstacles are Instantiated randomly 5 to 20 units ahead of the player. When they are instantiated, I want to add them to a list so that when there are too many ...
1234567890's user avatar
0 votes
2 answers
2k views

Unity: I need to edit my prefab but I can't move anything inside it!

I imported a character into Unity and turned him into a prefab. I couldn't get my custom "Look-At" script to work for the eyes, which are children of the prefab I imported. So I opened the prefab and ...
hatinacat2000's user avatar
2 votes
1 answer
2k views

If I don't use PrefabUtility class, how can I save my changed prefabs and build without exception?

I'm designing a racing game for my graduation project. I used PrefabUtility.SaveAsPrefabAsset to save my color change on the car prefabs, I finished the codes and it work well in Unity, but when I ...
KatElectric's user avatar
0 votes
1 answer
179 views

How to make collisions occur between objects using the same script?

Well what I’m trying to do is have cars travelling on the road. The cars have a trigger at the front and a hitbox at the back of the cars. What I want to happen is when the trigger hits the hitbox it ...
MrZeeIndo's user avatar
1 vote
1 answer
3k views

Instantiating Prefabs at run time

I'm trying to move my project to Addressables and upload assets, prefabs and screens to an archive on the server. I'm a new in Unity and this a bit challenging for me. I've prepared all prefabs for ...
Atlantis's user avatar
  • 113
0 votes
1 answer
155 views

How to store the configuration of Unity prefab components during map generation?

I managed to have a basic map generation algorhytm, but now it needs some content. I generate abstract map data, which then will be used to build the map itself. When I want to generate monsters, ...
Tudvari's user avatar
  • 751
1 vote
1 answer
851 views

How can I insert a prefab instance programmatically inside the Canvas, in the bottom-left corner of the Canvas?

I am trying to create the Snake game in Unity, based on this video tutorial. I have also viewed this tutorial. I have created the new project with the 3D template and manually added the Canvas. I ...
silviubogan's user avatar
-1 votes
1 answer
93 views

How to translate prefab made of hierarchy of 3d objects

I am trying to translate a prefab of a puzzle piece made of a hierarchy of cubes but it's not working. I have tried translating the GameObject using its transform and the function Translate, it did ...
Hermetix's user avatar
  • 507