107 questions
1
vote
0
answers
26
views
How to package prebuild library with prefab into a aar
I want to build a Android native library which contains a prebuild so files, for example librga. And package it to an aar. This aar should:
Contains librga.so and headers.
I write some jni interface ...
1
vote
1
answer
124
views
How can I ensure that all prefabs dragged from the assets to the scene are placed at (0, 0, 0) relative to their parent?
I have a handful of prefabs in my project's assets which I am frequently dragging into and out of the scene in order to test them sequentially after changing the code in their attached scripts. They ...
1
vote
2
answers
45
views
How do you spawn prefabs so they come 1 by 1 and that I can remove the bandit in the hierarchy?
I want to multiply my prefab (bandit) every few seconds, but if I remove my prefab in the hierarchy it is no longer spawned. I put this in my project view as prefab but this doesn't seem to work. The ...
0
votes
0
answers
61
views
Why are two objects from the same prefab, with the same scripts acting differently?
I'm developing a game like solitaire and all my cards are made from the same prefab. All cards in the tableau follow the exact same script but for some reason, the first card in the first tableau can ...
0
votes
1
answer
50
views
Why won't my UI buttons on screen character selection work? - prefab issue?
I am a beginner to Unity and I am trying to make a character selection for a local multiplayer game. Currently, I have my code and some buttons but when I run the code, new buttons appear stacked over ...
0
votes
0
answers
52
views
Placing a Prefab in Unity
So I am making a proceduraly generated dungeon, Ive got a algo that creates base of the dungeon out of cubes, it creates rooms, hallways and staircases. Once I had that I started to place prefabs on ...
1
vote
0
answers
1k
views
CXX1429: error when building with cmake using app\src\main\cpp\CMakeLists.txt: C++ build system [prefab] failed while executing
I was trying to build android vulkan app from this guide
Whenever I try to build, execution error occurred in
"app\build\intermediates\cxx\Debug\1k4v2e55\logs\arm64-v8a\prefab_command.bat" ...
0
votes
1
answer
81
views
Rotate a 3D Prefab around itself on its own any axis with a script
I am working in Unity (C#). I need help to rotate a 3D prefab around its own axis (be it the x or y axis). Prefab consists of 10 child objects. Its purpose is to make the Prefab rotate 90 degrees by ...
-1
votes
1
answer
614
views
Solution to 'Type Mismatch' error stopping me from assigning a GameObject to a prefab in Unity
Whenever I try to assign a GameObject or TMP Text Box to a prefab's public variable, I get an error message that says, "Type Mismatch". The variable is a list (used to be array) and I am not ...
1
vote
1
answer
235
views
How to keep prefab connections during play mode of prefabs in scene?
When I add prefabs to the scene, the instances lose their connection to the original prefabs in play mode.
Before play mode:
In Play mode:
If I instantiate them during runtime with PrefabUtility....
1
vote
0
answers
59
views
The associated script cannot be loaded
I created an asset using obi-rope and exported a unity package but when I imported it in a different project this error popped up!
I tried to re-create the unity package, and I noticed obi-rope is ...
1
vote
2
answers
314
views
Can I ignore a property in EqualsVerifier?
I have a class like this:
class Thing(val name: String) {
internal var complexObject: ComplexType? = null
override fun equals(other: Any?): Boolean {
return other is Thing && name == ...
0
votes
1
answer
201
views
How can I get override base of Prefab Variant in Unity?
How can I get Prefab Variant's "base" (Field named "Prefab" in picture) from Editor script?
I'm on Unity 2022.3, but UnityEditor.PrefabUtility seems do not have corresponding ...
1
vote
0
answers
408
views
How to Save Baked Lightmaps Within Prefabs in Unity
I'm working on a Unity project where I need to optimize performance by baking lightmaps for my prefabs (the prefabs should always look the same regardless of their position so there is no point in ...
0
votes
1
answer
49
views
3D House Prefab doesn't get transparent red or green whether it overlaps or not
I have a building placement project which doesn't work with 3D house objects. The objects all have rigidbody and box collider components while only the house prefab objects have child objects.
My ...
0
votes
2
answers
102
views
Trying to destroy prefab upon collision
I'm making a 3D Unity game and trying to get randomly-spawned prefabs disappear when they collide with the player object, but I'm not sure why it isn't working.
private void OnTriggerEnter(Collider ...
-1
votes
2
answers
104
views
How do I change the gravity of a prefab?
so basically I have a TargetSpawner which is simply a BoxCollider in the shape of a rectangle put on top of the screen which spawns little sushis (TargetPrefab) to shoot.
The little sushis are prefabs ...
0
votes
2
answers
62
views
Problem when it instanciates prefabs on Unity
I am not sure where I can post this thread because maybe the problem are about scripting, or maybe that is about modeling of tilemaps, or maybe that could be about the prefab configuration.
I have a ...
0
votes
1
answer
379
views
How to load a prefab with Resources.Load() in unity?
I've been trying to load pieces for a chess program which involves loading in a bunch of chess piece prefabs to load on the screen but for some reason it isn't working. Here's the code
white_pawn = (...
1
vote
0
answers
96
views
broken material and shader graph settings after I combined prefabs from different projects
So I made 3 different projects which contain contents of some meshes with materials, shader graphs, and set animation and keyframes using timeline. Then I export contents as one prefab for each ...
1
vote
1
answer
1k
views
Unity - getting the correct text size after Content Size Fitter
Please help, I can’t figure it out myself
I have a TextMeshPro Prefab
I wanted the height of the object to match the actual height of the text, so I added a Content Size Fitter component to the prefab ...
0
votes
1
answer
303
views
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 ...
0
votes
0
answers
339
views
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 ...
0
votes
0
answers
117
views
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. ...
1
vote
0
answers
221
views
How do I delete GameObjects in a prefab variant? (EditorCode)
I am currently working on a room editor.
The room is a base prefab with scripts.
It has a child transform with tiles, which is empty.
In my editor, I instantiate a base prefab room, and design ...
0
votes
1
answer
698
views
How to update all unity prefabs from the main one through c#?
I have a script that updates the Sprite Renderer of the main prefab (the one that is in Assets) but this does not change or update the Sprite Renderer of the instances of the main Prefab. How can I ...
2
votes
1
answer
749
views
How do I change a Unity prefab's sprite after instantiating it based on the data I input?
For context, I don't have much Unity and C# experience, so please don't berate me if the answer is really simple. I'm trying to make a dungeon's edge tiles automatically create walls on their ...
0
votes
2
answers
359
views
(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 = ...
-1
votes
1
answer
48
views
Calling an Int from another Script that lives on a Prefab
I'm super new to c# and I'm making a 3D game in Unity. I have an int that I want to call upon in another script, but the original script that the int is in, lives on a prefab that isn't on my terrain.
...
-2
votes
1
answer
51
views
How can I destroy a game object and instantiate a new prefab?
I am developing a game with Unity 2d, and I am trying to make the player disappear when it reaches the TorchSwordBool. I was successful doing so, but when I tried to instantiate a prefab for the ...
0
votes
0
answers
1k
views
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 ...
0
votes
1
answer
328
views
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. ...
1
vote
0
answers
199
views
A Enemy Prefab with two different hitboxes both detect and take damage from bullets in unity
I made a enemy prefab and a object to it (Field of View).
The enemy has a Box Collider 2D and a Rigidbody 2D, the FOV only has Box Collider 2D.
The enemy checks if a bullet is hitting him and takes ...
0
votes
2
answers
131
views
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 ...
0
votes
3
answers
791
views
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 ...
2
votes
1
answer
1k
views
I can't drag gameObject into prefab public variable
I have a bullet prefab in 2D unity and I want to drag a gameObject into a public variable so I can deal damage but it won't work. Here is my code, the gameObject I want to drag in is called EnemyAI ...
0
votes
2
answers
349
views
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 ...
0
votes
1
answer
536
views
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 ...
0
votes
1
answer
49
views
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. ...
1
vote
1
answer
1k
views
Dependencies between Android native modules (prefab) fail to build
Our Android application consists of 40-some Android Library Modules (ALMs), each of which also builds a C++ shared library with externalNativeBuild and CMake. So far we had the dependencies between ...
-1
votes
1
answer
79
views
Instantiating prefabs in a random location picked from a specified set of locations in unity c#
Prefabs
Locations
HI, I was wondering, how could I instantiate one prefab (from an array/list) under one of the random red squares! Please help me
1
vote
1
answer
366
views
Unity Add callbacks to prefab objects dynamically in code
I am creating a canvas with a table containing TextmeshPro Input fields on a row. I'm using the XR Input System for the Oculus Quest Vr Headset and wish to handle input from the controllers so they ...
1
vote
3
answers
2k
views
How to reference camera in prefab script in Unity 2D?
I have created a player prefab (called Tim in my project) and am trying to make all the references to gameObjects and transforms directly from the one of the players scripts which is actually attached ...
1
vote
0
answers
51
views
Layer or hierarchy problem for GameObject
In my Unity project, I made a prefab to rendering images from web sources by URL. However, when testing the app, it displayed the images like this:
There are two image windows, but you can see, the ...
0
votes
1
answer
423
views
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 ...
0
votes
0
answers
247
views
How to duplicate, reuse, and dispose of dynamically generated addressable objects
How do I load an addressable AssetReference dynamically, like a crate or something, via LoadAssetAsync and then reuse it throughout my game without calling LoadAssetAsync again?
I am generating a ...
0
votes
2
answers
370
views
Disable Child Element of a Prefab with Script
I have just started to learn Unity 2d and I have taken a task at hand where I want to Instantiate a Prefab from Assets folder and then disable some of the child elements in it once the prefab is ...
-2
votes
1
answer
702
views
Problem with building unity project and exporting to ios project
I'm not a unity specialist, I'm doing ios development. But I need to build and export the unity model to my project. In the unit itself, I see a mozhel, it is animated, that is, everything seems to ...
1
vote
0
answers
1k
views
Prefabs not visible in unity scene
I bought an asset from unity store and installed XR interaction toolkit therein. Everything works fine. When I drag prefabs from another asset into the scene and deploy it into oculus quest 2, these ...
0
votes
0
answers
289
views
OnMouseDown in prefab not working with some scene
I have prefab enemyRangeAttack and then I add this code for enemy (child of enemyRangeAttack)
public class Selectable : MonoBehaviour{
[HideInInspector] public GameObject Player;
public float range = ...