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


C# ProceduralMaterial.GetTexture方法代码示例

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


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

示例1: RenderDiffuse

    //
    // This function creates a RenderToTexture for the diffuse map and stores it as a png in the Resources folders.
    //
    public void RenderDiffuse(ProceduralMaterial Diffuse, int slot)
    {
        GameObject rtObject = (GameObject)Instantiate(Resources.Load("RTTSubTerrain"));
        Camera cam = rtObject.transform.Find("RTTSubCamera").GetComponent<Camera>();

        // Create Render To Texture
        Vector2 TexSize = new Vector2((float)Math.Pow(2,Diffuse.GetProceduralVector("$outputsize").x), (float)Math.Pow(2,Diffuse.GetProceduralVector("$outputsize").y));
        RenderTexture rt = new RenderTexture((int)TexSize.x, (int)TexSize.y, 32);
        cam.targetTexture = rt;
        rtObject.transform.Find("RTTSubPlane").GetComponent<Renderer>().sharedMaterial.mainTexture = Diffuse.GetTexture ("_MainTex");
        cam.Render();
        RenderTexture.active = rt;
        Texture2D dif = new Texture2D((int)TexSize.x, (int)TexSize.y, TextureFormat.ARGB32, false);
        dif.ReadPixels(new Rect(0, 0, (int)TexSize.x, (int)TexSize.y), 0, 0);

        // Clean up
        cam.targetTexture = null;
        RenderTexture.active = null; // added to avoid errors
        DestroyImmediate(rt,true);
        DestroyImmediate(rtObject,true);

        // Write Diffuse map as PNG
          	byte[] bytes = dif.EncodeToPNG();
        string filename = Application.dataPath + "/SubTerrain/Resources/" + gameObject.name+"_splat" + slot.ToString() + ".png";
        System.IO.File.WriteAllBytes(filename, bytes);
        AssetDatabase.ImportAsset( "Assets/SubTerrain/Resources/" + gameObject.name+"_splat" + slot.ToString() + ".png" );

        DestroyImmediate(dif,true);
    }
开发者ID:alextalvan,项目名称:Ships2,代码行数:32,代码来源:SubTerrain.cs

示例2: ShowProceduralTexturesGUI

 protected void ShowProceduralTexturesGUI(ProceduralMaterial material)
 {
     if (base.targets.Length <= 1)
     {
         EditorGUILayout.Space();
         Shader s = material.shader;
         if (s != null)
         {
             EditorGUILayout.BeginHorizontal(new GUILayoutOption[0]);
             GUILayout.Space(4f);
             GUILayout.FlexibleSpace();
             float pixels = 10f;
             bool flag = true;
             for (int i = 0; i < ShaderUtil.GetPropertyCount(s); i++)
             {
                 if (ShaderUtil.GetPropertyType(s, i) == ShaderUtil.ShaderPropertyType.TexEnv)
                 {
                     string propertyName = ShaderUtil.GetPropertyName(s, i);
                     Texture tex = material.GetTexture(propertyName);
                     if (SubstanceImporter.IsProceduralTextureSlot(material, tex, propertyName))
                     {
                         string propertyDescription = ShaderUtil.GetPropertyDescription(s, i);
                         Type textureTypeFromDimension = MaterialEditor.GetTextureTypeFromDimension(ShaderUtil.GetTexDim(s, i));
                         GUIStyle style = "ObjectPickerResultsGridLabel";
                         if (flag)
                         {
                             flag = false;
                         }
                         else
                         {
                             GUILayout.Space(pixels);
                         }
                         GUILayoutOption[] options = new GUILayoutOption[] { GUILayout.Height(((72f + style.fixedHeight) + style.fixedHeight) + 8f) };
                         GUILayout.BeginVertical(options);
                         Rect position = GUILayoutUtility.GetRect((float) 72f, (float) 72f);
                         DoObjectPingField(position, position, GUIUtility.GetControlID(0x3042, FocusType.Keyboard, position), tex, textureTypeFromDimension);
                         this.ShowAlphaSourceGUI(material, tex as ProceduralTexture, ref position);
                         position.height = style.fixedHeight;
                         GUI.Label(position, propertyDescription, style);
                         GUILayout.EndVertical();
                         GUILayout.FlexibleSpace();
                     }
                 }
             }
             GUILayout.Space(4f);
             EditorGUILayout.EndHorizontal();
         }
     }
 }
