//---------------------------------------------------------------------------------------// /// <summary> /// Sets the scale of the material, flipping the UV's if we know the texture orientation is incorrect for Unity /// </summary> /// <param name="mat"></param> /// <param name="orientation"></param> private static void SetScale(ref Material mat, GLTFImage.TextureOrientation orientation, string textureName = "", string propertyName = "") //---------------------------------------------------------------------------------------// { var scale = mat.mainTextureScale; scale.x = orientation.IsXFlipped ? -1 : 1; scale.y = orientation.IsYFlipped ? -1 : 1; mat.SetTextureScale(propertyName, scale); //Debug.Log( "GLTFMaterial SetScale() " + mat.name + " [ " + textureName + "] [ " + mat.GetTextureScale( propertyName ) + " ]" ); } //END SetScale
/// <summary> Create or return cached texture </summary> public IEnumerator GetTextureCached(bool linear, Action <Texture2D, GLTFImage.TextureOrientation> onFinish, Action <float> onProgress = null) { if (cache == null) { yield return(StaticCoroutine.Start(image.CreateTextureAsync(linear, (x, y) => { cache = x; orientation = y; }, image.mimeType, onProgress))); } onFinish(cache, orientation); }