protected void DestroyHidden(GameObject go, bool forceImmediate) {
        if (forceImmediate) {
            GameObject.DestroyImmediate(go);
        } else {
			MadGameObjectDestroy.SafeDestroy(go);
        }
    }
    protected override void Rebuild() {
        base.Rebuild();

        // remove all hidden child sprites
        var hidden = MadTransform.FindChildren<MadSprite>(
            transform, (s) => s.gameObject.hideFlags == HideFlags.HideInHierarchy);
        for (int i = 0; i < hidden.Count; ++i) {
			MadGameObjectDestroy.SafeDestroy(hidden[i].gameObject);
        }
    
        int nextDepth = guiDepth * DepthSpace;
        
        // build background
        nextDepth = BuildBackgroundTextures(nextDepth);

        // build the bar        
        if (textureBar != null) {
            if (effectBurn) {
                spriteBurnBar = CreateHidden<MadSprite>("bar_effect_burn");
                spriteBurnBar.guiDepth = nextDepth++;

                if (TextureValid(effectBurnTextureBar, atlasEffectBurnTextureBarGUID)) {
                    SetTexture(spriteBurnBar, effectBurnTextureBar, atlasEffectBurnTextureBarGUID);
                } else {
                    SetTexture(spriteBurnBar, textureBar, atlasTextureBarGUID);
                }
                
                spriteBurnBar.fillType = ToFillType(growDirection);
                spriteBurnBar.radialFillOffset = radialOffset;
                spriteBurnBar.radialFillLength = radialLength;
            }
        
            spriteBar = CreateHidden<MadSprite>("bar");
            spriteBar.guiDepth = nextDepth++;

            SetTexture(spriteBar, textureBar, atlasTextureBarGUID);
            
            spriteBar.fillType = ToFillType(growDirection);
            spriteBar.radialFillOffset = radialOffset;
            spriteBar.radialFillLength = radialLength;
        }
        
        // build foreground textures
        nextDepth = BuildForegroundTextures(nextDepth);
        
        // follow effect
        if (effectFollow) {
            if (effectFollowObject != null && effectFollowObject is Texture2D) {
                effectFollowSprite = CreateHidden<MadSprite>("bar_effect_follow");
                effectFollowSprite.texture = effectFollowObject as Texture2D;
                effectFollowSprite.guiDepth = nextDepth++;
            }
        }
        
        nextDepth = RebuildLabel(nextDepth);

        UpdateContainer();
    }
    protected override void Rebuild() {
        base.Rebuild();
        
        // remove used sprites
        if (spriteBar != null) {
			MadGameObjectDestroy.SafeDestroy(spriteBar.gameObject);
        }
        
        int nextDepth = guiDepth * DepthSpace;
        
        nextDepth = BuildBackgroundTextures(nextDepth);
        nextDepth = BuildBar(nextDepth);
        nextDepth = BuildForegroundTextures(nextDepth);
        nextDepth = RebuildLabel(nextDepth);

        UpdateContainer();
    }
    protected virtual void Rebuild() {
#if MAD_DEBUG
        Debug.Log("rebuilding " + this, this);
#endif

        spriteObjectsBg.Clear();
        spriteObjectsFg.Clear();

        DestroyAllHidden();

        // as a precaution I will search for hidden sprites at level 0
        var hidden = MadTransform.FindChildren<MadSprite>(transform, (s) => (s.hideFlags | HideFlags.HideInHierarchy) != 0, 0);
        if (hidden.Count > 0) {
            Debug.Log("There were " + hidden.Count + " hidden unmanaged sprites under this bar. I will remove them.");
            for (int i = 0; i < hidden.Count; ++i) {
				MadGameObjectDestroy.SafeDestroy(hidden[i].gameObject);
            }
        }
    }
Exemple #5
0
        protected void RemoveCreatedChildren()
        {
            for (int i = 0; i < createdChildren.Count; ++i)
            {
                MadGameObjectDestroy.SafeDestroy(createdChildren[i]);
            }

            // scan for generated children that were not removed
            // this is needed when user performs an undo operation
            var existingChildren = MadTransform.FindChildren <Transform>(transform, c => c.name.StartsWith("generated_"), 0);

            for (int i = 0; i < existingChildren.Count; i++)
            {
                var child = existingChildren[i];
                MadGameObjectDestroy.SafeDestroy(child.gameObject);
            }

            createdChildren.Clear();
            backgroundBinds.Clear();
            foregroundBinds.Clear();
        }