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


C# Material.GetTextureOffset方法代码示例

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


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

示例1: Start

    private Vector2 offset = Vector2.zero; //Starting Offset

    #endregion Fields

    #region Methods

    void Start()
    {
        material = GetComponent<Renderer>().material;

        //"_MainTex" is the main diffuse texture. This is specified in the Unity Docs.
        offset = material.GetTextureOffset("_MainTex");
    }
开发者ID:d4rkz3r0,项目名称:Shattered-Realms,代码行数:13,代码来源:AnimatedTexture.cs

示例2: Start

	// Use this for initialization
	void Start () {
        material = GetComponent<Renderer>().material;

        offset = material.GetTextureOffset("_MainTex");


	}
开发者ID:henarky,项目名称:HFPB,代码行数:8,代码来源:AnimatedTexture.cs

示例3: Start

    // Use this for initialization
    void Start()
    {
        //get reference to the material tied to the background quad
        material = GetComponent<Renderer> ().material;

        offset = material.GetTextureOffset("_MainTex");
    }
开发者ID:2h,项目名称:SuperZombieRunner,代码行数:8,代码来源:AnimatedTexture.cs

示例4: GetValues

	public List<StoredValue> GetValues(Material m)
	{
		var list = GetShaderProperties(m);
		var output = new List<StoredValue>();
		foreach(var p in list)
		{
			var o = new StoredValue { Property = p };
			output.Add(o);
			switch(p.type)
			{
			case MaterialProperty.PropertyType.color:
				o.Value = m.GetColor(p.name);
				break;
			case MaterialProperty.PropertyType.real:
				o.Value = m.GetFloat(p.name);
				break;
			case MaterialProperty.PropertyType.texture:
				o.Value = m.GetTexture(p.name);
				break;
			case MaterialProperty.PropertyType.vector:
				o.Value = m.GetVector(p.name);
				break;
			case MaterialProperty.PropertyType.textureOffset:
				o.Value = m.GetTextureOffset(p.name);
				break;
			case MaterialProperty.PropertyType.textureScale:
				o.Value = m.GetTextureScale(p.name);
				break;
			case MaterialProperty.PropertyType.matrix:
				o.Value = m.GetMatrix(p.name);
				break;
			}
		}
		return output;
	}
开发者ID:MHaubenstock,项目名称:RPG-Board-3D,代码行数:35,代码来源:StoreMaterials.cs

示例5: OnRecord

 public override void OnRecord()
 {
     if (_material = material)
     {
         _original = _material.GetTextureOffset(propertyName);
     }
 }
开发者ID:izaleu,项目名称:Steamplane,代码行数:7,代码来源:TweenMaterialTextureOffset.cs

示例6: FromMaterial

        public static SMaterial FromMaterial(Material mat)
        {
            if (mat == null)
                return null;

            Shader shader = mat.shader;
            if (shader == null)
                return null;

            SMaterial result = new SMaterial();
            result.instanceID = mat.GetInstanceID();
            result.materialName = mat.name;
            result.shaderName = shader.name;

            ShaderProperties.Info info = ShaderPropertyHelper.GetShaderInfo(shader.name);

            if (info != null){
                ComposedByteStream rawData = new ComposedByteStream();

                int iMax = info.propertyNames.Length;
                for (int i = 0; i < iMax; i++)
                {
                    string propName = info.propertyNames[i];
                    switch (info.propertyTypes[i])
                    {
                        case ShaderProperties.PropType.Color:
                            Color color = mat.GetColor(propName);
                            rawData.AddStream(new float[] { color.r, color.g, color.b, color.a });
                            break;

                        case ShaderProperties.PropType.Range:
                        case ShaderProperties.PropType.Float:
                            rawData.AddStream(new float[] { mat.GetFloat(propName) });
                            break;

                        case ShaderProperties.PropType.TexEnv:
                            Texture texture = mat.GetTexture(propName);
                            Vector2 offset = mat.GetTextureOffset(propName);
                            Vector2 scale = mat.GetTextureScale(propName);

                            rawData.AddStream(new int[] { texture != null ? texture.GetInstanceID() : -1 });
                            rawData.AddStream(texture != null ? texture.name : "" );
                            rawData.AddStream(new float[] { offset.x, offset.y });
                            rawData.AddStream(new float[] { scale.x, scale.y });
                            break;

                        case ShaderProperties.PropType.Vector:
                            Vector4 vector = mat.GetVector(propName);
                            rawData.AddStream(new float[] { vector.x, vector.y, vector.z, vector.w });
                            break;
                    }
                }
                result.rawData = rawData.Compose();
                return result;
            } else {
                if (vBug.settings.general.debugMode)
                    Debug.LogError("No shader-info found @" + shader.name);
                return null;
            }
        }
开发者ID:WhiteRavensGame,项目名称:JRPGTownPrototype,代码行数:60,代码来源:MaterialSerializeHelper.cs

示例7: SetFromToCurrent

 public void SetFromToCurrent()
 {
     if (_material = material)
     {
         from = _material.GetTextureOffset(propertyName);
     }
 }
开发者ID:izaleu,项目名称:Steamplane,代码行数:7,代码来源:TweenMaterialTextureOffset.cs

示例8: OnTween

        public override void OnTween(float factor)
        {
            if (_material = material)
            {
                _temp = _material.GetTextureOffset(propertyName);

                if (mask.GetBit(0)) _temp.x = from.x + (to.x - from.x) * factor;
                if (mask.GetBit(1)) _temp.y = from.y + (to.y - from.y) * factor;

                _material.SetTextureOffset(propertyName, _temp);
            }
        }
开发者ID:izaleu,项目名称:Steamplane,代码行数:12,代码来源:TweenMaterialTextureOffset.cs

示例9: ACCTexture

        public ACCTexture(Texture tex, Material mate, ShaderPropTex texProp, ShaderType type) :this(texProp.key) {
            this.tex = tex;
            this.type = type;
            this.prop = texProp;

            this.editname = tex.name;
            if (tex is Texture2D) {
               texOffset = mate.GetTextureOffset(propName);
               texScale  = mate.GetTextureScale(propName);
            } else {
                LogUtil.DebugF("propName({0}): texture type:{1}", propName, tex.GetType());
            }
            
//            } else {
//                // シェーダ切り替えなどで、元々存在しないテクスチャの場合
//                LogUtil.DebugF("texture not found. propname={0}, material={1}", propName, mate.name);
//                // 空のテクスチャは作成しない
////                this.tex = new Texture2D(2, 2);
////                this.tex.name = string.Empty;
////                // テクスチャを追加セット
////                mate.SetTexture(propName, this.tex);
//            }
        }
开发者ID:trzr,项目名称:CM3D2.AlwaysColorChangeEx.Plugin,代码行数:23,代码来源:ACCTexture.cs

示例10: StartLevel

        public override void StartLevel()
        {
            var camera = Camera.main;
            var cameraWidth = camera.GetOrthographicWidth();
            var cameraHeight = camera.GetOrthographicHeight();
            bounds = new Rect( -cameraWidth / 2, -cameraHeight / 2, cameraWidth, cameraHeight );

            background.transform.localScale = new Vector3( cameraWidth, cameraHeight, 1 );
            background.sharedMaterial = Instantiate( background.sharedMaterial );

            enemyShips = new LinkedList<EnemyShip>();
            var shipConfig = new ShipConfig( 0.1f, 0.1f );
            var shipModel = new ShipModel() { Lives = 3 };
            var weaponConfig = new WeaponConfig( 5f, 1, 0.5f );

            var weapon = Locator.ResLoader.LoadAndInstantiateAs< ProjectileWeapon >( "Weapons/Cannon" );
            weapon.Init( IsRunning, TimeProvider, weaponConfig, bounds, 1 );

            var enemyShipPrefab = Locator.ResLoader.Load< GameObject >( "Ships/Enemies/LaserCorvette" );
            enemyShipPrefabLink = enemyShipPrefab.transform;
            PrefabPoolManager.Prepare( enemyShipPrefabLink, 8 );

            Player = Locator.ResLoader.LoadAndInstantiateAs< PlayerShip >( "Ships/PlayerShip" );
            Player.transform.SetParent( transform, true );
            Player.OnShipDestroyed += OnGameOver;
            Player.Init( IsRunning, TimeProvider, shipConfig, shipModel, bounds);
            Player.Weapon = weapon;

            backgroundMaterial = background.GetComponent< Renderer >().sharedMaterial;
            initialTextureOffset = backgroundMaterial.GetTextureOffset( "_MainTex" );

            if ( musicTrack != null )
                Locator.Sound.PlayMusic( musicTrack );

            base.StartLevel();
        }
