当前位置: 首页>>代码示例>>C#>>正文


C# MeshRenderer.GetComponent方法代码示例

本文整理汇总了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;
    }
开发者ID:AlexanderBF,项目名称:Stoned,代码行数:10,代码来源:ShadowProjector.cs

示例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;
     }
 }
开发者ID:dream144,项目名称:altspacevr-project-unity-cursor,代码行数:12,代码来源:SphericalCursorModule.cs

示例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();
    }
开发者ID:tanis2000,项目名称:Futile,代码行数:43,代码来源:FFacetRenderLayer.cs

示例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();
    }
开发者ID:Grizzlage,项目名称:Futile-SpineSprite,代码行数:42,代码来源:FFacetRenderLayer.cs

示例5: GetOriginMeshFrom

 static Mesh GetOriginMeshFrom( SpriteRenderer spriteRenderer, MeshRenderer meshRenderer )
 {
     if ( spriteRenderer != null ) {
         return SpriteMeshConstructor.ConstructFromRendererBounds( spriteRenderer );
     } else {
         return meshRenderer.GetComponent<MeshFilter>().mesh;
     }
 }
开发者ID:sabikku,项目名称:unity-sprite-cutter,代码行数:8,代码来源:SpriteCutter.cs

示例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;
        }
开发者ID:markkleeb,项目名称:ArcadeCabs2016,代码行数:18,代码来源:MoBlur.cs

示例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);
 }
开发者ID:Objelisks,项目名称:altspacevr-project-unity-cursor,代码行数:6,代码来源:SphericalCursorModule.cs

示例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
        }
开发者ID:Maxii,项目名称:CodeEnv.Master,代码行数:12,代码来源:ADisplayManager.cs

示例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;
    }
开发者ID:dlobser,项目名称:beach,代码行数:22,代码来源:SpriteManager.cs

示例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;
    }
开发者ID:sclarke27,项目名称:HexGame,代码行数:26,代码来源:HexMapTile.cs


注:本文中的UnityEngine.MeshRenderer.GetComponent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。