开发者ID:CarlosHBC,项目名称:UnityDecompiled,代码行数:49,代码来源:ProceduralMaterialInspector.cs

示例3: ShowProceduralTexturesGUI

 protected void ShowProceduralTexturesGUI(ProceduralMaterial material)
 {
   if (this.targets.Length > 1)
     return;
   EditorGUILayout.Space();
   Shader shader = material.shader;
   if ((UnityEngine.Object) shader == (UnityEngine.Object) null)
     return;
   EditorGUILayout.BeginHorizontal();
   GUILayout.Space(4f);
   GUILayout.FlexibleSpace();
   float pixels = 10f;
   bool flag = true;
   for (int propertyIdx = 0; propertyIdx < ShaderUtil.GetPropertyCount(shader); ++propertyIdx)
   {
     if (ShaderUtil.GetPropertyType(shader, propertyIdx) == ShaderUtil.ShaderPropertyType.TexEnv)
     {
       string propertyName = ShaderUtil.GetPropertyName(shader, propertyIdx);
       Texture texture = material.GetTexture(propertyName);
       if (SubstanceImporter.IsProceduralTextureSlot((Material) material, texture, propertyName))
       {
         string propertyDescription = ShaderUtil.GetPropertyDescription(shader, propertyIdx);
         System.Type objType;
         switch (ShaderUtil.GetTexDim(shader, propertyIdx))
         {
           case ShaderUtil.ShaderPropertyTexDim.TexDim2D:
             objType = typeof (Texture);
             break;
           case ShaderUtil.ShaderPropertyTexDim.TexDim3D:
             objType = typeof (Texture3D);
             break;
           case ShaderUtil.ShaderPropertyTexDim.TexDimCUBE:
             objType = typeof (Cubemap);
             break;
           case ShaderUtil.ShaderPropertyTexDim.TexDimAny:
             objType = typeof (Texture);
             break;
           default:
             objType = (System.Type) null;
             break;
         }
         GUIStyle style = (GUIStyle) "ObjectPickerResultsGridLabel";
         if (flag)
           flag = false;
         else
           GUILayout.Space(pixels);
         GUILayout.BeginVertical(GUILayout.Height((float) (72.0 + (double) style.fixedHeight + (double) style.fixedHeight + 8.0)));
         Rect rect = GUILayoutUtility.GetRect(72f, 72f);
         ProceduralMaterialInspector.DoObjectPingField(rect, rect, GUIUtility.GetControlID(12354, EditorGUIUtility.native, rect), (UnityEngine.Object) texture, objType);
         this.ShowAlphaSourceGUI(material, texture as ProceduralTexture, ref rect);
         rect.height = style.fixedHeight;
         GUI.Label(rect, propertyDescription, style);
         GUILayout.EndVertical();
         GUILayout.FlexibleSpace();
       }
     }
   }
   GUILayout.Space(4f);
   EditorGUILayout.EndHorizontal();
 }
开发者ID:BlakeTriana,项目名称:unity-decompiled,代码行数:60,代码来源:ProceduralMaterialInspector.cs

