Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
1
Question by mobgato · Feb 05, 2016 at 08:51 AM · cs0103

error CS0103: The name `renderer' does not exist in the current context

Hi !

When I tried to build the work to any paltform, I got these two errors and building stopped.

Here are the errors.

alt text

This is the code

 using UnityEngine;
 using System.Collections;
 using System.Collections.Generic;
 
 [ExecuteInEditMode]
 public class PedestrianNode : MonoBehaviour 
 {
     public  List<PedestrianNode>        m_nodes              = new List<PedestrianNode>();
     public  bool                        m_waitAtNode         = false;
     public  int                         m_pathID             = 1;
 
     void Awake () 
     {
         #if !UNITY_EDITOR
             if(Application.isPlaying)
                 if(renderer)
                     renderer.enabled = false;
         #endif
 
         CleanupNodes();
     }
     
     void Start () 
     {
         
     }
 
     public void AddNode ( PedestrianNode a_node ) 
     {
         if(NodeExists(a_node))
             return;
 
         m_nodes.Add( a_node );
     }
 
     public bool NodeExists( PedestrianNode a_node )
     {
         for(int nIndex = 0; nIndex < m_nodes.Count; nIndex++)
         {
             if(m_nodes[nIndex] == a_node)
                 return true;
         }
 
         return false;
     }
 
     public void RemoveNode( PedestrianNode a_node )
     {
         m_nodes.Remove( a_node );
     }
 
     public void RemoveAllNodes()
     {
         m_nodes.Clear();
     }
 
     public PedestrianNode NextNode( PedestrianObject a_obj )
     {
         switch(a_obj.m_pathingStatus)
         {
         case PedestrianObject.PathingStatus.RANDOM:
         {
             if( m_nodes.Count > 0)
             {
                 int count = 0;
                 List<PedestrianNode> m_tmpNodes = new List<PedestrianNode>();
 
                 for(int nIndex = 0; nIndex < m_nodes.Count; nIndex++)
                     m_tmpNodes.Add(m_nodes[nIndex]);
 
                 while(count < m_tmpNodes.Count)
                 {
                     count++;
                     PedestrianNode node = m_tmpNodes[Random.Range(0, m_tmpNodes.Count)];
 
                     if(node && !a_obj.HasVisitedNode( node ))
                         return node;
                     else
                     {
                         m_tmpNodes.Remove( node );
                         count = 0;
                     }
                 }
             }
         }
             break;
         }
 
         return null;
     }
 
     public void SpawnNode( Vector3 a_pos, bool a_isConnected = true )
     {
         PedestrianNode node     = Instantiate(PedestrianSystem.Instance.m_nodePrefab) as PedestrianNode;
         node.transform.parent   = PedestrianSystem.Instance.transform;
         node.transform.position = a_pos;
 
         if(a_isConnected)
             AddNode(node);
     }
 
     public void CleanupNodes()
     {
         for(int nIndex = m_nodes.Count - 1; nIndex >= 0; nIndex--)
         {
             if(!m_nodes[nIndex])
                 m_nodes.RemoveAt(nIndex);
         }
     }
     
     void OnDrawGizmos()
     {
         #if !UNITY_EDITOR
             return;
         #else
             if(PedestrianSystem.Instance && !PedestrianSystem.Instance.m_showGizmos)
                 return;
         #endif
 
         if(PedestrianSystem.Instance && !PedestrianSystem.Instance.m_showGizmos)
             return;
         
         float scaleFactorCube   = 0.15f;
         float scaleFactorSphere = 0.225f;
         for(int nIndex = 0; nIndex < m_nodes.Count; nIndex++)
         {
             PedestrianNode connectedNode = m_nodes[nIndex];
             if(connectedNode)
             {
                 Vector3 offset = new Vector3(0.0f, 0.1f, 0.0f);
                 Gizmos.color = Color.white;
                 Gizmos.DrawLine( transform.position + offset, connectedNode.transform.position + offset );
                 
                 Vector3 dir = transform.position - connectedNode.transform.position;
                 //                    Gizmos.color = Color.white;
                 //                    Gizmos.DrawCube( (transform.position - (dir.normalized * ((dir.magnitude / 2) + scaleFactorSphere))) + offset, new Vector3(scaleFactorCube * 1.4f, scaleFactorCube * 1.4f, scaleFactorCube * 1.4f) );
                 Gizmos.color = Color.yellow;
                 Gizmos.DrawCube( (transform.position - (dir.normalized * ((dir.magnitude / 2) + scaleFactorSphere))) + offset, new Vector3(scaleFactorCube, scaleFactorCube, scaleFactorCube) );
                 Gizmos.color = Color.white;
                 Gizmos.DrawSphere( (transform.position - (dir.normalized * (dir.magnitude / 2))) + offset, scaleFactorSphere );
             }
         }
     }
 }
 


m24xkkp.png (20.2 kB)
Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image John3D · Mar 08, 2016 at 07:03 PM 0
Share

Hi,

Did you managed to solve this problem? I have the same problem.

Thanks!

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Taxen0 · Feb 05, 2016 at 12:40 PM

just like the error say, you don't have any variable named "renderer". Maybe you meant to type "gameObject.renderer"? otherwise you need to get a reference to the renderer you want to modify to the script.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by John3D · Mar 08, 2016 at 11:04 PM

Use this code to solve the problem:

 void Awake () 
     {
         #if !UNITY_EDITOR
             if(Application.isPlaying)
                 if(GetComponent<Renderer>())
                     GetComponent<Renderer>().enabled = false;
         #endif
 
         CleanupNodes();
     }
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

41 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

CS 0103 UnityEditor does not exist in the current context 0 Answers

error even after following simple tutorial 1 Answer

Error cs0103: the name unityEngine don't exist in the current context 2 Answers

Error CS0103 UnityEngine does not exist 3 Answers

error cs0103 unity the name text does not exist in the current context and same for the button what can i do plz someone help Asap 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges