ConvertUnityTextureToTextureDescription(string textureName, UnityEngine.Texture unityTexture) { var result = new Model.AnimatedExportObjectModelDescription.MaterialsDescription.Texture(); result.name = textureName; result.width = unityTexture.width; result.height = unityTexture.height; if (unityTexture.GetType() == typeof(Texture2D)) { result.pixels = ((Texture2D)unityTexture).GetPixels(TEXTURE_MIPMAP_LEVEL) .Select(x => new Model.AnimatedExportObjectModelDescription.MaterialsDescription.Color(x.r, x.g, x.b, x.a)).ToList(); } else { throw new InvalidOperationException("Mesh texture is not Texture2D!"); } return(result); }
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); // } }
public void setReference(Texture tex, bool mipped, bool fix) { if(locked) return; if( tex && tex.GetType() == typeof(Cubemap) ) { input = tex; cube = tex as Cubemap; } else if( tex && tex.GetType() == typeof(Texture2D) && allowTexture ) { input = tex; cube = null; } else { clear(); return; } fullPath = ""; mipmapped = mipped; updatePath(); updateInput(fix); }