• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Material类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Material的典型用法代码示例。如果您正苦于以下问题:C# Material类的具体用法?C# Material怎么用?C# Material使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Material类属于命名空间,在下文中一共展示了Material类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Start

    // Use this for initialization
    void Start()
    {
        // Script References
        shipGraphics = GetComponent<ShipGraphics>();
        shipPhysicsScript = GetComponent<ShipPhysicsScript>();

        // Component Variables
        cam = GetComponentInChildren<Camera>();
        body = GetComponent<Rigidbody>();
        model = transform.Find("Model").gameObject;
        capsuleCollider = GetComponentInChildren<CapsuleCollider>();
        boxCollider = GetComponentInChildren<BoxCollider>();
        lockSound = GetComponent<AudioSource>();

        // Control Variables
        mouseSensitivity = 8.0f;
        //mouseThreshold = 8.0f;
        //buttonSensitivity = 0.05f;
        //buttonThreshold = 0.05f;

        horTranslation = 0.0f;
        verTranslation = 0.0f;

        enemyNoLock = (Material)Resources.Load("Crosshair");
        enemyLock = (Material)Resources.Load("Crosshair_Enemy");

        trackedObject = null;
        trackingResults = null;
        shootWaitTime = 0.0f;
        targetTime = 0.0f;
        hits = 0;
    }
开发者ID:henryj41043,项目名称:Project_GRAVITY,代码行数:33,代码来源:ShipDataScript.cs


示例2: Init

 void Init(bool ForceNewMat = false)
 {
     if (spriteRenderer == null)
     {
         spriteRenderer = GetComponent<MeshRenderer>();
     }
     if (MaterialRef == null)
     {
         MaterialRef = (Material)Resources.Load("Materials/SpriteRepeat", typeof(Material));
     }
     if (materialInstance == null || ForceNewMat)
     {
         if (!Application.isPlaying)
         {
             materialInstance = new Material(MaterialRef);
             spriteRenderer.sharedMaterial = materialInstance;
         }
         else
             materialInstance = spriteRenderer.sharedMaterial;
     }
     if (materialInstance.mainTexture != TextureToRepeat)
     {
         materialInstance.mainTexture = TextureToRepeat;
     }
     FitScale();
 }
开发者ID:vizigr0u,项目名称:ggj2016,代码行数:26,代码来源:RepeatSprite.cs


示例3: Awake

    void Awake()
    {
        if (camera==null) {
            Debug.LogError("SetupForGrassRendering script (at "+gameObject.name+") - can't find camera component !");
            return;
        }

        if ((useCustomDepthShader) && (SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.Depth))) {
            shad=Shader.Find("GrassRenderDepth"); // our simple depth rendering shader (rely on native z-depth buffer and don't render into color channels)
        } else {
            shad=Shader.Find("Hidden/Camera-DepthTexture"); // unity's render depth - probably slower as it renders everything into color buffer
        }
        if (!shad) {
            // we've got no shader ? Make simple one (handles native z-buffer for Opaque RenderType only)
            Material mat=new Material("Shader \"RenderDepth\" {SubShader { Tags { \"RenderType\"=\"Opaque\"} \n Pass { ColorMask 0 }}}");
            shad=mat.shader;
        }
        SetupTexture();
        GameObject go=new GameObject("GrassDepthCamera");
        go.AddComponent(typeof(Camera));
        go.transform.parent=transform;
        myCam=go.camera;
        SetupParams();

        teleportTresholdSqr = teleportTreshold * teleportTreshold;
    }
开发者ID:gordonklarson,项目名称:Perfect-Soccer,代码行数:26,代码来源:SetupForGrassRendering.cs


示例4: SetMaterial

 public void SetMaterial(string name, Material material)
 {
     if (name == "Material")
     {
         MaterialInstance.Material = material;
     }
 }
开发者ID:robterrell,项目名称:paradox,代码行数:7,代码来源:PrimitiveProceduralModelBase.cs


