本文整理汇总了C#中UnityEngine.MeshRenderer.GetComponent方法的典型用法代码示例。如果您正苦于以下问题:C# MeshRenderer.GetComponent方法的具体用法?C# MeshRenderer.GetComponent怎么用?C# MeshRenderer.GetComponent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.MeshRenderer
的用法示例。
在下文中一共展示了MeshRenderer.GetComponent方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Start
void Start()
{
castToPlane = new Plane(-Vector3.forward, Vector3.zero);
meshRenderer = shadowPlane.GetComponent<MeshRenderer>();
meshFilter = meshRenderer.GetComponent<MeshFilter>();
mesh = meshFilter.mesh;
meshFilter.mesh = mesh;
vertices = mesh.vertices;
}
示例2: Awake
void Awake()
{
// Find Cursor Object
Cursor = transform.Find("Cursor").gameObject;
CursorMeshRenderer = Cursor.transform.GetComponentInChildren<MeshRenderer>();
CursorMeshRenderer.GetComponent<Renderer>().material.color = new Color(0.0f, 0.8f, 1.0f);
// Record initial coordinate for reset function
if (Cursor) {
ScreenCoordinate = Cursor.transform.localPosition;
InitCoordiante = Cursor.transform.localPosition;
}
}
示例3: FFacetRenderLayer
public FFacetRenderLayer(FStage stage, FFacetType facetType, FAtlas atlas, FShader shader)
{
this.stage = stage;
this.facetType = facetType;
this.atlas = atlas;
this.shader = shader;
_expansionAmount = facetType.expansionAmount;
_maxEmptyFacets = facetType.maxEmptyAmount;
this.batchIndex = facetType.index*10000000 + atlas.index*10000;
_gameObject = new GameObject("FRenderLayer ("+stage.name+") ("+facetType.name+")");
_transform = _gameObject.transform;
_transform.parent = Futile.instance.gameObject.transform;
_meshFilter = _gameObject.AddComponent<MeshFilter>();
_meshRenderer = _gameObject.AddComponent<MeshRenderer>();
_meshRenderer.castShadows = false;
_meshRenderer.receiveShadows = false;
_mesh = _meshFilter.mesh;
//we could possibly create a pool of materials so they can be reused,
//but that would create issues when unloading textures, so it's probably not worth it
_material = new Material(shader.shader);
_material.mainTexture = atlas.texture;
_meshRenderer.GetComponent<Renderer>().sharedMaterial = _material;
#if UNITY_3_0 || UNITY_3_1 || UNITY_3_2 || UNITY_3_3 || UNITY_3_4 || UNITY_3_5
_gameObject.active = false;
#else
_gameObject.SetActive(false);
_mesh.MarkDynamic();
#endif
ExpandMaxFacetLimit(facetType.initialAmount);
UpdateTransform();
}
示例4: FFacetRenderLayer
public FFacetRenderLayer(FStage stage, FFacetType facetType, FAtlas atlas, FShader shader)
{
_stage = stage;
_facetType = facetType;
_atlas = atlas;
_shader = shader;
_expansionAmount = _facetType.expansionAmount;
_maxEmptyFacets = _facetType.maxEmptyAmount;
batchIndex = _facetType.index*10000000 + atlas.index*10000 + shader.index;
_gameObject = new GameObject("FRenderLayer ("+_stage.name+") ("+_facetType.name+")");
_transform = _gameObject.transform;
_transform.parent = Futile.instance.gameObject.transform;
_meshFilter = _gameObject.AddComponent<MeshFilter>();
_meshRenderer = _gameObject.AddComponent<MeshRenderer>();
//_meshRenderer.castShadows = false;
_meshRenderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
_meshRenderer.receiveShadows = false;
_mesh = _meshFilter.mesh;
_material = new Material(_shader.shader);
_material.mainTexture = _atlas.texture;
_meshRenderer.GetComponent<Renderer>().material = _material;
#if UNITY_3_0 || UNITY_3_1 || UNITY_3_2 || UNITY_3_3 || UNITY_3_4 || UNITY_3_5
_gameObject.active = false;
#else
_gameObject.SetActive(false);
_mesh.MarkDynamic();
#endif
ExpandMaxFacetLimit(_facetType.initialAmount);
UpdateTransform();
}
示例5: GetOriginMeshFrom
static Mesh GetOriginMeshFrom( SpriteRenderer spriteRenderer, MeshRenderer meshRenderer )
{
if ( spriteRenderer != null ) {
return SpriteMeshConstructor.ConstructFromRendererBounds( spriteRenderer );
} else {
return meshRenderer.GetComponent<MeshFilter>().mesh;
}
}
示例6: RigidData
public RigidData(MeshRenderer mr)
{
var mf = mr.GetComponent<MeshFilter>();
if(mf == null)
throw new UnityException("Encountered MeshRenderer without matching MeshFilter! " + mr.name);
transform = mr.transform;
renderer = mr;
mesh = mf.sharedMesh;
materials = mr.sharedMaterials;
if(mesh == null || materials == null)
materials = new Material[0];
else if(materials.Length > mesh.subMeshCount) // Cut off any redundant materials in the renderer
System.Array.Resize(ref materials, mesh.subMeshCount);
props = new MaterialPropertyBlock();
props.AddMatrix(SID_PREV_MVP, Matrix4x4.identity);
prevWorld = transform.localToWorldMatrix;
}
示例7: Awake
void Awake()
{
Cursor = transform.Find("Cursor").gameObject;
CursorMeshRenderer = Cursor.transform.GetComponentInChildren<MeshRenderer>();
CursorMeshRenderer.GetComponent<Renderer>().material.color = new Color(0.0f, 0.8f, 1.0f);
}
示例8: Initialize
public void Initialize() {
_primaryMeshRenderer = InitializePrimaryMesh(_trackedItemGo);
_primaryMeshRenderer.enabled = true;
var primaryMeshCameraLosChgdListener = _primaryMeshRenderer.GetComponent<ICameraLosChangedListener>();
primaryMeshCameraLosChgdListener.inCameraLosChanged += PrimaryMeshInCameraLosChangedEventHandler;
primaryMeshCameraLosChgdListener.enabled = true;
InitializeSecondaryMeshes(_trackedItemGo);
InitializeOther(_trackedItemGo);
// AssessComponentsToShow(); no need to call here as EnableDisplay(true) is called immediately after initialization
}
示例9: Awake
//--------------------------------------------------------------
// End utility functions
//--------------------------------------------------------------
void Awake()
{
gameObject.AddComponent<MeshFilter>();
gameObject.AddComponent<MeshRenderer>();
meshFilter = (MeshFilter)GetComponent(typeof(MeshFilter));
meshRenderer = (MeshRenderer)GetComponent(typeof(MeshRenderer));
meshRenderer.GetComponent<Renderer>().material = material;
mesh = meshFilter.mesh;
// Create our first batch of sprites:
EnlargeArrays(allocBlockSize);
// Move the object to the origin so the objects drawn will not
// be offset from the objects they are intended to represent.
transform.position = Vector3.zero;
transform.rotation = Quaternion.identity;
}
示例10: Start
// Use this for initialization
void Start () {
mapManager = MapManager.Instance;
tileMesh = tileObject.GetComponentInChildren<MeshRenderer>();
if (tileMesh == null) {
Debug.LogError ("tile mesh not found", tileMesh);
return;
}
if(_debugTile)
{
posText.gameObject.SetActive(true);
coordText.gameObject.SetActive(true);
}
else
{
posText.gameObject.SetActive(false);
coordText.gameObject.SetActive(false);
}
//Material newMat = hexMaterials[Mathf.RoundToInt(Random.Range(0, hexMaterials.Length))];
//tileMesh.material = newMat;
defaultColor = tileMesh.GetComponent<Renderer>().material.color;
}