本文整理汇总了C#中UnityEngine.MaterialPropertyBlock类的典型用法代码示例。如果您正苦于以下问题:C# MaterialPropertyBlock类的具体用法?C# MaterialPropertyBlock怎么用?C# MaterialPropertyBlock使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MaterialPropertyBlock类属于UnityEngine命名空间,在下文中一共展示了MaterialPropertyBlock类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetDebugString
public string GetDebugString() {
string str = "<b>SkyDebug Info - " + this.name + "</b>\n";
Material mat = null;
if(Application.isPlaying) mat = GetComponent<Renderer>().material;
else mat = GetComponent<Renderer>().sharedMaterial;
str += mat.shader.name + "\n";
str += "is supported: " + mat.shader.isSupported + "\n";
mset.ShaderIDs[] bids = {new mset.ShaderIDs(), new mset.ShaderIDs()};
bids[0].Link();
bids[1].Link("1");
str += "\n<b>Anchor</b>\n";
mset.SkyAnchor anchor = this.GetComponent<mset.SkyAnchor>();
if(anchor != null) {
str += "Curr. sky: " + anchor.CurrentSky.name + "\n";
str += "Prev. sky: " + anchor.PreviousSky.name + "\n";
} else {
str += "none\n";
}
str += "\n<b>Property Block</b>\n";
if(block == null) block = new MaterialPropertyBlock();
block.Clear();
this.GetComponent<Renderer>().GetPropertyBlock(block);
for(int i=0; i<2; ++i) {
str += "Renderer Property block - blend ID " + i;
if(printDetails) {
str += "\nexposureIBL " + block.GetVector(bids[i].exposureIBL);
str += "\nexposureLM " + block.GetVector(bids[i].exposureLM);
str += "\nskyMin " + block.GetVector(bids[i].skyMin);
str += "\nskyMax " + block.GetVector(bids[i].skyMax);
str += "\ndiffuse SH\n";
for(int j=0; j<4; ++j) {
str += block.GetVector(bids[i].SH[j]) + "\n";
}
str += "...\n";
}
Texture spec = block.GetTexture(bids[i].specCubeIBL);
Texture sky = block.GetTexture(bids[i].skyCubeIBL);
str += "\nspecCubeIBL "; if(spec) str += spec.name; else str += "none";
str += "\nskyCubeIBL "; if(sky) str += sky.name; else str += "none";
if(printDetails) {
str += "\nskyMatrix\n" + block.GetMatrix(bids[i].skyMatrix);
str += "\ninvSkyMatrix\n" + block.GetMatrix(bids[i].invSkyMatrix);
}
if(i==0) {
str += "\nblendWeightIBL " + block.GetFloat(bids[i].blendWeightIBL);
}
str += "\n\n";
}
return str;
}
示例2: Awake
void Awake ()
{
mb = new MaterialPropertyBlock();
if( useTint) colorType = "_TintColor";
originalColor = this.renderer.material.GetColor(colorType);
}
示例3: AssignParams
public void AssignParams()
{
var renderer = GetComponent<Renderer>();
var trans = GetComponent<Transform>();
var material = renderer.sharedMaterial;
if (m_mpb == null)
{
m_mpb = new MaterialPropertyBlock();
m_mpb.SetFloat("_ObjectID", m_id);
}
var pos = m_use_root_position ? trans.root.position : trans.position;
var rot = m_use_root_rotation ? trans.root.rotation : trans.rotation;
var scale = m_use_root_scale ? trans.root.lossyScale : trans.lossyScale;
if(m_debug_log)
{
Debug.Log("pos: " + pos);
Debug.Log("rot: " + rot);
Debug.Log("scale: " + scale);
}
m_mpb.SetVector("_Position", pos);
m_mpb.SetVector("_Rotation", new Vector4(rot.x, rot.y, rot.z, rot.w));
m_mpb.SetVector("_Scale", scale);
m_mpb.SetFloat("_LocalTime", m_local_time);
for (int i = 0; i < m_fparams.Count; ++i)
{
m_mpb.SetFloat(m_fparams[i].key, m_fparams[i].value);
}
renderer.SetPropertyBlock(m_mpb);
}
示例4: OnWillRenderObject
public void OnWillRenderObject()
{
if (m_MatProps == null)
m_MatProps = new MaterialPropertyBlock();
Camera cam = Camera.current;
cam.depthTextureMode |= DepthTextureMode.Depth;
m_MatProps.Clear();
m_MatProps.AddVector("_CameraLocalPos", transform.InverseTransformPoint(cam.transform.position));
m_MatProps.AddMatrix("_CameraToLocal", transform.worldToLocalMatrix * cam.transform.localToWorldMatrix);
m_MatProps.AddVector("_Scale", transform.localScale);
m_MatProps.AddFloat("_Brightness", m_Brightness);
if (Application.isPlaying)
{
float time = Time.time;
m_TimeElapsed += m_Speed * (time - m_LastFrameTime);
m_LastFrameTime = time;
Shader.SetGlobalFloat("_FireTime", m_StartTime + m_TimeElapsed);
}
else
{
Shader.SetGlobalFloat("_FireTime", m_StartTime);
}
renderer.SetPropertyBlock(m_MatProps);
}
示例5: Start
void Start()
{
property_block = new MaterialPropertyBlock();
property_block.AddMatrix("prev_Object2World", Matrix4x4.identity);
mesh_renderer = GetComponent<MeshRenderer>();
mesh_renderer.SetPropertyBlock(property_block);
}
示例6: Start
private void Start()
{
this.bloodPropertyBlock = new MaterialPropertyBlock();
this.animator = base.transform.GetComponentInChildren<Animator>();
this.resetSkinDamage();
base.InvokeRepeating("setSkinDamage", 1f, 0.3f);
}
示例7: SetupMaterialPropertyBlock
public static void SetupMaterialPropertyBlock(MaterialProperty materialProp, int changedMask, Renderer target)
{
MaterialPropertyBlock materialPropertyBlock = new MaterialPropertyBlock();
target.GetPropertyBlock(materialPropertyBlock);
materialProp.WriteToMaterialPropertyBlock(materialPropertyBlock, changedMask);
target.SetPropertyBlock(materialPropertyBlock);
}
示例8: DrawSphere
public static void DrawSphere(Vector3 position, float radius, Color color)
{
Matrix4x4 mat = Matrix4x4.TRS(position, Quaternion.identity, radius * 0.5f * Vector3.one);
MaterialPropertyBlock block = new MaterialPropertyBlock();
block.AddColor("_Color", color);
Graphics.DrawMesh(solidSphere, mat, material, 0, null, 0, block);
}
示例9: LateUpdate
public virtual void LateUpdate()
{
if(m_id==0)
{
m_id = ++s_idgen;
}
m_local_time += Time.deltaTime;
if (m_mpb == null)
{
m_renderer = GetComponent<Renderer>();
m_trans = GetComponent<Transform>();
m_mpb = new MaterialPropertyBlock();
m_mpb.AddVector("_Position", Vector4.zero);
m_mpb.AddVector("_Rotation", Vector4.zero);
m_mpb.AddVector("_Scale", Vector4.one);
m_mpb.AddFloat("_LocalTime", m_local_time);
m_mpb.AddFloat("_ID", m_id);
}
var rot = m_trans.rotation;
m_mpb.SetVector("_Position", m_trans.position);
m_mpb.SetVector("_Rotation", new Vector4(rot.x, rot.y, rot.z, rot.w));
m_mpb.SetVector("_Scale", m_trans.localScale);
m_mpb.SetFloat("_LocalTime", m_local_time);
for (int i = 0; i < m_params.Length; ++i)
{
m_mpb.SetFloat(m_params[i].key, m_params[i].value);
}
m_renderer.SetPropertyBlock(m_mpb);
}
示例10: DrawCube
public static void DrawCube(Vector3 position, Quaternion rotation, float size, Color color)
{
Matrix4x4 mat = Matrix4x4.TRS(position, rotation, size * Vector3.one);
MaterialPropertyBlock block = new MaterialPropertyBlock();
block.AddColor("_Color", color);
Graphics.DrawMesh(solidCube, mat, material, 0, null, 0, block);
}
示例11: SetOffset
public void SetOffset(Vector4 offset)
{
MaterialPropertyBlock props = new MaterialPropertyBlock();
GetComponent<Renderer>().GetPropertyBlock(props);
props.AddVector(offsetID, offset);
GetComponent<Renderer>().SetPropertyBlock(props);
}
示例12: BindFrame
private void BindFrame()
{
if (this.propBlock == null)
{
this.propBlock = new MaterialPropertyBlock();
}
else
{
this.propBlock.Clear();
}
Vector2 vector2 = base.transform.worldToLocalMatrix.MultiplyVector(this.north);
vector2.Normalize();
Vector2 vector21 = new Vector2(-vector2.y, vector2.x);
vector21 = vector21 * this.scalar;
vector2 = vector2 * this.scalar;
if (this.bindNorth)
{
this.propBlock.AddVector(CompassRenderProxy.g.kPropLensUp, vector2);
}
if (this.bindWest)
{
this.propBlock.AddVector(CompassRenderProxy.g.kPropLensRight, vector21);
}
if (this.bindForward)
{
this.propBlock.AddVector(CompassRenderProxy.g.kPropLensDir, this.forward);
}
base.renderer.SetPropertyBlock(this.propBlock);
}
示例13: setSkinDamageProperty
private void setSkinDamageProperty(MaterialPropertyBlock block)
{
if (this.skin)
{
this.skin.SetPropertyBlock(block);
}
}
示例14: SetTexture
public override void SetTexture(Texture2D texture)
{
base.SetTexture(texture);
MaterialPropertyBlock props = new MaterialPropertyBlock();
props.AddTexture("_MainTex", texture);
spriteRenderer.SetPropertyBlock(props);
}
示例15: Awake
private void Awake()
{
this._alpha = 0.001f;
this._renderer = base.GetComponent<Renderer>();
this._block = new MaterialPropertyBlock();
base.enabled = false;
}