當前位置: 首頁>>代碼示例>>C#>>正文


C# ProceduralMaterial.GetProceduralVector方法代碼示例

本文整理匯總了C#中UnityEngine.ProceduralMaterial.GetProceduralVector方法的典型用法代碼示例。如果您正苦於以下問題:C# ProceduralMaterial.GetProceduralVector方法的具體用法?C# ProceduralMaterial.GetProceduralVector怎麽用?C# ProceduralMaterial.GetProceduralVector使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在UnityEngine.ProceduralMaterial的用法示例。


在下文中一共展示了ProceduralMaterial.GetProceduralVector方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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


注:本文中的UnityEngine.ProceduralMaterial.GetProceduralVector方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。