How do i solve this? CS1061
Soo i very new to programing and Unity and im trying to start a project but it allways show this error here and i dont know what to doo please help me http://prntscr.com/elqjtf
using UnityEngine;
using System.Collections;
public class ScrollingUVs : MonoBehaviour
{
public int materialIndex = 0;
public Vector2 uvAnimationRate = new Vector2( 1.0f, 0.0f );
public string textureName = "_MainTex";
public bool ScrollBump = true;
public string bumpName = "_BumpMap";
Vector2 uvOffset = Vector2.zero;
void LateUpdate()
{
uvOffset += ( uvAnimationRate * Time.deltaTime );
if( renderer.enabled )
{
renderer.materials[ materialIndex ].SetTextureOffset( textureName, uvOffset );
if(ScrollBump)
{
renderer.materials[ materialIndex ].SetTextureOffset( bumpName, uvOffset );
}
}
}
}
Answer by Commoble · Mar 19, 2017 at 04:46 PM
When you get an error message, you should generally read the error message before you come to Unity Answers to ask how to solve it:
Type UnityEngine.Component does not contain a definition for "enabled"
The "renderer" field is of type Component, which, as the error message says, doesn't have an enabled field.
The renderer field is also deprecated; Unity no longer supports using it, though it's kept around for legacy purposes. This is the correct way to get a reference to your object's Renderer:
public Renderer renderComponent;
Put this where you declare the other variables in your class. This will create a field in the Inspector that you can drag your component to. Since this is an actual Renderer type and not just a generic Component type, you can access its enabled field.
Your answer
Follow this Question
Related Questions
Help to Add some Sort and Binary Search in the code. 1 Answer
Velocity in Player Movement Problem? 0 Answers
Namespce Error!!!!!!!!! 0 Answers
VR Object Snapping 0 Answers
Vehicle enter/exit, why is my trigger collider not working? 1 Answer