deleteFragments() public method

public deleteFragments ( ) : void
return void
    public override void OnInspectorGUI()
    {
        Explodable myTarget = (Explodable)target;

        myTarget.allowRuntimeFragmentation = EditorGUILayout.Toggle("Allow Runtime Fragmentation", myTarget.allowRuntimeFragmentation);
        myTarget.shatterType     = (Explodable.ShatterType)EditorGUILayout.EnumPopup("Shatter Type", myTarget.shatterType);
        myTarget.extraPoints     = EditorGUILayout.IntField("Extra Points", myTarget.extraPoints);
        myTarget.subshatterSteps = EditorGUILayout.IntField("Subshatter Steps", myTarget.subshatterSteps);
        if (myTarget.subshatterSteps > 1)
        {
            EditorGUILayout.HelpBox("Use subshatter steps with caution! Too many will break performance!!! Don't recommend more than 1", MessageType.Warning);
        }

        myTarget.fragmentLayer    = EditorGUILayout.TextField("Fragment Layer", myTarget.fragmentLayer);
        myTarget.sortingLayerName = EditorGUILayout.TextField("Sorting Layer", myTarget.sortingLayerName);
        myTarget.orderInLayer     = EditorGUILayout.IntField("Order In Layer", myTarget.orderInLayer);

        if (myTarget.GetComponent <PolygonCollider2D>() == null && myTarget.GetComponent <BoxCollider2D>() == null)
        {
            EditorGUILayout.HelpBox("You must add a BoxCollider2D or PolygonCollider2D to explode this sprite", MessageType.Warning);
        }
        else
        {
            if (GUILayout.Button("Generate Fragments"))
            {
                myTarget.fragmentInEditor();
                EditorUtility.SetDirty(myTarget);
            }
            if (GUILayout.Button("Destroy Fragments"))
            {
                myTarget.deleteFragments();
                EditorUtility.SetDirty(myTarget);
            }
        }
    }
 protected override void Awake()
 {
     base.Awake();
     curHealth = maxHealth;
     coll      = GetComponent <Collider2D>();
     expl      = GetComponent <Explodable>();
     if (expl != null)
     {
         expl.deleteFragments();
         addon = GetComponent <MyFragmentsAddon>();
     }
 }
    public override void OnInspectorGUI()
    {
        Explodable myTarget = (Explodable)target;

        myTarget.allowRuntimeFragmentation = EditorGUILayout.Toggle("Allow Runtime Fragmentation", myTarget.allowRuntimeFragmentation);
        myTarget.DestroyPiecesAfterHit     = EditorGUILayout.Toggle("Destroy Pieces After Hit", myTarget.DestroyPiecesAfterHit);

        this.DrawDefaultInspectorWithoutScriptField();
        myTarget.UseGravityOnFragments = EditorGUILayout.Toggle("Use Gravity On Fragments", myTarget.UseGravityOnFragments);

        myTarget.ColliderTypeParent    = (ColliderType)EditorGUILayout.EnumPopup("Collider Type", myTarget.ColliderTypeParent);
        myTarget.ParentColliderWidth   = EditorGUILayout.FloatField("Parent Collider Width", myTarget.ParentColliderWidth);
        myTarget.ChildrenColliderWidth = EditorGUILayout.FloatField("Children Collider Width", myTarget.ChildrenColliderWidth);
        myTarget.shatterType           = (Explodable.ShatterType)EditorGUILayout.EnumPopup("Shatter Type", myTarget.shatterType);
        myTarget.extraPoints           = EditorGUILayout.IntField("Extra Points", myTarget.extraPoints);
        myTarget.subshatterSteps       = EditorGUILayout.IntField("Subshatter Steps", myTarget.subshatterSteps);
        if (myTarget.subshatterSteps > 1)
        {
            EditorGUILayout.HelpBox("Use subshatter steps with caution! Too many will break performance!!! Don't recommend more than 1", MessageType.Warning);
        }

        myTarget.fragmentLayer    = EditorGUILayout.TextField("Fragment Layer", myTarget.fragmentLayer);
        myTarget.sortingLayerName = EditorGUILayout.TextField("Sorting Layer", myTarget.sortingLayerName);
        myTarget.orderInLayer     = EditorGUILayout.IntField("Order In Layer", myTarget.orderInLayer);

        if (GUILayout.Button("Generate Fragments"))
        {
            myTarget.fragmentInEditor();
            EditorUtility.SetDirty(myTarget);
        }

        if (GUILayout.Button("Destroy Fragments"))
        {
            myTarget.deleteFragments();
            EditorUtility.SetDirty(myTarget);
        }
    }
示例#4
0
    private IEnumerator DestroyAfterDelay(float delay, Explodable _explodable)
    {
        yield return(new WaitForSeconds(delay));

        _explodable.deleteFragments();
    }