示例#1
0
        /// <summary>
        ///
        /// </summary>
        public MaterialManager GetMaterialManager(string shaderName, string[] keywords)
        {
            if (_root != this)
            {
                return(_root.GetMaterialManager(shaderName, keywords));
            }

            if (_materialManagers == null)
            {
                _materialManagers = new Dictionary <string, MaterialManager>();
            }

            string key = shaderName;

            if (keywords != null)
            {
                //对于带指定关键字的,目前的设计是不参加共享材质了,因为逻辑会变得更复杂
                key = shaderName + "_" + _gCounter++;
            }

            MaterialManager mm;

            if (!_materialManagers.TryGetValue(key, out mm))
            {
                mm             = new MaterialManager(this, ShaderConfig.GetShader(shaderName), keywords);
                mm._managerKey = key;
                _materialManagers.Add(key, mm);
            }

            return(mm);
        }
示例#2
0
        void Init()
        {
            Release();

            mainTexture = new NTexture(_fontAsset.atlasTexture);
            mainTexture.destroyMethod = DestroyMethod.None;

            _manager = mainTexture.GetMaterialManager(this.shader);
            _manager.onCreateNewMaterial += OnCreateNewMaterial;

            _material = new Material(_fontAsset.material); //copy
            _material.SetFloat(ShaderUtilities.ID_TextureWidth, mainTexture.width);
            _material.SetFloat(ShaderUtilities.ID_TextureHeight, mainTexture.height);
            _material.SetFloat(ShaderUtilities.ID_GradientScale, fontAsset.atlasPadding + 1);
            _material.SetFloat(ShaderUtilities.ID_WeightNormal, fontAsset.normalStyle);
            _material.SetFloat(ShaderUtilities.ID_WeightBold, fontAsset.boldStyle);

            // _ascent = _fontAsset.faceInfo.ascentLine;
            // _lineHeight = _fontAsset.faceInfo.lineHeight;
            _ascent     = _fontAsset.faceInfo.pointSize;
            _lineHeight = _fontAsset.faceInfo.pointSize * 1.25f;

            bool          isAlternativeTypeface;
            TMP_FontAsset actualAsset;

            _lineChar = TMP_FontAssetUtilities.GetCharacterFromFontAsset('_', _fontAsset, true, FontStyles.Normal, _fontWeight, out isAlternativeTypeface, out actualAsset);
        }
示例#3
0
        /// <summary>
        ///
        /// </summary>
        public MaterialManager GetMaterialManager(string shaderName)
        {
            if (_root != this)
            {
                if (_root == null)
                {
                    return(null);
                }
                else
                {
                    return(_root.GetMaterialManager(shaderName));
                }
            }

            if (_materialManagers == null)
            {
                _materialManagers = new Dictionary <string, MaterialManager>();
            }

            MaterialManager mm;

            if (!_materialManagers.TryGetValue(shaderName, out mm))
            {
                mm = new MaterialManager(this, ShaderConfig.GetShader(shaderName));
                _materialManagers.Add(shaderName, mm);
            }

            return(mm);
        }
示例#4
0
        void UpdateManager()
        {
            if (_manager != null)
            {
                _manager.Release();
            }

            if (_texture != null)
            {
                _manager = _texture.GetMaterialManager(_shader, _materialKeywords);
            }
            else
            {
                _manager = null;
            }
        }
示例#5
0
 static int GetMaterialManager(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         FairyGUI.NTexture        obj  = (FairyGUI.NTexture)ToLua.CheckObject <FairyGUI.NTexture>(L, 1);
         string                   arg0 = ToLua.CheckString(L, 2);
         FairyGUI.MaterialManager o    = obj.GetMaterialManager(arg0);
         ToLua.PushObject(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
示例#6
0
        void UpdateManager()
        {
            MaterialManager mm;

            if (_texture != null)
            {
                mm = _texture.GetMaterialManager(_shader, _materialKeywords);
            }
            else
            {
                mm = null;
            }
            if (_manager != null && _manager != mm)
            {
                _manager.Release();
            }
            _manager = mm;
        }