I'm a beginner using c # in unity.
I want to make a wall that flows from right to left every few seconds.
Error message
UnassignedReferenceException: The variable graywall of RepetitionWall has not been assigned.
You probably need to assign the graywall variable of the RepetitionWall script in the inspector.
UnityEngine.Object.Instantiate [T] (T original) (at C: /buildslave/unity/build/Runtime/Export/Scripting/UnityEngineObject.bindings.cs:266)
RepetitionWall.Update () (at Assets/script/RepetitionWall.cs: 23)
c #
Source code
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RepetitionWall: MonoBehaviour
{
public float intervalMin, intervalMax;
public float instanceTime;
public GameObject graywall;
// Start is called before the first frame update
void Start ()
{
}
// Update is called once per frame
void Update ()
{
if (instanceTime<= 0)
{
GameObject newwall = Instantiate (graywall);
newwall.transform.position = transform.position;
instanceTime = Random.Range (intervalMin, intervalMax);
}
else else
{
instanceTime-= Time.deltaTime;
}
}
}
What I triedI didn't know what to try.
Supplementary information (FW/tool version, etc.)Please provide more detailed information here.
-
Answer # 1
Related articles
- c # - player production in unity (shooting game)
- c # - unity 202010f1 + oculusrift hmd position tracking is not reflected in the game
- unity c # php json array passing
- unity c # error code indexoutofrangeexception: index was outside the bounds of the array
- [unity c #] i don't know the code to operate with float h by specifying gameobject
- c # - unity) show/hide prefab button conditionally
- c # - unity) video thumbnails
- i want the button to proceed to the next in unity to appear when the game clear is displayed in the ui
- c # - about unity ads test ad display
- c # - [unity ray cast] execute the function of the object that received the ray
- about programming basics unity c #
- c # - unity) i want to get the image size in prefab
- c # - [unity 2d] i want to create a gimmick that clings to a rope, hangs, swings like a pendulum, and jumps
- c # - about player prefs for unity
- [unity c #] how to completely stop walking when switching panels
- how to use tolist (): and linq;in unity c #
- [c # unity] how to set arrey or dictionary in scriptableobject?
- c # - when controlling ui in unity, there are times when you can access an instance of an object and times when you cannot
- c # - how to autorun after burning unity to dvd
- c # - player production in unity (shooting game)
- c # - please tell me how to use the additional components of unity's volunteer production
- c # - conversion from enum type to enum type
- c # - missingreferenceexception occurs even though there is a reference
- c # - i want to update the value
- c # - i want the camera to follow the player character in a tps game, but if i make multiple players in multiplayer, the camera
- c # - [unity] even though "has exit time" of animator is specified, it will transition to another state earlier than t
- c # - == becomes false even though the strings are equal
- c # - how to use start () in unity
- c # - in a script? error cs1056: unexpected character'?' is displayed even though there is no
An unnecessary script was associated with the prefabricated object, and the object was not specified in the place where the object of the script was specified.
I solved it by deleting the script.