Question about a message in Unity 5

Hopefully this is my last question today :slight_smile: Again, I am cleaning up code with my conversion and I am running across an interesting warning message. It states:

PlayVideo.cs(15,25): warning CS0108: `' hides inherited member ''. Use the new keyword if hiding was intended

The line it refers to in my script is:

private AudioSource audio;

This is my movie texture script I wrote. Although it works just fine, I would just like to know exactly what is throwing the warning. If you would like to see the whole script, click on it below.

Full Script
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEngine.UI;
using UnityEngine.SceneManagement;

[RequireComponent (typeof (AudioSource))]

public class PlayVideo : MonoBehaviour {

public UnityEngine.MovieTexture movie;
public int level = 1;    //Level to open after splash
public float setTime = 3.0f;    //Duration before loading next level

private AudioSource audio;

float timer;     // Use this for initialization

void Start () {
    GetComponent<RawImage>().texture = movie as MovieTexture;
    audio = GetComponent<AudioSource>();
    audio.clip = movie.audioClip;
    timer = 0.0f; //Initializes Timer to 0

void Update () {
    timer += Time.deltaTime; //Adds Time.deltaTime to timer each update
    if (timer > setTime)
        SceneManager.LoadScene(level); //Loads Level at index

Hey Eric,

From what I can see online there are suggestions that error CS0108 refers to a member variable with a name that is used within inherited code.

Try renaming audio to something daft/unusual and see if the warning goes away.

That was it Rob, thanks :slight_smile:

I wasn’t too worried about it, since it worked. But I hate looming questions of why there is an error.


No worries - nice to have a tidy code base :slight_smile:

Privacy & Terms