Replace string shader properties to id

This commit is contained in:
2017-08-06 02:24:45 +07:00
parent 9f7f0e5a2b
commit 5611da7a7c
4 changed files with 20 additions and 14 deletions

View File

@@ -2,6 +2,7 @@
* Not save generated meshes in scene
* Fix (At line 908 of file "FTMain.jsfl": ReferenceError: ft is not defined)
* Fix warning on add missing components
* Replace string shader properties to id
* Replace shader "if" instruction to "step"
###### Version 1.3.8

View File

@@ -11,15 +11,20 @@ namespace FTRuntime {
#endif
public class SwfClip : MonoBehaviour {
MeshFilter _meshFilter = null;
MeshRenderer _meshRenderer = null;
MeshFilter _meshFilter = null;
MeshRenderer _meshRenderer = null;
#if UNITY_5_6_OR_NEWER
SortingGroup _sortingGroup = null;
SortingGroup _sortingGroup = null;
#endif
bool _dirtyMesh = true;
SwfClipAsset.Sequence _curSequence = null;
MaterialPropertyBlock _curPropBlock = null;
bool _dirtyMesh = true;
SwfClipAsset.Sequence _curSequence = null;
MaterialPropertyBlock _curPropBlock = null;
static readonly int _tintShaderProp = Shader.PropertyToID("_Tint");
static readonly int _mainTexShaderProp = Shader.PropertyToID("_MainTex");
static readonly int _alphaTexShaderProp = Shader.PropertyToID("_AlphaTex");
static readonly int _externalAlphaShaderProp = Shader.PropertyToID("_ExternalAlpha");
// ---------------------------------------------------------------------
//
@@ -389,19 +394,19 @@ namespace FTRuntime {
_curPropBlock = new MaterialPropertyBlock();
}
_meshRenderer.GetPropertyBlock(_curPropBlock);
_curPropBlock.SetColor("_Tint", tint);
_curPropBlock.SetColor(_tintShaderProp, tint);
var sprite = clip ? clip.Sprite : null;
var atlas = sprite && sprite.texture ? sprite.texture : Texture2D.whiteTexture;
var atlasA = sprite ? sprite.associatedAlphaSplitTexture : null;
_curPropBlock.SetTexture(
"_MainTex",
_mainTexShaderProp,
atlas ? atlas : Texture2D.whiteTexture);
if ( atlasA ) {
_curPropBlock.SetTexture("_AlphaTex", atlasA);
_curPropBlock.SetFloat("_ExternalAlpha", 1.0f);
_curPropBlock.SetTexture(_alphaTexShaderProp, atlasA);
_curPropBlock.SetFloat(_externalAlphaShaderProp, 1.0f);
} else {
_curPropBlock.SetTexture("_AlphaTex", Texture2D.whiteTexture);
_curPropBlock.SetFloat("_ExternalAlpha", 0.0f);
_curPropBlock.SetTexture(_alphaTexShaderProp, Texture2D.whiteTexture);
_curPropBlock.SetFloat(_externalAlphaShaderProp, 0.0f);
}
_meshRenderer.SetPropertyBlock(_curPropBlock);
}

View File

@@ -2,7 +2,7 @@
public static class SwfVersion {
public const int Major = 1;
public const int Minor = 3;
public const int Revision = 8;
public const int Revision = 9;
public static string AsString {
get {

View File

@@ -60,7 +60,7 @@ https://gist.github.com/talecrafter/111ea3345911bd238f4998b4d5a04bf3
можно использовать ISerializationCallbackReceiver
можно в hideFlags на меше поиграться!
**** TODO Поддержка задавать теги и сплит текстур на альфу для etc
**** TODO Заменить установку пропертей шейдера с текстовых имён на id
**** DONE Заменить установку пропертей шейдера с текстовых имён на id
**** DONE Заюзать step вместо if в шейдере
https://web.archive.org/web/20161214092913/http://http.developer.nvidia.com:80/Cg/step.html
*** Баги