コード例 #1
0
        public override bool SetTextureOnMaterial(string fieldName, ImageData id, PlaytimePainter pntr)
        {
            //  if (id == null)
            //    return;

            Texture tex = id.CurrentTexture();

            if (pntr.terrain != null)
            {
                if (fieldName.Contains(PainterDataAndConfig.terrainLight))
                {
                    FindMergingTerrain(pntr);
                    if ((mergingTerrain != null) && (id != null))
                    {
                        mergingTerrain.lightTexture = id.texture2D;
                    }

#if UNITY_EDITOR
                    if (tex is Texture2D)
                    {
                        UnityEditor.TextureImporter timp = ((Texture2D)tex).GetTextureImporter();
                        if (timp != null)
                        {
                            bool needReimport = timp.WasClamped();
                            needReimport |= timp.HadNoMipmaps();

                            if (needReimport)
                            {
                                timp.SaveAndReimport();
                            }
                        }
                    }
#endif

                    Shader.SetGlobalTexture(PainterDataAndConfig.terrainLight, tex);



                    return(true);
                }
            }
            return(false);
        }
コード例 #2
0
        public override bool SetTextureOnMaterial(string fieldName, ImageData id, PlaytimePainter painter)
        {
            Texture tex = id.CurrentTexture();

            if (painter.terrain != null)
            {
                if (fieldName.Contains(PainterDataAndConfig.terrainTexture))
                {
                    int no = fieldName[0].CharToInt();
                    painter.terrain.SetSplashPrototypeTexture(id.texture2D, no);
                    if (tex.GetType() != typeof(Texture2D))
                    {
                        //else
                        Debug.Log("Can only use Texture2D for Splat Prototypes. If using regular terrain may not see changes.");
                    }
                    else
                    {
#if UNITY_EDITOR
                        UnityEditor.TextureImporter timp = ((Texture2D)tex).GetTextureImporter();
                        if (timp != null)
                        {
                            bool needReimport = timp.WasClamped();
                            needReimport |= timp.HadNoMipmaps();

                            if (needReimport)
                            {
                                timp.SaveAndReimport();
                            }
                        }
#endif
                    }
                    return(true);
                }
            }
            return(false);
        }