Renderer









How do I use Renderer
Below are practical examples compiled from projects for learning and reference purposes

Featured Snippets


File name: MaterialPerOwner.cs Copy
12     void Start()
13     {
14         m_Renderer = GetComponent();
15     }
File name: MaterialPerOwner.cs Copy
18     private void Update()
19     {
20         if( this.photonView.ownerId != assignedColorForUserId )
21         {
22             m_Renderer.material = PlayerVariables.GetMaterial( m_Renderer.material, this.photonView.ownerId );
23             this.assignedColorForUserId = this.photonView.ownerId;
24             //Debug.Log("Switched Material to: " + this.assignedColorForUserId + " " + this.renderer.material.GetInstanceID());
25         }
26     }
File name: OnClickRequestOwnership.cs Copy
28     public void ColorRpc( Vector3 col )
29     {
30         Color color = new Color( col.x, col.y, col.z );
31         this.gameObject.GetComponent().material.color = color;
32     }
File name: PlayerDiamond.cs Copy
28     {
29         get
30         {
31             if( m_DiamondRenderer == null )
32             {
33                 m_DiamondRenderer = GetComponentInChildren();
34             }
35
36             return m_DiamondRenderer;
37         }
38     }
File name: PlayerDiamond.cs Copy
87     void UpdateDiamondVisibility()
88     {
89         DiamondRenderer.enabled = true;
90
91         if( PhotonView == null || PhotonView.isMine == false )
92         {
93             DiamondRenderer.enabled = false;
94         }
95     }
File name: MoveByKeys.cs Copy
26     public void Start()
27     {
28         //enabled = photonView.isMine;
29         this.isSprite = (GetComponent() != null);
30
31         this.body2d = GetComponent();
32         this.body = GetComponent();
33     }
File name: ShowInfoOfPlayer.cs Copy
20     void Start()
21     {
22         if (font == null)
23         {
24             #if UNITY_3_5
25             font = (Font)FindObjectsOfTypeIncludingAssets(typeof(Font))[0];
26             #else
27             font = (Font)Resources.FindObjectsOfTypeAll(typeof(Font))[0];
28             #endif
29             Debug.LogWarning("No font defined. Found font: " + font);
30         }
31
32         if (tm == null)
33         {
34             textGo = new GameObject("3d text");
35             //textGo.transform.localScale = new Vector3(0.2f, 0.2f, 0.2f);
36             textGo.transform.parent = this.gameObject.transform;
37             textGo.transform.localPosition = Vector3.zero;
38
39             MeshRenderer mr = textGo.AddComponent();
40             mr.material = font.material;
41             tm = textGo.AddComponent();
42             tm.font = font;
43             tm.anchor = TextAnchor.MiddleCenter;
44             if (this.CharacterSize > 0)
45             {
46                 tm.characterSize = this.CharacterSize;
47             }
48         }
49     }
File name: Scalable.cs Copy
14  protected virtual void Start() {
15   renderer = GetComponent();
16   origMaterial = GetComponent().material;
17   origColor = origMaterial.GetColor("_Color");
18   origEmission = origMaterial.GetColor("_EmissionColor");
19  }
File name: Scalable.cs Copy
43  public void SetMaterial(Material material) {
44   renderer.material = material;
45  }
File name: Scalable.cs Copy
47  public void SetEmission(Color color) {
48   renderer.material.SetColor("_EmissionColor", color);
49   //DynamicGI.UpdateMaterials(r);
50         //DynamicGI.UpdateEnvironment();
51  }

Download file with original file name:Renderer

Renderer 143 lượt xem

Gõ tìm kiếm nhanh...