c# Inheritance related questions

Asked 1 weeks ago, Updated 1 weeks ago, 1 views

I wrote a property class like this

using System.Collections; using System.Collections.Generic; using UnityEngine;

public class property2 : property {

// Start is called before the first frame update
void Start()
{

}

// // Update is called once per frame
void Update()
{
    if (Input.GetKeyDown(KeyCode.DownArrow))
    {
        print(getsalary());

    }

}

}

We created a property2 class to inherit the property.

Question) When the salary value changes within the property class by pressing UpArrow, the code was created with the intention of changing the salary value output from the property2 class, but the salary value output from the property2 class does not change. How do I solve this?

If you don't understand the question, please leave a comment I'll try harder to explain ㅠ<

c#

2022-09-20 11:33

1 Answers

If you use Update in a child class, Update in the parent class is not invoked automatically. I think you should call base.Update from your child's Update.


2022-09-20 11:33

If you have any answers or tips


© 2022 pinfo. All rights reserved.