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);
            }
        }
    }
Esempio n. 2
0
 private void SpawnExploder()
 {
     exploderParent.DestroyChildren();
     exploder = Instantiate(exploderPrefab, exploderParent);
     exploder.transform.localPosition = Vector3.zero;
     exploder.transform.localRotation = Quaternion.identity;
     explosionForce = exploder.GetComponent <ExplosionForce>();
 }
Esempio n. 3
0
    public void Explode()
    {
        Debug.Log("Mouse down");
        _explodable.GetComponent <Rigidbody2D>().simulated = true;
        _explodable.explode();
        ExplosionForce ef = GameObject.FindObjectOfType <ExplosionForce>();

        ef.doExplosion(transform.position);
    }