示例5: CreateMaterials

 void CreateMaterials()
 {
     if (!apply) {
         apply = new Material (bloomShader);
         apply.hideFlags = HideFlags.DontSave;
     }
 }
开发者ID:cn00,项目名称:U3D5_CSharp_AngryBots,代码行数:7,代码来源:MobileBloom.cs


示例6: SetColorRange

    private void SetColorRange(Material material)
    {
        switch (ColorRange)
        {
            case TOD_ColorRangeType.Auto:
                if (Components.Camera && Components.Camera.HDR)
                {
                    material.EnableKeyword("HDR");
                    material.DisableKeyword("LDR");
                }
                else
                {
                    material.DisableKeyword("HDR");
                    material.EnableKeyword("LDR");
                }
                break;

            case TOD_ColorRangeType.HDR:
                material.EnableKeyword("HDR");
                material.DisableKeyword("LDR");
                break;

            case TOD_ColorRangeType.LDR:
                material.DisableKeyword("HDR");
                material.EnableKeyword("LDR");
                break;
        }
    }
开发者ID:Drenerdo,项目名称:projectspark,代码行数:28,代码来源:TOD_Sky+Settings.cs


示例7: OnEnable

	void OnEnable()
	{
		if (overlayMaterial == null)
		{
			overlayMaterial = new Material(Shader.Find("Custom/SteamVR_Overlay"));
		}
	}
开发者ID:apekshadarbari,项目名称:PokerFace,代码行数:7,代码来源:SteamVR_GameView.cs


示例8: Awake

    void Awake()
    {
		if (!Application.isPlaying)
			return;

		fadeMaterial = new Material(Shader.Find("Oculus/Unlit Transparent Color"));
    }
开发者ID:FIU-SCIS-Senior-Projects,项目名称:SmartBuilding4,代码行数:7,代码来源:OVRTrackerBounds.cs


示例9: Watch

 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="name">name</param>
 /// <param name="description">description</param>
 /// <param name="price">price</param>
 /// <param name="material">material</param>
 /// <param name="manufacturer">manufacturer</param>
 /// <param name="age">age</param>
 public Watch(string name, string description, double price, Material material, string manufacturer, int age)
     : base(name, description, price)
 {
     this.material = material;
     this.manufacturer = manufacturer;
     this.age = age;
 }
开发者ID:bttalic,项目名称:BitcampStudentTest,代码行数:16,代码来源:Watch.cs


示例10: Start

    public void Start()
    {
        fxRes = GetComponent<IndieEffects>();
        blurMat = new Material(shader);

        previousViewProjectionMatrix = fxRes.DepthCam.camera.projectionMatrix * fxRes.DepthCam.camera.worldToCameraMatrix;
    }
开发者ID:GreatArcStudios,项目名称:UnityIndieEffects,代码行数:7,代码来源:CameraMotionBlur.cs


示例11: Bake

    public Material Bake()
    {
        Camera camera = transform.FindChild("Camera").camera;
        RenderTexture render_texture = new RenderTexture(256, 256, 24, RenderTextureFormat.Default, RenderTextureReadWrite.Default);
        render_texture.useMipMap = true;
        render_texture.filterMode = FilterMode.Trilinear;
        render_texture.mipMapBias = -0.5f;
        camera.targetTexture = render_texture;

        transform.FindChild("Title").gameObject.layer = LayerMask.NameToLayer("Active Card Render Texture");
        transform.FindChild("Rules").gameObject.layer = LayerMask.NameToLayer("Active Card Render Texture");

        Transform tile_mesh = transform.FindChild("Tile_base").FindChild("default");
        Material material = new Material(tile_mesh.renderer.material);
        material.mainTexture = render_texture;

        camera.Render();

        transform.FindChild("Title").gameObject.layer = LayerMask.NameToLayer("Card Render Texture");
        transform.FindChild("Rules").gameObject.layer = LayerMask.NameToLayer("Card Render Texture");

        Material return_material = new Material(multiply);
        return_material.mainTexture = render_texture;

        return return_material;
    }