示例4: ShowProceduralTexturesGUI

        protected void ShowProceduralTexturesGUI(ProceduralMaterial material)
        {
            if (base.targets.Length <= 1)
            {
                EditorGUILayout.Space();
                Shader s = material.shader;
                if (s != null)
                {
                    EditorGUILayout.BeginHorizontal(new GUILayoutOption[0]);
                    GUILayout.Space(4f);
                    GUILayout.FlexibleSpace();
                    float pixels = 10f;
                    bool flag = true;
                    for (int i = 0; i < ShaderUtil.GetPropertyCount(s); i++)
                    {
                        if (ShaderUtil.GetPropertyType(s, i) != ShaderUtil.ShaderPropertyType.TexEnv)
                        {
                            continue;
                        }
                        string propertyName = ShaderUtil.GetPropertyName(s, i);
                        Texture tex = material.GetTexture(propertyName);
                        if (SubstanceImporter.IsProceduralTextureSlot(material, tex, propertyName))
                        {
                            System.Type type;
                            string propertyDescription = ShaderUtil.GetPropertyDescription(s, i);
                            switch (ShaderUtil.GetTexDim(s, i))
                            {
                                case ShaderUtil.ShaderPropertyTexDim.TexDim2D:
                                    type = typeof(Texture);
                                    break;

                                case ShaderUtil.ShaderPropertyTexDim.TexDim3D:
                                    type = typeof(Texture3D);
                                    break;

                                case ShaderUtil.ShaderPropertyTexDim.TexDimCUBE:
                                    type = typeof(Cubemap);
                                    break;

                                case ShaderUtil.ShaderPropertyTexDim.TexDimAny:
                                    type = typeof(Texture);
                                    break;

                                default:
                                    type = null;
                                    break;
                            }
                            GUIStyle style = "ObjectPickerResultsGridLabel";
                            if (flag)
                            {
                                flag = false;
                            }
                            else
                            {
                                GUILayout.Space(pixels);
                            }
                            GUILayoutOption[] options = new GUILayoutOption[] { GUILayout.Height(((72f + style.fixedHeight) + style.fixedHeight) + 8f) };
                            GUILayout.BeginVertical(options);
                            Rect position = GUILayoutUtility.GetRect((float) 72f, (float) 72f);
                            DoObjectPingField(position, position, GUIUtility.GetControlID(0x3042, EditorGUIUtility.native, position), tex, type);
                            this.ShowAlphaSourceGUI(material, tex as ProceduralTexture, ref position);
                            position.height = style.fixedHeight;
                            GUI.Label(position, propertyDescription, style);
                            GUILayout.EndVertical();
                            GUILayout.FlexibleSpace();
                        }
                    }
                    GUILayout.Space(4f);
                    EditorGUILayout.EndHorizontal();
                }
            }
        }
开发者ID:randomize,项目名称:VimConfig,代码行数:72,代码来源:ProceduralMaterialInspector.cs

示例5: ShowProceduralTexturesGUI

		protected void ShowProceduralTexturesGUI(ProceduralMaterial material)
		{
			if (base.targets.Length > 1)
			{
				return;
			}
			EditorGUILayout.Space();
			Shader shader = material.shader;
			if (shader == null)
			{
				return;
			}
			EditorGUILayout.BeginHorizontal(new GUILayoutOption[0]);
			GUILayout.Space(4f);
			GUILayout.FlexibleSpace();
			float pixels = 10f;
			bool flag = true;
			for (int i = 0; i < ShaderUtil.GetPropertyCount(shader); i++)
			{
				if (ShaderUtil.GetPropertyType(shader, i) == ShaderUtil.ShaderPropertyType.TexEnv)
				{
					string propertyName = ShaderUtil.GetPropertyName(shader, i);
					Texture texture = material.GetTexture(propertyName);
					if (SubstanceImporter.IsProceduralTextureSlot(material, texture, propertyName))
					{
						string propertyDescription = ShaderUtil.GetPropertyDescription(shader, i);
						Type objType;
						switch (ShaderUtil.GetTexDim(shader, i))
						{
						case ShaderUtil.ShaderPropertyTexDim.TexDim2D:
							objType = typeof(Texture);
							break;
						case ShaderUtil.ShaderPropertyTexDim.TexDim3D:
							objType = typeof(Texture3D);
							break;
						case ShaderUtil.ShaderPropertyTexDim.TexDimCUBE:
							objType = typeof(Cubemap);
							break;
						case ShaderUtil.ShaderPropertyTexDim.TexDimAny:
							objType = typeof(Texture);
							break;
						default:
							objType = null;
							break;
						}
						GUIStyle gUIStyle = "ObjectPickerResultsGridLabel";
						if (flag)
						{
							flag = false;
						}
						else
						{
							GUILayout.Space(pixels);
						}
						GUILayout.BeginVertical(new GUILayoutOption[]
						{
							GUILayout.Height(72f + gUIStyle.fixedHeight + gUIStyle.fixedHeight + 8f)
						});
						Rect rect = GUILayoutUtility.GetRect(72f, 72f);
						ProceduralMaterialInspector.DoObjectPingField(rect, rect, GUIUtility.GetControlID(12354, EditorGUIUtility.native, rect), texture, objType);
						this.ShowAlphaSourceGUI(material, texture as ProceduralTexture, ref rect);
						rect.height = gUIStyle.fixedHeight;
						GUI.Label(rect, propertyDescription, gUIStyle);
						GUILayout.EndVertical();
						GUILayout.FlexibleSpace();
					}
				}
			}
			GUILayout.Space(4f);
			EditorGUILayout.EndHorizontal();
		}
开发者ID:guozanhua,项目名称:UnityDecompiled,代码行数:71,代码来源:ProceduralMaterialInspector.cs


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