Questions tagged [unity-components]

Components are scripts added to a GameObject in Unity3d.

In Unity you can create GameObjects in a scene and attach scripts to them that include game logic and extend MonoBehaviour. A script is written in C#, javascript or boo and becomes a component when attached to a GameObject.

44 questions
1
vote
1 answer

How to Parse JSON Response of the wp login response in unity

I am able to post User credentials to word press API end point and validate the login credentials and it gives me back a JSON as show below , how should I parse this JSON object in the data to get the value of ID from the following JSON Response …
1
vote
3 answers

I cannot access a component from its own gameobject (unity3d)

I want to access the HorizontalAxis variable from the CarAgent component (of the Taxi gameobject). It works fine when I try to access it from another gameobject, but when I try to access it in CarUserControl, which is also a Taxi component, it says…
Vincent Quirion
  • 389
  • 2
  • 4
  • 16
1
vote
1 answer

Unity prefabs acting differently based on whether dragging them into the scene statically or having them dynamically generated by code

If I instantiate a prefab like so: GameObject asteroid = GameObject.Instantiate(thing2spawn); //then set the location and some other stuff The prefabbed asteroid's collisions do not register at all, but If I simply drag the asteroid into the scene,…
1
vote
2 answers

Instantiating a image as a child of a canvas in Unity 5.3

I'm trying to instantiate an Image as a child of a canvas element. This code is attached to the Unity Canvas that i want to have as the parent. Image Pokal = GameObject.Instantiate(Resources.Load("Pokal")) as Image; if (Pokal != null) …
1
vote
1 answer

Unity streaming WWW issue

I'm using WWW Unity class to get songs from S3 Bucket. The issue is this, when I'm loading one song, the streaming works great, I'm getting a big enough buffer and able to play a song easily with AudioSource Clip. The problem starts when I try to…
Dagan Bog-Computers
  • 598
  • 1
  • 5
  • 16
1
vote
2 answers

OnTriggerEnter2d unity not working

I'm new on using Unity, and I'm trying to use a sprite as a collision trigger. But my OnTriggerEnter2d won't trigger. Here are the infos: main character info collision sprite used as trigger info And code for the newPlatformRow script attached…
TBogdan
  • 737
  • 7
  • 17
  • 34
1
vote
1 answer

unity3d replacing objects with prefabs in scene during editing

I was developing a 2d game. I have 8 maps. Maps are made from "wall" gameObject (I duplicated or copied them, yeah that was bad idea, and it's my first big, normal project). Now I need to change all of these "wall" component settings. I though I…
1
vote
1 answer

Turning off a script from a script in Unity

I need to turn off a script from another script in Unity. The script is in C# and the script I am turning off is in JS. Both scripts are attached to the same object. The error I am receiving says that there is no such thing as enabled. Any thoughts?…
1
vote
0 answers

Decoupling components in Unity that share data

I have been redesigning all my entities in Unity in the hopes that they will be more modulated and the components will be less dependent on each other. However, I have run into problems that I can't seem to get around. If I have two script…
Ben
  • 1,816
  • 1
  • 20
  • 29
1
vote
1 answer

Unity3D Running A Script Inside Another Script

This has been driving me crazy and I have been at this with no luck for hours. All I want to do is run one of my scripts from another script. Both scripts are attached to the same game object. Here's the script I want to use to run the other…
iEpic
  • 95
  • 2
  • 12
1
vote
1 answer

Unity3D. How to construct components programmatically

I'm new to unity and am having a bit of trouble getting my head around the architecture. Lets say I have a C# script component called 'component A'. I'd like component A to have an array of 100 other components of type 'component B'. How do I…
Guye Incognito
  • 2,726
  • 6
  • 38
  • 72
0
votes
0 answers

Is there a way to make every other row of a Grid Layout Group "indented"? (Unity 2D)

I am creating a health/stamina system in my Unity 2D game project, and I am trying to create a custom layout using the built in Grid/Horizontal/Vertical Layout Group components. The layout I am aiming to achieve will look similar to this…
0
votes
0 answers

Accessing added component, inside of another added component through a method at Start causes NullReferenceException

I have renamed the Classes and simplified the content for this post. Both level2 and spriteRenderer are visible in the inspector after hitting start, but spriteRenderer doesn't seem to be loaded when the fill method is called. After checking with…
0
votes
0 answers

How to stop Screen Space Overlay canvas from blocking UI button presses on World Space canvas?

I'm using Unity 2022.1.23f1 and the Universal Render Pipeline. I have a render texture, set to 480x270 with point filtering, to get a cool pixelated effect. In my scenes, I output the camera into the pixelated render texture and render it in a raw…
Pietu
  • 1
0
votes
1 answer

Is it possible to move a 3D object using the position of hand obtained from camera UNITY?

[![enter image description here][1]][1]I want to create a unity program where I'm able to provide a 3D model of the hand on the screen based on the input from a camera. I'm using HandPoseBarracuda for detecting and obtaining the position of the hand…