本文整理汇总了C#中UnityEngine.MaterialPropertyBlock类的典型用法代码示例。如果您正苦于以下问题:C# MaterialPropertyBlock类的具体用法?C# MaterialPropertyBlock怎么用?C# MaterialPropertyBlock使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MaterialPropertyBlock类属于UnityEngine命名空间,在下文中一共展示了MaterialPropertyBlock类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:keyward,项目名称:EnemyOfMyEnemy,代码行数:60,代码来源:SkyDebug.cs
示例2: Awake
void Awake ()
{
mb = new MaterialPropertyBlock();
if( useTint) colorType = "_TintColor";
originalColor = this.renderer.material.GetColor(colorType);
}
开发者ID:marcteys,项目名称:trauts,代码行数:7,代码来源:SavePropretyBlock.cs
示例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);
}
开发者ID:n0mimono,项目名称:Unity5Effects,代码行数:31,代码来源:ShaderParams.cs
示例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);
}
开发者ID:cupsster,项目名称:fire,代码行数:28,代码来源:Fire.cs
示例5: Start
void Start()
{
property_block = new MaterialPropertyBlock();
property_block.AddMatrix("prev_Object2World", Matrix4x4.identity);
mesh_renderer = GetComponent<MeshRenderer>();
mesh_renderer.SetPropertyBlock(property_block);
}
开发者ID:WondermSwift,项目名称:MassParticle,代码行数:7,代码来源:DSMotionTrail.cs
示例6: Start
private void Start()
{
this.bloodPropertyBlock = new MaterialPropertyBlock();
this.animator = base.transform.GetComponentInChildren<Animator>();
this.resetSkinDamage();
base.InvokeRepeating("setSkinDamage", 1f, 0.3f);
}
开发者ID:GameDiffs,项目名称:TheForest,代码行数:7,代码来源:coopPlayerBloodDamage.cs
示例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);
}
开发者ID:BlakeTriana,项目名称:unity-decompiled,代码行数:7,代码来源:MaterialAnimationUtility.cs
示例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);
}
开发者ID:Deus0,项目名称:Zeltex,代码行数:7,代码来源:DebugDraw.cs
示例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);
}
开发者ID:GustavoQuiroz,项目名称:Unity5Effects,代码行数:31,代码来源:TransformToShader.cs
示例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);
}
开发者ID:Deus0,项目名称:Zeltex,代码行数:7,代码来源:DebugDraw.cs
示例11: SetOffset
public void SetOffset(Vector4 offset)
{
MaterialPropertyBlock props = new MaterialPropertyBlock();
GetComponent<Renderer>().GetPropertyBlock(props);
props.AddVector(offsetID, offset);
GetComponent<Renderer>().SetPropertyBlock(props);
}
开发者ID:ShreveportArcade,项目名称:BlurBomber,代码行数:7,代码来源:ShakeMaterialOnTrigger.cs
示例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);
}
开发者ID:HexHash,项目名称:LegacyRust,代码行数:29,代码来源:CompassRenderProxy.cs
示例13: setSkinDamageProperty
private void setSkinDamageProperty(MaterialPropertyBlock block)
{
if (this.skin)
{
this.skin.SetPropertyBlock(block);
}
}
开发者ID:GameDiffs,项目名称:TheForest,代码行数:7,代码来源:setupCreepySkin.cs
示例14: SetTexture
public override void SetTexture(Texture2D texture)
{
base.SetTexture(texture);
MaterialPropertyBlock props = new MaterialPropertyBlock();
props.AddTexture("_MainTex", texture);
spriteRenderer.SetPropertyBlock(props);
}
开发者ID:juliancruz87,项目名称:transpp,代码行数:7,代码来源:OnlineMapsSpriteRendererControl.cs
示例15: Awake
private void Awake()
{
this._alpha = 0.001f;
this._renderer = base.GetComponent<Renderer>();
this._block = new MaterialPropertyBlock();
base.enabled = false;
}
开发者ID:GameDiffs,项目名称:TheForest,代码行数:7,代码来源:TimedStippling.cs
示例16: Update
void Update()
{
if (_props == null)
_props = new MaterialPropertyBlock();
var dx = Mathf.Sin(_slideSpeed * Time.time) * _interval;
var br = (Mathf.Cos(_blinkSpeed * Time.time) + 1) * 0.5f;
var origin = transform.position + new Vector3(
_interval * _columns * -0.5f + dx,
_interval * _columns * -0.5f, 0);
var rotation = transform.rotation;
var scale = Vector3.one * _cellSize;
for (var y = 0; y <= _columns; y++)
{
for (var x = 0; x <= _columns; x++)
{
var position = origin + new Vector3(x, y, 0) * _interval;
var matrix = Matrix4x4.TRS(position, rotation, scale);
var c1 = _color1 * (br * x / _columns);
var c2 = _color2 * (br * y / _columns);
_props.SetColor("_EmissionColor", c1 + c2);
Graphics.DrawMesh(_mesh, matrix, _material, 0, null, 0, _props);
}
}
}
开发者ID:ariessanchezsulit,项目名称:KinoBloom,代码行数:29,代码来源:ArrayDrawer.cs
示例17: SwapColors_Custom
public void SwapColors_Custom(ColorPalette palette)
{
Texture2D t = spriteRenderer.sprite.texture;
if (palette.cachedTexture == null)
{
var w = t.width;
var h = t.height;
var cloneTexture = new Texture2D(w, h);
cloneTexture.wrapMode = TextureWrapMode.Clamp;
cloneTexture.filterMode = FilterMode.Point;
var colors = t.GetPixels();
for (int i = 0; i < colors.Length; i++)
{
colors[i] = palette.GetColor(colors[i]);
}
cloneTexture.SetPixels(colors);
cloneTexture.Apply();
palette.cachedTexture = cloneTexture;
}
block = new MaterialPropertyBlock();
block.AddTexture("_MainTex", palette.cachedTexture);
}
开发者ID:Mrbransky,项目名称:Kissy_Ghost,代码行数:29,代码来源:PaletteSwapper.cs
示例18: CreateMaterial
static void CreateMaterial (GameObject go) {
// Create a simple material asset
if (go.GetComponent<Renderer>() != null)
{
Material material = new Material(go.GetComponent<Renderer>().sharedMaterial);
material.CopyPropertiesFromMaterial(go.GetComponent<Renderer>().sharedMaterial);
go.GetComponent<Renderer>().sharedMaterial = material;
MaterialPropertyBlock block = new MaterialPropertyBlock();
go.GetComponent<Renderer>().GetPropertyBlock(block);
#if UNITY_EDITOR
if(!Directory.Exists("Assets/Materials")) {
AssetDatabase.CreateFolder("Assets", "Materials");
AssetDatabase.Refresh();
}
string textureName = null;
if (block.GetTexture(0).name != null) {
textureName = block.GetTexture(0).name;
} else {
textureName = material.mainTexture.name;
}
AssetDatabase.CreateAsset(material, "Assets/Materials/" + textureName + ".mat");
Debug.Log("Created material " + textureName + " for " + go.name);
#endif
}
}
开发者ID:MJ-meo-dmt,项目名称:UnitySpritesAndBones,代码行数:26,代码来源:SortLayerMaterialEditor.cs
示例19: UpdateOutline
void UpdateOutline(bool outline)
{
MaterialPropertyBlock mpb = new MaterialPropertyBlock();
spriteRenderer.GetPropertyBlock(mpb);
mpb.SetFloat("_Outline", outline ? 1f : 0);
mpb.SetColor("_OutlineColor", color);
spriteRenderer.SetPropertyBlock(mpb);
}
开发者ID:Magicolo,项目名称:PseudoFramework,代码行数:8,代码来源:SpriteOutline.cs
示例20: Awake
void Awake()
{
mb = new MaterialPropertyBlock();
mb.AddColor("_Color",newColor);
mb.AddColor("_TintColor",newColor);
this.transform.renderer.SetPropertyBlock(mb);
}
开发者ID:marcteys,项目名称:trauts,代码行数:8,代码来源:SetThisColor.cs
注:本文中的UnityEngine.MaterialPropertyBlock类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论