Questions tagged [prefab]
92 questions
0
votes
1 answer
How to export GUI items from Unity
I purchased a UI asset from the Unity Asset Store, which includes buttons and icons organized as prefabs. I would like to extract these elements as images to edit them in Photoshop. How can I accomplish this?
I want to open this asset in Photoshop…

Sayu Sfp
- 1
0
votes
0 answers
transform.root returning wrong object Unity
I have a button that's instantiated as a child of a prefab, when using transform.root it does not return the desired object.
GameObject parentObj = this.transform.root.gameObject;
that is the line in question
I have used Debug.Log to verify that,…

Splosh
- 1
- 1
0
votes
0 answers
Unity 2D Platformer: Jump animation breaks when Player Object turned into a Prefab. Any solutions?
I'm currently working on a 2D Platformer in Unity. I followed along Brackeys Tutorials (will post links below) and everything works like intended, except when I turn my Player Object into a prefab. Then suddenly my Jump Animation breaks for some…

Yeriwen
- 1
- 1
0
votes
2 answers
(Unity) Spawning random prefabs with none of them being identical
I want to spawn random prefabs, but I don't want to have any of them coincidentally be identical. I currently have this code block:
int animalIndex = Random.Range(0, 8);
int animalIndex2 = Random.Range(0, 8);
int animalIndex3=…

f0rCE
- 1
- 2
0
votes
0 answers
Unity - UI Image unable to change material colour, changes all instances
Title says it all, I've looked online for multiple solutions.
I'm instantiating a Prefab multiple times for my UI, I'm trying to set the child of this prefabs Image components Materials Colour (what a chain of words), and its resulting in them all…

Anthony Brown
- 1
- 1
0
votes
1 answer
Are there any disadvantages to Gradle Prefab AARs?
I'm primarily an Android Java developer, but I have a need for libyuv. I created a module and have it building under CMake. I read about prefab, and for developers like me this is a game changer. As such, I want to share my module as a prefab. I…

Dustin
- 2,064
- 1
- 16
- 12
0
votes
2 answers
How to reference a variable from another script in a prefab? (beginner question)
I have a game where the player speeds up overtime, and shoots projectile bullets. I want the bullets to stay at the same speed relative to the player. So i have to reference the speed variable in the players script.
there is a similar situation i…

BounteousLark
- 9
- 2
0
votes
3 answers
Where to initialize a private variable in Unity C# that requires access to scene hierarchy
I have a "Manager" type class called PlayerManager and I'd like to initialize an object for it in a different class/object using FindObjectOfType(). My understanding is that this searches the current scene hierarchy to find an object that has this…

Fotis Aronis
- 78
- 9
0
votes
0 answers
How to add a toggle to the prefab, but for each object it will work separately in Unity 2d
I'm making 2D game in Unity and I wanted to create a toggle inside the prefab. I have a map, and on it there are markers. When clicked, they show a specific information about this place, like name or description. All of this works fine. However, I…

Joanna
- 1
0
votes
2 answers
Unity Prefab Child set coordinates to x=0 y=0
I have a problem.
I have created a prefab in unity that has a child. I want to place this child on the position x=0, y=0 of the canvas, but it is always positioned on the centre of the parent. How can I move it (with code if possible) to the…

opaotti
- 1
0
votes
1 answer
Prefab values resetting during runtime
I have a prefab Block. In my scene hierarchy, there is a lot of Blocks:
The prefab contains a code that contains an integer value called id.
I wrote a script (to run in edit mode) that sets random values to the id of all blocks and it works well,…

Daniel
- 7,357
- 7
- 32
- 84
0
votes
1 answer
How to interact with prefab instance independetly to other its instances?
I am new in C# and Unity3D and I'm struggle using events so I need HELP.
So I'm making hypercasual game to improve my skills. In the game I want if player hits an item to different things happened. For example: triggering bomb collider will destroy…
0
votes
0 answers
Is it possible to destroy a prefab with code from another prefab?
I have a frog in my 2d game. It has an attack where it sticks its tongue out. I didn't make an animation for this, I made tongue fragment prefabs that spawn one after another. They obviously start at the frog's mouth. I want to make it look somewhat…
0
votes
0 answers
How to make Android Studio aware of source code directory for prefab-published .AAR libraries?
Using Android Studio Electric Eel, AGP 7.5, NDK r23 and prefab. In my local Maven repository, I have a precompiled .AAR with some prefab-published static libraries. I.e. the .AAR contains both .a and .h files.
In my native app (using NDK-build, not…

l33t
- 18,692
- 16
- 103
- 180
0
votes
1 answer
Unity instantiate object at a certain direction based of a spatial anchor
Having a spatial anchor as a reference point, I wanted to create an object that does not change its location that reference to the spatial anchor.
When creating and saving the initial location of the object that will be spawned later using prefab. I…

4ndyg0h
- 1
- 1