Example #1
0
 // Use this for initialization
 void Start()
 {
     if (navGraph == null)
     {
         navGraph = RPNavGraph.Inst;
         navGraph.RegisterNode(this);
     }
 }
Example #2
0
    // Update is called once per frame
    void Update()
    {
        if (Application.isEditor && oldNeighbours != neighbours.Length)
        {
            oldNeighbours = neighbours.Length;
            if (navGraph == null)
            {
                navGraph = RPNavGraph.Inst;
            }
            navGraph.refresh = true;
        }

        if (Application.isEditor && nodeName != oldName)
        {
            oldName = nodeName;
            if (navGraph == null)
            {
                navGraph = RPNavGraph.Inst;
            }

            if (nodeName.Length > 0)
            {
                Material cop = new Material(GetComponent <MeshRenderer>().sharedMaterial);
                cop.color = navGraph.endNodeColor;
                GetComponent <MeshRenderer>().sharedMaterial = cop;
            }
            else
            {
                Material cop = new Material(GetComponent <MeshRenderer>().sharedMaterial);
                cop.color = navGraph.normalNodeColor;
                GetComponent <MeshRenderer>().sharedMaterial = cop;
            }
            navGraph.RegisterNode(this);
        }

        if (Application.isEditor && changedColorYet == false)
        {
            changedColorYet = true;
            if (navGraph == null)
            {
                navGraph = RPNavGraph.Inst;
            }

            if (nodeName.Length > 0)
            {
                Material cop = new Material(GetComponent <MeshRenderer>().sharedMaterial);
                cop.color = navGraph.endNodeColor;
                GetComponent <MeshRenderer>().sharedMaterial = cop;
            }
            else
            {
                Material cop = new Material(GetComponent <MeshRenderer>().sharedMaterial);
                cop.color = navGraph.normalNodeColor;
                GetComponent <MeshRenderer>().sharedMaterial = cop;
            }
            navGraph.RegisterNode(this);
        }
    }