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


C# Material类代码示例

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


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


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