开发者ID:forwolk,项目名称:HamburgTest,代码行数:36,代码来源:Level.cs

示例11: Start

 // Use this for initialization
 void Start()
 {
     myMeshRenderer = GetComponent<MeshRenderer> ();
     myMat = myMeshRenderer.material;
     origOffset = myMat.GetTextureOffset ("_MainTex");
 }
开发者ID:nigelDaMan,项目名称:WeCanTango,代码行数:7,代码来源:ScrollTexture.cs

示例12: AddSingleChannel

        public void AddSingleChannel(string channelName, string propertyName, string texturePropertyName, Material material)
        {
            float value = material.GetFloat(propertyName);
            Texture texture = material.GetTexture(texturePropertyName);
            Vector2 offset = material.GetTextureOffset(texturePropertyName);
            Vector2 scale = material.GetTextureScale(texturePropertyName);

            SingleChannel channel = new SingleChannel();
            channel.value = value;
            channel.texture = texture is Texture2D ? (texture as Texture2D) : null;
            channel.offset = offset;
            channel.scale = scale;

            this.singleChannels[channelName] = channel;
        }
开发者ID:mmerchante,项目名称:edutracing,代码行数:15,代码来源:SSDMaterial.cs

示例13: AddColorChannel

        public void AddColorChannel(string channelName, string propertyName, string texturePropertyName, Material material)
        {
            Color value = material.GetColor(propertyName);
            Texture texture = material.GetTexture(texturePropertyName);
            Vector2 offset = material.GetTextureOffset(texturePropertyName);
            Vector2 scale = material.GetTextureScale(texturePropertyName);

            ColorChannel channel = new ColorChannel();
            channel.value = value;
            channel.texture = texture is Texture2D ? (texture as Texture2D) : null;
            channel.offset = offset;
            channel.scale = scale;

            this.colorChannels[channelName] = channel;
        }
开发者ID:mmerchante,项目名称:edutracing,代码行数:15,代码来源:SSDMaterial.cs

示例14: GetValues

 /// <summary>
 /// Gets the values given a material
 /// </summary>
 /// <param name="m">The material</param>
 /// <returns>A StoredValue containing value and type information</returns>
 public List<StoredValue> GetValues(Material m)
 {
     var list = GetShaderProperties(m);
     var output = new List<StoredValue>();
     foreach (var p in list) {
         var o = new StoredValue {
             property = p
         };
         output.Add(o);
         switch (p.type) {
             case MaterialProperty.PropertyType.Color:
                 o.value = new object[1];
                 o.value[0] = m.GetColor(p.name);
                 break;
             case MaterialProperty.PropertyType.Float:
                 o.value = new object[1];
                 o.value[0] = m.GetFloat(p.name);
                 break;
             case MaterialProperty.PropertyType.Range:
                 o.value = new object[1];
                 o.value[0] = m.GetFloat(p.name);
                 break;
             case MaterialProperty.PropertyType.TexEnv:
                 o.value = new object[3];
                 o.value[0] = m.GetTexture(p.name);
                 o.value[1] = m.GetTextureOffset(p.name);
                 o.value[2] = m.GetTextureScale(p.name);
                 break;
             case MaterialProperty.PropertyType.Vector:
                 o.value = new object[1];
                 o.value[0] = m.GetVector(p.name);
                 break;
             default:
                 Debug.LogError("Unsupported type: " + p.type.ToString());
                 break;
         }
     }
     return output;
 }
开发者ID:Bloodcoder,项目名称:unityserializer-ng,代码行数:44,代码来源:StoreMaterials.cs

