本文整理汇总了C#中UnityEngine.Renderer类的典型用法代码示例。如果您正苦于以下问题:C# Renderer类的具体用法?C# Renderer怎么用?C# Renderer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Renderer类属于UnityEngine命名空间,在下文中一共展示了Renderer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InstantiateDirectionIndicator
private GameObject InstantiateDirectionIndicator(GameObject directionIndicator)
{
if (directionIndicator == null)
{
return null;
}
GameObject indicator = Instantiate(directionIndicator);
// Set local variables for the indicator.
directionIndicatorDefaultRotation = indicator.transform.rotation;
directionIndicatorRenderer = indicator.GetComponent<Renderer>();
// Start with the indicator disabled.
directionIndicatorRenderer.enabled = false;
// Remove any colliders and rigidbodies so the indicators do not interfere with Unity's physics system.
foreach (Collider collider in indicator.GetComponents<Collider>())
{
Destroy(collider);
}
foreach (Rigidbody rigidBody in indicator.GetComponents<Rigidbody>())
{
Destroy(rigidBody);
}
Material indicatorMaterial = directionIndicatorRenderer.material;
indicatorMaterial.color = DirectionIndicatorColor;
indicatorMaterial.SetColor("_TintColor", DirectionIndicatorColor);
return indicator;
}
示例2: OnStart
public override void OnStart(PartModule.StartState state)
{
Flap = part.FindModelTransform(flapTransform);
cachedRenderer = Flap.gameObject.GetComponent<Renderer>();
if (FlapActive != false)
ToggleFlaps();
}
示例3: SetupMaterialPropertyBlock
public static void SetupMaterialPropertyBlock(MaterialProperty materialProp, int changedMask, Renderer target)
{
MaterialPropertyBlock materialPropertyBlock = new MaterialPropertyBlock();
target.GetPropertyBlock(materialPropertyBlock);
materialProp.WriteToMaterialPropertyBlock(materialPropertyBlock, changedMask);
target.SetPropertyBlock(materialPropertyBlock);
}
示例4: MaterialCache
public MaterialCache(Renderer renderer)
{
if(renderer as SpriteRenderer)
{
return;
}
List<Material> l_materialList = new List<Material>();
foreach(Material material in renderer.sharedMaterials)
{
Material materialInstance = null;
if(material)
{
materialInstance = GameObject.Instantiate<Material>(material);
materialInstance.hideFlags = HideFlags.DontSave;
materialInstance.shader = Shader.Find("Sprites/Default");
}
l_materialList.Add(materialInstance);
}
m_Materials = l_materialList.ToArray();
renderer.sharedMaterials = materials;
}
示例5: Awake
protected virtual void Awake()
{
MeshRenderer = GetComponent<MeshRenderer>();
Renderer = GetComponent<Renderer>();
Collider = GetComponent<Collider>();
ParticleSystem = GetComponent<ParticleSystem>();
}
示例6: Awake
void Awake()
{
trans = GetComponent<Transform>();
rend = GetComponent<Renderer>();
col = GetComponent<Collider>();
gc = GameController.Instance;
}
示例7: Start
void Start()
{
bout = transform.GetChild(0).GetComponent<Renderer>();
centre = transform.GetChild(1).GetComponent<Renderer>();
pointe = transform.GetChild(2).GetComponent<Renderer>();
reset();
}
示例8: AttachToTarget
/// <summary>
/// Attaches this object to 'attachTarget' at 'point'
/// </summary>
/// <param name="point">Point to attach to.</param>
/// <param name="attachTarget">Target object.</param>
protected void AttachToTarget () {
targetRenderer = attachTarget.GetComponent<Renderer>();
targetBounds = targetRenderer.bounds;
targetPosition = attachTarget.transform.position;
float width = targetBounds.size.x;
float height = targetBounds.size.y;
float attachTargetX = targetPosition.x;
float attachTargetY = targetPosition.y;
//NOTE (aaron): Ideally this would be independent of anchor/pivot position, but I cannot find a way to abstract
//the local relative position of this position within the object. Therefore, this currently only works for objects
//with centered pivots.
switch (attachPoint) {
case AttachPoint.BottomLeft:
transform.position = new Vector3(attachTargetX - width / 2, attachTargetY - height / 2, 0);
break;
case AttachPoint.BottomRight:
transform.position = new Vector3(attachTargetX + width / 2, attachTargetY - height / 2, 0);
break;
case AttachPoint.TopLeft:
transform.position = new Vector3(attachTargetX - width / 2, attachTargetY + height / 2, 0);
break;
case AttachPoint.TopRight:
transform.position = new Vector3(attachTargetX + width / 2, attachTargetY + height / 2, 0);
break;
case AttachPoint.BottomCenter:
transform.position = new Vector3(attachTargetX, attachTargetY - height / 2, 0);
break;
case AttachPoint.TopCenter:
transform.position = new Vector3(attachTargetX, attachTargetY + height / 2, 0);
break;
}
}
示例9: Init
void Init()
{
if (m_renderer == null) {
m_renderer = gameObject.GetComponent<Renderer>();
m_position = gameObject.transform.localPosition;
}
}
示例10: Start
private void Start()
{
_rigidbody = GetComponent<Rigidbody2D>();
_renderer = GetComponent<SpriteRenderer>();
_controller.Jump += Jump;
}
示例11: Awake
private void Awake()
{
myRenderer = GetComponentInChildren<Renderer> ();
originalTexture = myRenderer.material.mainTexture;
SetStartPosition (startPosition);
InitMapObjectType();
}
示例12: Awake
void Awake()
{
this.grid = transform.parent.parent.GetComponent<Grid> ();
renderer = GetComponent<Renderer> ();
randomize = false; // to set baseColor
renderer.material.color = baseColor;
}
示例13: Start
void Start()
{
r = HandTarget.GetComponent<Renderer>();
rbd = GetComponent<Rigidbody>();
rbd.useGravity = false;
tossModule = GetComponent<PlayerTossModule> ();
}
示例14: ExportToFile
public static void ExportToFile(Mesh mesh, Renderer renderer, string filename, bool uselhcoords = true) {
if (string.IsNullOrEmpty (filename))
return;
using (StreamWriter sw = new StreamWriter(filename)) {
sw.Write(ExportToString(mesh, ref renderer, uselhcoords));
}
}
示例15: ApplyMaterialModificationToAnimationRecording
public static bool ApplyMaterialModificationToAnimationRecording(MaterialProperty materialProp, int changedMask, Renderer target, object oldValue)
{
switch (materialProp.type)
{
case MaterialProperty.PropType.Color:
SetupMaterialPropertyBlock(materialProp, changedMask, target);
ApplyMaterialModificationToAnimationRecording(materialProp, target, (Color) oldValue);
return true;
case MaterialProperty.PropType.Vector:
SetupMaterialPropertyBlock(materialProp, changedMask, target);
ApplyMaterialModificationToAnimationRecording(materialProp, target, (Color) ((Vector4) oldValue));
return true;
case MaterialProperty.PropType.Float:
case MaterialProperty.PropType.Range:
SetupMaterialPropertyBlock(materialProp, changedMask, target);
ApplyMaterialModificationToAnimationRecording(materialProp, target, (float) oldValue);
return true;
case MaterialProperty.PropType.Texture:
{
if (!MaterialProperty.IsTextureOffsetAndScaleChangedMask(changedMask))
{
return false;
}
string name = materialProp.name + "_ST";
SetupMaterialPropertyBlock(materialProp, changedMask, target);
ApplyMaterialModificationToAnimationRecording(name, target, (Vector4) oldValue);
return true;
}
}
return false;
}