示例#1
0
    void OnLoadSuccess(NTexture texture)
    {
        if (string.IsNullOrEmpty(this.url))
            return;

        this.onExternalLoadSuccess(texture);
    }
示例#2
0
        public static MaterialManager GetInstance(NTexture texture, string shaderName)
        {
            NTexture rootTexture = texture.root;
            if (rootTexture.materialManagers == null)
                rootTexture.materialManagers = new Dictionary<string, MaterialManager>();

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

            if (mm.sharedMaterial == null)
            {
                Shader shader = ShaderConfig.Get(shaderName);
                if (shader == null)
                {
                    Debug.LogWarning("FairyGUI: shader not found: " + shaderName);
                    shader = Shader.Find("Transparent/Diffuse");
                }
                mm.sharedMaterial = new Material(shader);
                mm.sharedMaterial.mainTexture = rootTexture.nativeTexture;
                if (rootTexture.alphaTexture != null)
                    mm.sharedMaterial.SetTexture("_AlphaTex", rootTexture.alphaTexture);
            }

            return mm;
        }
示例#3
0
 static public int DestroyMaterials(IntPtr l)
 {
     try {
         FairyGUI.NTexture self = (FairyGUI.NTexture)checkSelf(l);
         self.DestroyMaterials();
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
示例#4
0
 static public int get_height(IntPtr l)
 {
     try {
         FairyGUI.NTexture self = (FairyGUI.NTexture)checkSelf(l);
         pushValue(l, true);
         pushValue(l, self.height);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
示例#5
0
 static public int get_materialManagers(IntPtr l)
 {
     try {
         FairyGUI.NTexture self = (FairyGUI.NTexture)checkSelf(l);
         pushValue(l, true);
         pushValue(l, self.materialManagers);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
        public MaterialManager(NTexture texture)
        {
            this.texture = texture;

            _pools = new MaterialPool[7];
            _pools[0] = new MaterialPool(this, null, false); //none
            _pools[1] = new MaterialPool(this, GRAYED, false); //grayed
            _pools[2] = new MaterialPool(this, CLIPPED, false); //clipped
            _pools[3] = new MaterialPool(this, CLIPPED_GRAYED, false); //clipped+grayed
            _pools[4] = new MaterialPool(this, SOFT_CLIPPED, false); //softClipped
            _pools[5] = new MaterialPool(this, SOFT_CLIPPED_GRAYED, false); //softClipped+grayed
            _pools[6] = new MaterialPool(this, ALPHA_MASK, true); //stencil mask
        }
示例#7
0
 static public int set_refCount(IntPtr l)
 {
     try {
         FairyGUI.NTexture self = (FairyGUI.NTexture)checkSelf(l);
         System.Int32      v;
         checkType(l, 2, out v);
         self.refCount = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
示例#8
0
 static int Dispose(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         FairyGUI.NTexture obj = (FairyGUI.NTexture)ToLua.CheckObject <FairyGUI.NTexture>(L, 1);
         obj.Dispose();
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
示例#9
0
 static public int set_storedODisk(IntPtr l)
 {
     try {
         FairyGUI.NTexture self = (FairyGUI.NTexture)checkSelf(l);
         System.Boolean    v;
         checkType(l, 2, out v);
         self.storedODisk = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
示例#10
0
 static public int set_alphaTexture(IntPtr l)
 {
     try {
         FairyGUI.NTexture self = (FairyGUI.NTexture)checkSelf(l);
         FairyGUI.NTexture v;
         checkType(l, 2, out v);
         self.alphaTexture = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
示例#11
0
 static int DestroyMaterials(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         FairyGUI.NTexture obj = (FairyGUI.NTexture)ToLua.CheckObject(L, 1, typeof(FairyGUI.NTexture));
         obj.DestroyMaterials();
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
示例#12
0
 static public int set_lastActive(IntPtr l)
 {
     try {
         FairyGUI.NTexture self = (FairyGUI.NTexture)checkSelf(l);
         System.Single     v;
         checkType(l, 2, out v);
         self.lastActive = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
示例#13
0
 static int GetUV(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         FairyGUI.NTexture     obj  = (FairyGUI.NTexture)ToLua.CheckObject <FairyGUI.NTexture>(L, 1);
         UnityEngine.Vector2[] arg0 = ToLua.CheckStructArray <UnityEngine.Vector2>(L, 2);
         obj.GetUV(arg0);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
示例#14
0
 static int MonitorTexture(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         FairyGUI.Stage    obj  = (FairyGUI.Stage)ToLua.CheckObject <FairyGUI.Stage>(L, 1);
         FairyGUI.NTexture arg0 = (FairyGUI.NTexture)ToLua.CheckObject <FairyGUI.NTexture>(L, 2);
         obj.MonitorTexture(arg0);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
示例#15
0
        public NTexture(NTexture root, Rect region)
        {
            this.root = root;
            nativeTexture = root.nativeTexture;

            if (root._region != null)
            {
                region.x += ((Rect)root._region).x;
                region.y += ((Rect)root._region).y;
            }
            _region = region;

            uvRect = new Rect(region.x * root.uvRect.width / nativeTexture.width, 1 - region.yMax * root.uvRect.height / nativeTexture.height,
                region.width * root.uvRect.width / nativeTexture.width, region.height * root.uvRect.height / nativeTexture.height);
        }
示例#16
0
    static int _CreateFairyGUI_NTexture(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 1)
            {
                UnityEngine.Texture arg0 = (UnityEngine.Texture)ToLua.CheckUnityObject(L, 1, typeof(UnityEngine.Texture));
                FairyGUI.NTexture   obj  = new FairyGUI.NTexture(arg0);
                ToLua.PushObject(L, obj);
                return(1);
            }
            else if (count == 2 && TypeChecker.CheckTypes(L, 1, typeof(UnityEngine.Texture), typeof(UnityEngine.Rect)))
            {
                UnityEngine.Texture arg0 = (UnityEngine.Texture)ToLua.CheckUnityObject(L, 1, typeof(UnityEngine.Texture));
                UnityEngine.Rect    arg1 = (UnityEngine.Rect)ToLua.CheckObject(L, 2, typeof(UnityEngine.Rect));
                FairyGUI.NTexture   obj  = new FairyGUI.NTexture(arg0, arg1);
                ToLua.PushObject(L, obj);
                return(1);
            }
            else if (count == 2 && TypeChecker.CheckTypes(L, 1, typeof(FairyGUI.NTexture), typeof(UnityEngine.Rect)))
            {
                FairyGUI.NTexture arg0 = (FairyGUI.NTexture)ToLua.CheckObject(L, 1, typeof(FairyGUI.NTexture));
                UnityEngine.Rect  arg1 = (UnityEngine.Rect)ToLua.CheckObject(L, 2, typeof(UnityEngine.Rect));
                FairyGUI.NTexture obj  = new FairyGUI.NTexture(arg0, arg1);
                ToLua.PushObject(L, obj);
                return(1);
            }
            else if (count == 3 && TypeChecker.CheckTypes(L, 1, typeof(UnityEngine.Texture), typeof(float), typeof(float)))
            {
                UnityEngine.Texture arg0 = (UnityEngine.Texture)ToLua.CheckUnityObject(L, 1, typeof(UnityEngine.Texture));
                float             arg1   = (float)LuaDLL.luaL_checknumber(L, 2);
                float             arg2   = (float)LuaDLL.luaL_checknumber(L, 3);
                FairyGUI.NTexture obj    = new FairyGUI.NTexture(arg0, arg1, arg2);
                ToLua.PushObject(L, obj);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to ctor method: FairyGUI.NTexture.New"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
示例#17
0
 static int Reload(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 3);
         FairyGUI.NTexture   obj  = (FairyGUI.NTexture)ToLua.CheckObject <FairyGUI.NTexture>(L, 1);
         UnityEngine.Texture arg0 = (UnityEngine.Texture)ToLua.CheckObject <UnityEngine.Texture>(L, 2);
         UnityEngine.Texture arg1 = (UnityEngine.Texture)ToLua.CheckObject <UnityEngine.Texture>(L, 3);
         obj.Reload(arg0, arg1);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
示例#18
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));
     }
 }
示例#19
0
    static int get_nativeTexture(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            FairyGUI.NTexture   obj = (FairyGUI.NTexture)o;
            UnityEngine.Texture ret = obj.nativeTexture;
            ToLua.Push(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index nativeTexture on a nil value"));
        }
    }
示例#20
0
    static int set_rotated(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            FairyGUI.NTexture obj = (FairyGUI.NTexture)o;
            bool arg0             = LuaDLL.luaL_checkboolean(L, 2);
            obj.rotated = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index rotated on a nil value"));
        }
    }
示例#21
0
    static int set_originalSize(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            FairyGUI.NTexture   obj  = (FairyGUI.NTexture)o;
            UnityEngine.Vector2 arg0 = ToLua.ToVector2(L, 2);
            obj.originalSize = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index originalSize on a nil value"));
        }
    }
示例#22
0
    static int set_destroyMethod(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            FairyGUI.NTexture      obj  = (FairyGUI.NTexture)o;
            FairyGUI.DestroyMethod arg0 = (FairyGUI.DestroyMethod)ToLua.CheckObject(L, 2, typeof(FairyGUI.DestroyMethod));
            obj.destroyMethod = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index destroyMethod on a nil value"));
        }
    }
示例#23
0
    static int set_alphaTexture(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            FairyGUI.NTexture obj  = (FairyGUI.NTexture)o;
            FairyGUI.NTexture arg0 = (FairyGUI.NTexture)ToLua.CheckObject(L, 2, typeof(FairyGUI.NTexture));
            obj.alphaTexture = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index alphaTexture on a nil value" : e.Message));
        }
    }
示例#24
0
    static int get_mainTexture(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            FairyGUI.BaseFont obj = (FairyGUI.BaseFont)o;
            FairyGUI.NTexture ret = obj.mainTexture;
            ToLua.PushObject(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index mainTexture on a nil value"));
        }
    }
示例#25
0
    static int set_lastActive(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            FairyGUI.NTexture obj  = (FairyGUI.NTexture)o;
            float             arg0 = (float)LuaDLL.luaL_checknumber(L, 2);
            obj.lastActive = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index lastActive on a nil value" : e.Message));
        }
    }
示例#26
0
    static int set_storedODisk(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            FairyGUI.NTexture obj = (FairyGUI.NTexture)o;
            bool arg0             = LuaDLL.luaL_checkboolean(L, 2);
            obj.storedODisk = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index storedODisk on a nil value" : e.Message));
        }
    }
示例#27
0
    static int get_height(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            FairyGUI.NTexture obj = (FairyGUI.NTexture)o;
            int ret = obj.height;
            LuaDLL.lua_pushinteger(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index height on a nil value" : e.Message));
        }
    }
示例#28
0
    static int set_refCount(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            FairyGUI.NTexture obj = (FairyGUI.NTexture)o;
            int arg0 = (int)LuaDLL.luaL_checknumber(L, 2);
            obj.refCount = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index refCount on a nil value" : e.Message));
        }
    }
示例#29
0
    static int get_materialManagers(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            FairyGUI.NTexture obj = (FairyGUI.NTexture)o;
            System.Collections.Generic.Dictionary <string, FairyGUI.MaterialManager> ret = obj.materialManagers;
            ToLua.PushObject(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index materialManagers on a nil value" : e.Message));
        }
    }
示例#30
0
    static int get_alphaTexture(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            FairyGUI.NTexture obj = (FairyGUI.NTexture)o;
            FairyGUI.NTexture ret = obj.alphaTexture;
            ToLua.PushObject(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index alphaTexture on a nil value" : e.Message));
        }
    }
示例#31
0
    static int set_mainTexture(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            FairyGUI.BaseFont obj  = (FairyGUI.BaseFont)o;
            FairyGUI.NTexture arg0 = (FairyGUI.NTexture)ToLua.CheckObject <FairyGUI.NTexture>(L, 2);
            obj.mainTexture = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index mainTexture on a nil value"));
        }
    }
示例#32
0
    static int get_storedODisk(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            FairyGUI.NTexture obj = (FairyGUI.NTexture)o;
            bool ret = obj.storedODisk;
            LuaDLL.lua_pushboolean(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index storedODisk on a nil value" : e.Message));
        }
    }
示例#33
0
    static int get_uvRect(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            FairyGUI.NTexture obj = (FairyGUI.NTexture)o;
            UnityEngine.Rect  ret = obj.uvRect;
            ToLua.PushValue(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index uvRect on a nil value" : e.Message));
        }
    }
示例#34
0
    static int get_lastActive(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            FairyGUI.NTexture obj = (FairyGUI.NTexture)o;
            float             ret = obj.lastActive;
            LuaDLL.lua_pushnumber(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index lastActive on a nil value" : e.Message));
        }
    }
        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;
        }
示例#36
0
文件: Stage.cs 项目: yinlei/Fishing
 public void MonitorTexture(NTexture texture)
 {
     if (_toCollectTextures.IndexOf(texture) == -1)
         _toCollectTextures.Add(texture);
 }
示例#37
0
文件: Image.cs 项目: yinlei/Fishing
        void Create(NTexture texture)
        {
            _optimizeNotTouchable = true;
            _fillClockwise = true;

            CreateGameObject("Image");
            graphics = new NGraphics(gameObject);
            graphics.shader = ShaderConfig.imageShader;

            _color = Color.white;
            if (texture != null)
                UpdateTexture(texture);
        }
示例#38
0
文件: Image.cs 项目: yinlei/Fishing
        protected virtual void UpdateTexture(NTexture value)
        {
            if (value == _texture)
                return;

            _requireUpdateMesh = true;
            _texture = value;
            if (_contentRect.width == 0)
                SetNativeSize();
            graphics.texture = _texture;
            InvalidateBatchingState();
        }
示例#39
0
文件: Image.cs 项目: yinlei/Fishing
 public Image(NTexture texture)
     : base()
 {
     Create(texture);
 }
示例#40
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="shader"></param>
 /// <param name="texture"></param>
 public void SetShaderAndTexture(string shader, NTexture texture)
 {
     _shader = shader;
     _texture = texture;
     if (_customMatarial && _material != null)
         _material.mainTexture = _texture != null ? _texture.nativeTexture : null;
     UpdateManager();
 }
示例#41
0
 protected void onExternalLoadSuccess(NTexture texture)
 {
     _content.texture = texture;
     _contentSourceWidth = texture.width;
     _contentSourceHeight = texture.height;
     UpdateLayout();
 }
示例#42
0
 protected virtual void FreeExternal(NTexture texture)
 {
 }
示例#43
0
 protected void onExternalLoadSuccess(NTexture texture)
 {
     _content.texture = texture;
     _contentSourceWidth = texture.width;
     _contentSourceHeight = texture.height;
     _content.scale9Grid = null;
     _content.scaleByTile = false;
     UpdateLayout();
 }
示例#44
0
 public MaterialManager(NTexture owner)
 {
     _owner = owner;
 }
示例#45
0
 public static void DisposeEmpty()
 {
     if (_empty != null)
     {
         if (_empty.nativeTexture != null)
         {
             Texture.DestroyImmediate(_empty.nativeTexture);
             _empty.nativeTexture = null;
         }
         _empty.Dispose();
         _empty = null;
     }
 }
示例#46
0
        void textureRebuildCallback(Font font)
        {
            mainTexture = new NTexture( font.material.mainTexture );

            if ( !_callingValidate )
                Stage.inst.onPostUpdate.Add( ValidateTextFields );
            //Debug.Log("Font texture rebuild: " + name + "," + mainTexture.width + "," + mainTexture.height);
        }
示例#47
0
 /// <summary>
 /// 
 /// </summary>
 public static void DisposeEmpty()
 {
     if (_empty != null)
     {
         _empty.Dispose(true);
         _empty = null;
     }
 }
        void textureRebuildCallback(Font targetFont)
        {
            if (_font != targetFont)
                return;
            mainTexture = new NTexture(_font.material.mainTexture);

            textRebuildFlag = true;
            //Debug.Log("Font texture rebuild: " + name + "," + mainTexture.width + "," + mainTexture.height);
        }
示例#49
0
        public virtual void Update(UpdateContext context)
        {
            if (graphics != null)
            {
                graphics.alpha = context.alpha * _alpha;
                graphics.grayed = context.grayed | _grayed;
                graphics.UpdateMaterial(context);
            }

            if (_paintingMode != 0)
            {
                NTexture paintingTexture = paintingGraphics.texture;
                if (paintingTexture != null && paintingTexture.disposed) //Texture可能已被Stage.MonitorTexture销毁
                {
                    paintingTexture = null;
                    _paintingFlag = 1;
                }
                if (_paintingFlag == 1)
                {
                    _paintingFlag = 0;

                    //从优化考虑,决定使用绘画模式的容器都需要明确指定大小,而不是自动计算包围。这在UI使用上并没有问题,因为组件总是有固定大小的
                    int textureWidth = Mathf.RoundToInt(_contentRect.width + _paintingMargin.left + _paintingMargin.right);
                    int textureHeight = Mathf.RoundToInt(_contentRect.height + _paintingMargin.top + _paintingMargin.bottom);
                    if (paintingTexture == null || paintingTexture.width != textureWidth || paintingTexture.height != textureHeight)
                    {
                        if (paintingTexture != null)
                            paintingTexture.Dispose(true);
                        if (textureWidth > 0 && textureHeight > 0)
                        {
                            paintingTexture = new NTexture(CaptureCamera.CreateRenderTexture(textureWidth, textureHeight, false));
                            Stage.inst.MonitorTexture(paintingTexture);
                        }
                        else
                            paintingTexture = null;
                        paintingGraphics.texture = paintingTexture;
                    }

                    if (paintingGraphics.material == null)
                    {
                        paintingGraphics.material = new Material(ShaderConfig.GetShader(ShaderConfig.imageShader));
                        paintingGraphics.material.hideFlags = DisplayOptions.hideFlags;
                    }

                    if (paintingTexture != null)
                    {
                        paintingGraphics.SetOneQuadMesh(
                            new Rect(-_paintingMargin.left, -_paintingMargin.top, paintingTexture.width, paintingTexture.height),
                            new Rect(0, 0, 1, 1), Color.white);
                    }
                    else
                        paintingGraphics.ClearMesh();
                }

                if (paintingTexture != null)
                {
                    paintingTexture.lastActive = Time.time;

                    if (!(this is Container)) //如果是容器,这句移到Container.Update的最后执行,因为容器中可能也有需要Capture的内容,要等他们完成后再进行容器的Capture。
                        UpdateContext.OnEnd += _captureDelegate;
                }

                paintingGraphics.UpdateMaterial(context);
            }

            if (_filter != null)
                _filter.Update();

            Stats.ObjectCount++;
        }
        void textureRebuildCallback()
        {
            mainTexture = new NTexture(_font.material.mainTexture);

            textRebuildFlag = true;

            //Debug.Log("Font texture rebuild: " + name + "," + mainTexture.width + "," + mainTexture.height);
        }
示例#51
0
 protected void onExternalLoadSuccess(NTexture texture)
 {
     _image.texture = texture;
     _contentSourceWidth = texture.width;
     _contentSourceHeight = texture.height;
     _activeObject = _image;
     UpdateLayout();
 }
示例#52
0
 protected override void FreeExternal(NTexture texture)
 {
     texture.refCount--;
 }
    IEnumerator Run()
    {
        _started = true;

        LoadItem item = null;
        while (true)
        {
            if (_items.Count > 0)
            {
                item = _items[0];
                _items.RemoveAt(0);
            }
            else
                break;

            if (_pool.ContainsKey(item.url))
            {
                //Debug.Log("hit " + item.url);

                NTexture texture = (NTexture)_pool[item.url];
                texture.refCount++;

                if (item.onSuccess != null)
                    item.onSuccess(texture);

                continue;
            }

            WWW www = new WWW(_basePath + item.url + ".ab");
            yield return www;

            if (string.IsNullOrEmpty(www.error))
            {
                AssetBundle bundle = www.assetBundle;
                if (bundle == null)
                {
                    Debug.LogWarning("Run Window->Build FairyGUI example Bundles first.");
                    if (item.onFail != null)
                        item.onFail(www.error);
                    continue;
                }
        #if UNITY_5
                NTexture texture = new NTexture(bundle.LoadAllAssets<Texture2D>()[0]);
        #else
                NTexture texture = new NTexture((Texture2D)bundle.mainAsset);
        #endif
                texture.refCount++;
                bundle.Unload(false);

                _pool[item.url] = texture;

                if (item.onSuccess != null)
                    item.onSuccess(texture);
            }
            else
            {
                if (item.onFail != null)
                    item.onFail(www.error);
            }
        }

        _started = false;
    }
示例#54
0
 protected virtual void FreeExternal(NTexture texture)
 {
     texture.Dispose();
 }
        public void SetData(NTexture texture, Frame[] frames, Rect boundsRect)
        {
            this.frames = frames;
            this.frameCount = frames.Length;
            _contentRect = boundsRect;

            if (_end == -1 || _end > frameCount - 1)
                _end = frameCount - 1;
            if (_endAt == -1 || _endAt > frameCount - 1)
                _endAt = frameCount - 1;
            playState.Rewind();

            graphics.texture = texture;
            OnSizeChanged(true, true);
            InvalidateBatchingState();
            _forceDraw = true;
        }
示例#56
0
        public void Create(NTexture texture)
        {
            quadBatch = new QuadBatch(gameObject);
            quadBatch.shader = ShaderConfig.imageShader;

            _texture = texture;
            _color = Color.white;
            if (_texture != null)
            {
                contentRect.width = _texture.width;
                contentRect.height = _texture.height;
                UpdateTexture();
            }
            optimizeNotTouchable = true;
            scaleOverrided = true;
        }