示例15: DumpGlossinessReflectivity

        private void DumpGlossinessReflectivity(Material material, bool metallic, BabylonPBRMaterial babylonPbrMaterial)
        {
            if (material.HasProperty("_Glossiness"))
            {
                babylonPbrMaterial.microSurface = material.GetFloat("_Glossiness");
            }

            if (metallic)
            {
                if (material.HasProperty("_Metallic"))
                {
                    var metalness = material.GetFloat("_Metallic");
                    babylonPbrMaterial.reflectivity = new float[] { metalness * babylonPbrMaterial.albedo[0],
                        metalness * babylonPbrMaterial.albedo[1],
                        metalness * babylonPbrMaterial.albedo[2] };

                    if (babylonPbrMaterial.albedoTexture != null)
                    {
                        var albedoTexture = material.GetTexture("_MainTex") as Texture2D;
                        if (albedoTexture != null)
                        {
                            var albedoPixels = GetPixels(albedoTexture);
                            var reflectivityTexture = new Texture2D(albedoTexture.width, albedoTexture.height, TextureFormat.RGBA32, false);
                            reflectivityTexture.alphaIsTransparency = true;
                            babylonPbrMaterial.useMicroSurfaceFromReflectivityMapAlpha = true;

                            var metallicTexture = material.GetTexture("_MetallicGlossMap") as Texture2D;
                            if (metallicTexture == null)
                            {
                                for (var i = 0; i < albedoTexture.width; i++)
                                {
                                    for (var j = 0; j < albedoTexture.height; j++)
                                    {
                                        albedoPixels[j * albedoTexture.width + i].r *= metalness;
                                        albedoPixels[j * albedoTexture.width + i].g *= metalness;
                                        albedoPixels[j * albedoTexture.width + i].b *= metalness;
                                        albedoPixels[j * albedoTexture.width + i].a = babylonPbrMaterial.microSurface;
                                    }
                                }
                            }
                            else
                            {
                                var metallicPixels = GetPixels(metallicTexture);
                                for (var i = 0; i < albedoTexture.width; i++)
                                {
                                    for (var j = 0; j < albedoTexture.height; j++)
                                    {
                                        var pixel = albedoPixels[j * albedoTexture.width + i];
                                        var metallicPixel = metallicPixels[j * albedoTexture.width + i];
                                        albedoPixels[j * albedoTexture.width + i].r *= metallicPixel.r;
                                        albedoPixels[j * albedoTexture.width + i].g *= metallicPixel.r;
                                        albedoPixels[j * albedoTexture.width + i].b *= metallicPixel.r;
                                        albedoPixels[j * albedoTexture.width + i].a = metallicPixel.a;
                                    }
                                }
                            }

                            reflectivityTexture.SetPixels(albedoPixels);
                            reflectivityTexture.Apply();

                            var textureName = albedoTexture.name + "_MetallicGlossMap.png";
                            var babylonTexture = new BabylonTexture { name = textureName };
                            var textureScale = material.GetTextureScale("_MainTex");
                            babylonTexture.uScale = textureScale.x;
                            babylonTexture.vScale = textureScale.y;

                            var textureOffset = material.GetTextureOffset("_MainTex");
                            babylonTexture.uOffset = textureOffset.x;
                            babylonTexture.vOffset = textureOffset.y;

                            var reflectivityTexturePath = Path.Combine(Path.GetTempPath(), textureName);
                            File.WriteAllBytes(reflectivityTexturePath, reflectivityTexture.EncodeToPNG());
                            babylonScene.AddTexture(reflectivityTexturePath);
                            if (File.Exists(reflectivityTexturePath))
                            {
                                File.Delete(reflectivityTexturePath);
                            }

                            babylonPbrMaterial.reflectivityTexture = babylonTexture;
                        }
                    }
                    //else
                    //{
                    //      TODO. Manage Albedo Cube Texture.
                    //}
                }
            }
            else
            {

                if (material.HasProperty("_SpecColor"))
                {
                    babylonPbrMaterial.reflectivity = material.GetColor("_SpecColor").ToFloat();
                }
                babylonPbrMaterial.reflectivityTexture = DumpTextureFromMaterial(material, "_SpecGlossMap");
                if (babylonPbrMaterial.reflectivityTexture != null && babylonPbrMaterial.reflectivityTexture.hasAlpha)
                {
                    babylonPbrMaterial.useMicroSurfaceFromReflectivityMapAlpha = true;
                }
            }
//.........这里部分代码省略.........
开发者ID:CreateAppAdmin,项目名称:Babylon.js,代码行数:101,代码来源:SceneBuilder.Materials.cs


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