UnityEngine. UIElements. UIR. RenderChain. Render (UnityEngine. The Rect viewport, UnityEngine. Matrix4x4 the projection, UnityEngine. UIElements. PanelClearFlags clearFlags) (at & lt; Ba477b09073148948adef3d3e1503d12 & gt; : 0)
UnityEngine. UIElements. UIRRepaintUpdater. DrawChain (UnityEngine. The Rect viewport, UnityEngine. Matrix4x4 the projection) (at & lt; Ba477b09073148948adef3d3e1503d12 & gt; : 0)
UnityEngine. UIElements. UIRRepaintUpdater. The Update () (at & lt; Ba477b09073148948adef3d3e1503d12 & gt; : 0)
UnityEngine. UIElements. VisualTreeUpdater. UpdateVisualTreePhase (UnityEngine. UIElements. VisualTreeUpdatePhase phase) (at & lt; Ba477b09073148948adef3d3e1503d12 & gt; : 0)
UnityEngine. UIElements. Panel. UpdateForRepaint () (at & lt; Ba477b09073148948adef3d3e1503d12 & gt; : 0)
UnityEngine. UIElements. Panel. Repaint (UnityEngine. Event e) (at & lt; Ba477b09073148948adef3d3e1503d12 & gt; : 0)
UnityEngine. UIElements. UIElementsUtility. DoDispatch (UnityEngine. UIElements. BaseVisualElementPanel panel) (at & lt; Ba477b09073148948adef3d3e1503d12 & gt; : 0)
UnityEngine. UIElements. UIElementsUtility. The ProcessEvent (System. Int32 instanceID, System. IntPtr nativeEventPtr) (at & lt; Ba477b09073148948adef3d3e1503d12 & gt; : 0)
UnityEngine. GUIUtility. The ProcessEvent (System. Int32 instanceID, System. IntPtr nativeEventPtr) (at & lt; 70 ac3a30392c42a48583a8f82077fee6 & gt; : 0)
Application can run normally, but don't know what is going wrong, has been an error
After baidu to see someone say undefined reference instance objects, just learning c # and unity, didn't see that which is not defined, save the children
Attach using two script
Script: 1. The Playercontrol cs
Using System. The Collections;
Using System. Collections. Generic;
Using UnityEngine;
Public class the Playercontrol: MonoBehaviour
{
Public float speed=10 f;
Private int Maxhealth=3;//maximum life
Private int Currenthealth=2;//current hit points
Public int Gamingmaxhealth {get {return Maxhealth; }}
Public int Gaminghealth {get {return Currenthealth; }}
Rigidbody2D rbody;//define rigid rbody
//Start is called before the first frame update
Void the Start ()
{
Rbody=GetComponent}
//Update is called once per frame
Void the Update ()
{
Float moveX=Input. GetAxisRaw (" Horizontal ");//horizontal direction, A: 1 0-1 D:
//the first disabled float moveY=Input. GetAxisRaw (" Vertical ");//the vertical direction, W: 1, S: 1 0
Vector2 position=rbody. Position;
Position. X +=speed moveX * * Time. The deltaTime;
//ban position. Y +=speed moveY * * Time. The deltaTime;
Rbody. MovePosition (position);
}
//change the player's life value
Public void Changehealth (int aomunt)
{
Currenthealth=Mathf Clamp (Currenthealth + aomunt, 0, Maxhealth);
The Debug Log (Currenthealth + "/" + Maxhealth);
}
}
2: script Healthcollect. Cs
Using System. The Collections;
Using System. Collections. Generic;
Using UnityEngine;
//h. props collision detection
Public class Healthcollect: MonoBehaviour
{
//Start is called before the first frame update
Void the Start ()
{
}
//Update is called once per frame
Void the Update ()
{
}
Private void OnTriggerEnter2D Collider2D (other)
{
The Playercontrol PC=other. GetComponent(a);
If (PC!=null) {Debug Log (" players encounter cherry "); }
If (PC) Gaminghealth & lt; PC. Gamingmaxhealth)
{
PC. Changehealth (1);
Destroy (enclosing gameObject);
}
}
}
CodePudding user response:
Double-click the error to see if code specifies a sentenceCodePudding user response:
Is in the unity console error, can't find the pointCodePudding user response:
It ought to be you the questions you've UI UI banned give it a try