开发者ID:JamesWilko,项目名称:FTJ,代码行数:26,代码来源:TileScript.cs


示例12: GetNewInstanceOfBatch

		protected override Batch GetNewInstanceOfBatch(Material material, BlendMode blendMode,
			int numberOfQuadsToAdd)
		{
			if ((material.Shader as ShaderWithFormat).Format.Is3D)
				throw new BatchRenderer2DCannotBeUsedToRender3D(); //ncrunch: no coverage
			return new Batch2D(material, blendMode, numberOfQuadsToAdd);
		}
开发者ID:whztt07,项目名称:DeltaEngine,代码行数:7,代码来源:BatchRenderer2D.cs


示例13: Flash

    private IEnumerator Flash()
    {
        if (isFlashing)
        {
            yield break;
        }
        isFlashing = true;

        this.originalMaterial = GetComponent<Renderer>().material;
        if (!this.originalMaterial.HasProperty("_Emission"))
        {
            Debug.LogWarning("Doesnt have emission, can't flash " + gameObject);
            yield break;
        }

        this.originalColor = this.originalMaterial.GetColor("_Emission");
        this.originalMaterial.SetColor("_Emission", Color.white);

        for (float f = 0.0f; f <= 1.0f; f += 0.08f)
        {
            Color lerped = Color.Lerp(Color.white, this.originalColor, f);
            this.originalMaterial.SetColor("_Emission", lerped);
            yield return null;
        }

        this.originalMaterial.SetColor("_Emission", this.originalColor);
        isFlashing = false;
    }
开发者ID:Ralph89,项目名称:SoccerRally,代码行数:28,代码来源:OnClickFlashRpc.cs


示例14: DoStuff

    static void DoStuff()
    {
        Object[] activeGOs = Selection.GetFiltered(typeof(Texture2D), SelectionMode.Assets);
        Debug.Log("Matching selection: " + activeGOs);

        foreach (Texture2D t in activeGOs){
            string path = AssetDatabase.GetAssetPath(t);
            path = path.Remove(path.LastIndexOf("/") + 1);

            string materialPath = path + t.name +"Mat.mat";

            Material material = AssetDatabase.LoadAssetAtPath(materialPath, typeof(Material)) as Material;

            if (material == null) {
                material = new Material (Shader.Find("VertexLit"));
                material.mainTexture = t;

                Debug.Log("Creating material: " + materialPath);
                AssetDatabase.CreateAsset(material, materialPath);
                EditorUtility.SetDirty(material);
            }
        }

        AssetDatabase.SaveAssets();
        AssetDatabase.Refresh();
    }
开发者ID:andykorth,项目名称:MWGJ15,代码行数:26,代码来源:CreateMaterialForSelection.cs


示例15: ensureMaxTextContrast

 Color ensureMaxTextContrast(Material material, TextMesh textMesh)
 {
     float red = Math.Abs(1-material.color.r);
     float green = Math.Abs(1-material.color.g);
     float blue = Math.Abs(1-material.color.b);
     return new Color (red, green, blue);
 }
开发者ID:scottluu,项目名称:Oculus-Type,代码行数:7,代码来源:EnemiesBehaviour.cs


示例16: Awake

	private void Awake() {
		Instance = this;
		renderer = GetComponent<Renderer>();
		targetMat = new Material(renderer.material);
		targetMat.color = Color.clear;
		renderer.sharedMaterial = targetMat;
	}
开发者ID:kevadsett,项目名称:BAGameJam2016,代码行数:7,代码来源:Flasher.cs


