本文整理汇总了C#中UnityEngine.Renderer.GetComponent方法的典型用法代码示例。如果您正苦于以下问题:C# Renderer.GetComponent方法的具体用法?C# Renderer.GetComponent怎么用?C# Renderer.GetComponent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.Renderer
的用法示例。
在下文中一共展示了Renderer.GetComponent方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RemoveRenderer
public void RemoveRenderer(Renderer rend) {
if(AffectedRenderers.Contains(rend)) {
AffectedRenderers.Remove(rend);
mset.SkyAnchor anchor = rend.GetComponent<mset.SkyAnchor>();
if(anchor && anchor.CurrentApplicator == this) anchor.CurrentApplicator = null;
}
}
示例2: AddRenderer
public void AddRenderer(Renderer rend) {
mset.SkyAnchor anchor = rend.GetComponent<mset.SkyAnchor>();
if(anchor != null) {
if(anchor.CurrentApplicator != null) anchor.CurrentApplicator.RemoveRenderer(rend);
anchor.CurrentApplicator = this;
}
AffectedRenderers.Add(rend);
}
示例3: DrawHierachy
private void DrawHierachy(TreeData treeData, Renderer renderer, Rect sizeRect)
{
if (styles == null)
{
styles = new Styles();
}
this.hierachySpread = this.hierachyNodeSize + this.hierachyNodeSpace;
this.hierachyView = sizeRect;
Event event2 = new Event(Event.current);
List<HierachyNode> nodes = new List<HierachyNode>();
this.BuildHierachyNodes(treeData, nodes, treeData.root, 0);
this.LayoutHierachyNodes(nodes, sizeRect);
float num = 16f;
Vector2 zero = Vector2.zero;
if (sizeRect.width < this.hierachyRect.width)
{
zero.y -= 16f;
}
bool changed = GUI.changed;
this.hierachyDisplayRect = GUILayoutUtility.GetRect(sizeRect.width, this.hierachyRect.height + num);
this.hierachyDisplayRect.width = sizeRect.width;
GUI.Box(this.hierachyDisplayRect, GUIContent.none, styles.nodeBackground);
this.hierachyScroll = GUI.BeginScrollView(this.hierachyDisplayRect, this.hierachyScroll, this.hierachyRect, false, false);
GUI.changed = changed;
this.HandleDragHierachyNodes(treeData, nodes);
this.DrawHierachyNodes(treeData, nodes, treeData.root, (Vector2) (zero / 2f), 1f, 1f);
if ((this.dragNode != null) && this.isDragging)
{
Vector2 vector2 = Event.current.mousePosition - this.dragClickPos;
this.DrawHierachyNodes(treeData, nodes, this.dragNode.group, vector2 + ((Vector2) (zero / 2f)), 0.5f, 0.5f);
}
GUI.EndScrollView();
MeshFilter component = renderer.GetComponent<MeshFilter>();
if (((component != null) && (component.sharedMesh != null)) && (renderer != null))
{
int length = component.sharedMesh.vertices.Length;
int num3 = component.sharedMesh.triangles.Length / 3;
int num4 = renderer.sharedMaterials.Length;
Rect position = new Rect((this.hierachyDisplayRect.xMax - 80f) - 4f, ((this.hierachyDisplayRect.yMax + zero.y) - 40f) - 4f, 80f, 40f);
string text = TreeEditorHelper.GetGUIContent("Hierachy Stats").text.Replace("[v]", length.ToString()).Replace("[t]", num3.ToString()).Replace("[m]", num4.ToString()).Replace(" / ", "\n");
GUI.Label(position, text, EditorStyles.helpBox);
}
if ((event2.type == EventType.ScrollWheel) && (Event.current.type == EventType.Used))
{
Event.current = event2;
}
}
示例4: HasNormals
private static bool HasNormals(Renderer renderer)
{
Mesh mesh = (Mesh) null;
if (renderer is MeshRenderer)
{
MeshFilter component = renderer.GetComponent<MeshFilter>();
if ((UnityEngine.Object) component != (UnityEngine.Object) null)
mesh = component.sharedMesh;
}
else if (renderer is SkinnedMeshRenderer)
mesh = (renderer as SkinnedMeshRenderer).sharedMesh;
return InternalMeshUtil.HasNormals(mesh);
}
示例5: ApplyCorrectSky
public void ApplyCorrectSky(Renderer rend) {
//filter by ignored layers
bool localCube = false;
//if the anchor is a direct link to a sky, ignore applicators all together
mset.SkyAnchor anchor = rend.GetComponent<SkyAnchor>();
if(anchor && anchor.BindType == SkyAnchor.AnchorBindType.TargetSky) {
anchor.Apply();
localCube = true;
}
//look for localized applicators to bind this renderer to
foreach(mset.SkyApplicator app in skyApplicators) {
if(localCube) app.RemoveRenderer(rend);
else if(app.RendererInside(rend)) localCube = true;
}
//no local applicator found, but we have a global sky
if(!localCube && _GlobalSky != null) {
if(anchor != null) {
if(anchor.CurrentApplicator != null) {
anchor.CurrentApplicator.RemoveRenderer(rend);
anchor.CurrentApplicator = null;
}
//start last blend to global sky and tell the anchor it's gone global
anchor.BlendToGlobalSky(_GlobalSky);
} else {
//HACK: no applying to renderers outside of a sky anchor! it leaks memory.
//_GlobalSky.Apply(rend,0);
}
if(!globalSkyChildren.Contains(rend)) globalSkyChildren.Add(rend);
}
//if a local cube was found or there is no global sky, remove rend
if(localCube || _GlobalSky == null) {
if(globalSkyChildren.Contains(rend)) {
globalSkyChildren.Remove(rend);
}
}
}
示例6: RegisterNewRenderer
public void RegisterNewRenderer(Renderer rend) {
//filter by active
if(!rend.gameObject.activeInHierarchy) return;
//filter by ignored layers
int layerFlag = 1 << rend.gameObject.layer;
if((IgnoredLayerMask & layerFlag) != 0) return;
//sort by static/dynamic
if(rend.gameObject.isStatic) {
if(!staticRenderers.Contains(rend)) {
staticRenderers.Add(rend);
ApplyCorrectSky(rend);
}
} else if(!dynamicRenderers.Contains(rend)) {
dynamicRenderers.Add(rend);
if(rend.GetComponent<mset.SkyAnchor>() == null) {
rend.gameObject.AddComponent(typeof(mset.SkyAnchor));
}
}
}
示例7: HasNormals
private static bool HasNormals(Renderer renderer)
{
Mesh sharedMesh = null;
if (renderer is MeshRenderer)
{
MeshFilter component = renderer.GetComponent<MeshFilter>();
if (component != null)
{
sharedMesh = component.sharedMesh;
}
}
else if (renderer is SkinnedMeshRenderer)
{
sharedMesh = (renderer as SkinnedMeshRenderer).sharedMesh;
}
return InternalMeshUtil.HasNormals(sharedMesh);
}