本文整理汇总了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;
}
示例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();
}
示例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;
}
示例4: SetMaterial
public void SetMaterial(string name, Material material)
{
if (name == "Material")
{
MaterialInstance.Material = material;
}
}
示例5: CreateMaterials
void CreateMaterials()
{
if (!apply) {
apply = new Material (bloomShader);
apply.hideFlags = HideFlags.DontSave;
}
}
示例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;
}
}
示例7: OnEnable
void OnEnable()
{
if (overlayMaterial == null)
{
overlayMaterial = new Material(Shader.Find("Custom/SteamVR_Overlay"));
}
}
示例8: Awake
void Awake()
{
if (!Application.isPlaying)
return;
fadeMaterial = new Material(Shader.Find("Oculus/Unlit Transparent Color"));
}
示例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;
}
示例10: Start
public void Start()
{
fxRes = GetComponent<IndieEffects>();
blurMat = new Material(shader);
previousViewProjectionMatrix = fxRes.DepthCam.camera.projectionMatrix * fxRes.DepthCam.camera.worldToCameraMatrix;
}
示例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;
}
示例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);
}
示例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;
}
示例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();
}
示例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);
}