示例17: SetColorSpace

    private void SetColorSpace(Material material)
    {
        switch (ColorSpace)
        {
            case TOD_ColorSpaceType.Auto:
                if (QualitySettings.activeColorSpace == UnityEngine.ColorSpace.Linear)
                {
                    material.EnableKeyword("LINEAR");
                    material.DisableKeyword("GAMMA");
                }
                else
                {
                    material.DisableKeyword("LINEAR");
                    material.EnableKeyword("GAMMA");
                }
                break;

            case TOD_ColorSpaceType.Linear:
                material.EnableKeyword("LINEAR");
                material.DisableKeyword("GAMMA");
                break;

            case TOD_ColorSpaceType.Gamma:
                material.DisableKeyword("LINEAR");
                material.EnableKeyword("GAMMA");
                break;
        }
    }
开发者ID:Drenerdo,项目名称:projectspark,代码行数:28,代码来源:TOD_Sky+Settings.cs


示例18: Awake

    void Awake()
    {
        //create walking ground
        plane = GameObject.CreatePrimitive(PrimitiveType.Plane);
        scale = (int)gridWorldSize.x/10; // scaling the plane gives an 10*scale x 10*scale (x-axis x z-axis) plane, set to 50
        plane.transform.localScale = new Vector3 (scale, 1, scale); //scales only in x and z dimensions
        grass = Resources.Load ("Materials/TL_Grass_01/U5_Material/TL_Grass_01_U5") as Material;
        plane.GetComponent<Renderer> ().material = grass;
        plane.layer = 11;

        //set borders
        walls.Add ((GameObject) Resources.Load("Borders/Walls/wall1"));
        walls.Add ((GameObject) Resources.Load("Borders/Walls/wall2"));
        walls.Add ((GameObject) Resources.Load("Borders/Walls/wall3"));
        walls.Add ((GameObject) Resources.Load("Borders/Walls/wall4"));
        for (int i =0; i< walls.Count; i++) {
            Instantiate (walls[i], walls[i].transform.position, walls[i].transform.rotation);
        }

        //choose skybox
        skyboxes.Add ((Material) Resources.Load("Skyboxes/skybox1"));
        skyboxes.Add ((Material) Resources.Load("Skyboxes/skybox2"));
        skyboxes.Add ((Material) Resources.Load("Skyboxes/skybox3"));
        skyboxes.Add ((Material) Resources.Load("Skyboxes/skybox4"));
        skyboxes.Add ((Material) Resources.Load("Skyboxes/skybox5"));
        int randomskybox = Random.Range (0, skyboxes.Count+1);
        if (randomskybox != skyboxes.Count) {
            RenderSettings.skybox = skyboxes [randomskybox];
        }
        RenderSettings.fog = true;

        //create roads and trees
        roadbuilder = GetComponent<GenerateRoads>();
        roadbuilder.Generate ();
    }
开发者ID:gitjiaying,项目名称:minorProject,代码行数:35,代码来源:GenerateMap.cs


示例19: ReplaceSelectedMaterials

    public void ReplaceSelectedMaterials(Material mat, Material replacement)
    {
        pb_Editor editor = pb_Editor.instance;

            pb_Object[] pbs = FindObjectsOfType(typeof(pb_Object)) as pb_Object[];
            // Cycle through every ProBuilder Object
            foreach(pb_Object pb in pbs)
            {
                bool addToSelection = false;

                foreach(pb_Face f in pb.faces)
                {
                    if(f.material == mat)
                    {
                        addToSelection = true;

                        f.SetMaterial(rmat);

                        pb.AddToFaceSelection(f);
                    }
                }

                pb.Refresh();

                if(addToSelection)
                    editor.AddToSelection(pb.gameObject);
            }

            SceneView.RepaintAll();
    }
开发者ID:Izzu,项目名称:Hearthstone-RTS,代码行数:30,代码来源:SelectFacesWithMaterial.cs


示例20: OnEnable

    void OnEnable()
    {
        if (blitMaterial == null)
            blitMaterial = new Material(Shader.Find("Custom/SteamVR_BlitFlip"));

        camera = GetComponent<Camera>();
    }
开发者ID:VRCrew,项目名称:LightSaber,代码行数:7,代码来源:SteamVR_CameraFlip.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# MaterialProperty类代码示例发布时间:2022-05-24
下一篇:
C# MatchmakingMode类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap