FairyGUI.MaterialManager.GetInstance C# (CSharp) Method

GetInstance() public static method

public static GetInstance ( NTexture texture, string shaderName, string keywords ) : MaterialManager
texture NTexture
shaderName string
keywords string
return MaterialManager
        public static MaterialManager GetInstance(NTexture texture, string shaderName, string[] keywords)
        {
            NTexture rootTexture = texture.root;
            if (rootTexture.materialManagers == null)
                rootTexture.materialManagers = new Dictionary<string, MaterialManager>();

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

            MaterialManager mm;
            if (!rootTexture.materialManagers.TryGetValue(key, out mm))
            {
                mm = new MaterialManager(rootTexture);
                mm.shaderName = shaderName;
                mm._keywords = keywords;
                rootTexture.materialManagers.Add(key, mm);
            }

            return mm;
        }

Usage Example

示例#1
0
文件: NGraphics.cs 项目: mengtest/u1
        void UpdateManager()
        {
            if (_manager != null)
            {
                _manager.Release();
            }

            if (_texture != null)
            {
                _manager = MaterialManager.GetInstance(_texture, _shader, _materialKeywords);
            }
            else
            {
                _manager = null;
            }
        }
All Usage Examples Of FairyGUI.MaterialManager::GetInstance