Exemple #1
0
    void CleanUp(bool forceDelete)
    {
        int levelCount = configuration.LevelCount(MadLevel.Type.Level);
        var children   = MadTransform.FindChildren <MadLevelIcon>(transform, (icon) => icon.hasLevelConfiguration);

        if (forceDelete)
        {
            foreach (var child in children)
            {
                MadGameObject.SafeDestroy(child.gameObject);
            }
        }
        else
        {
            var sorted = from c in children orderby c.levelIndex ascending select c;

            foreach (MadLevelIcon levelIcon in sorted)
            {
                if (levelIcon.levelIndex >= levelCount)
                {
                    // disable leftovers
                    MadGameObject.SetActive(levelIcon.gameObject, false);
                }
            }
        }
    }
Exemple #2
0
    private void Finish()
    {
        Anim(1);

        if (sendMessageOnFinish)
        {
            GameObject receiver = gameObject;
            if (messageReceiver != null)
            {
                receiver = messageReceiver;
            }

            receiver.SendMessage(messageName);
        }

        if (playAnimationOnFinish && !string.IsNullOrEmpty(playAnimationOnFinishName))
        {
            MadAnim.PlayAnimation(gameObject, playAnimationOnFinishName, playAnimationOnFinishFromTheBeginning);
        }

        if (destroyObjectOnFinish)
        {
            MadGameObject.SafeDestroy(gameObject);
        }
        isPlaying = false;

        if (!string.IsNullOrEmpty(animationQueue))
        {
            PlayAnimationNow(gameObject, animationQueue);
        }
    }
    void RebuildClean()
    {
        var generated = MadTransform.FindChildren <MadSprite>(transform, (sprite) => sprite.name.StartsWith("generated_"));

        foreach (var obj in generated)
        {
            MadGameObject.SafeDestroy(obj.gameObject);
        }
    }
Exemple #4
0
    public void Destroy()
    {
        MadGameObject.SetActive(gameObject, false);

#if UNITY_EDITOR
        EditorApplication.delayCall += () => {
            DestroyImmediate(gameObject);
        };
#else
        MadGameObject.SafeDestroy(gameObject);
#endif
    }
Exemple #5
0
 // if a scene has only one Main Camera object, then init tool proposes to remove it
 private static void CheckEmptyScene()
 {
     if (SceneHasOnlyMainCamera())
     {
         bool remove = EditorUtility.DisplayDialog(
             "Remove Main Camera?",
             "Your scene seems to have only the Main Camera object. If you're not planning to use it, it's recommended to remove it.",
             "Remove", "Leave");
         if (remove)
         {
             var mainCamera = GameObject.Find("/Main Camera");
             MadGameObject.SafeDestroy(mainCamera);
         }
     }
 }
Exemple #6
0
    void OnEnable()
    {
        panels.Add(this);

        materialStore = GetComponent <MadMaterialStore>();

        var meshRenderer = gameObject.GetComponent <MeshRenderer>();

        if (meshRenderer != null)
        {
            MadGameObject.SafeDestroy(meshRenderer);
        }

        var meshFilter = gameObject.GetComponent <MeshFilter>();

        if (meshFilter != null)
        {
            MadGameObject.SafeDestroy(meshFilter);
        }
    }
Exemple #7
0
    // if a scene has only one Main Camera object, then init tool proposes to remove it
    private static void CheckEmptyScene()
    {
        if (SceneIsNewlyCreated())
        {
            bool remove = EditorUtility.DisplayDialog(
                "Remove Unused Objects?",
                "It seems that this is a newly created scene. Level select screen do not need the Main Camera or Directional Light objects. If you're not planning to use it, it's recommended to remove it.",
                "Remove", "Leave");
            if (remove)
            {
                var mainCamera = GameObject.Find("/Main Camera");
                if (mainCamera != null)
                {
                    MadGameObject.SafeDestroy(mainCamera);
                }

                var light = GameObject.Find("/Directional Light");
                if (light != null)
                {
                    MadGameObject.SafeDestroy(light);
                }
            }
        }
    }
 public void RemoveLayer(MadLevelBackgroundLayer layer)
 {
     MadGameObject.SafeDestroy(layer.gameObject);
     layers.Remove(layer);
 }