fragmentInEditor() public method

Creates fragments and then disables them
public fragmentInEditor ( ) : 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);
            }
        }
    }
示例#2
0
    void Awake()
    {
        m_Explodable = GameObject.Instantiate(Resources.Load("Prefabs/HuLuBroken") as GameObject).GetComponent <Explodable>();
        m_Explodable.m_ObjParents = m_ObjParent;

        m_Explodable.fragmentInEditor();
        m_Explodable.transform.SetParent(this.transform);
        m_Explodable.transform.localPosition = Vector3.zero;
        m_Explodable.transform.eulerAngles   = Vector3.zero;
        m_Explodable.transform.localScale    = Vector3.one;
    }
示例#3
0
 public override void OnFragmentsGenerated(List <GameObject> fragments)
 {
     foreach (GameObject fragment in fragments)
     {
         Explodable explodable = fragment.AddComponent <Explodable>();
         explodable.shatterType      = base.explodable.shatterType;
         explodable.fragmentLayer    = base.explodable.fragmentLayer;
         explodable.sortingLayerName = base.explodable.sortingLayerName;
         explodable.orderInLayer     = base.explodable.orderInLayer;
         fragment.layer = base.explodable.gameObject.layer;
         explodable.fragmentInEditor();
     }
 }
    public void Die()
    {
        GameObject explodingPlayer = Instantiate(explodingPlayerPrefab, transform.position + new Vector3(0, 1, 0), Quaternion.identity);
        Explodable explodable      = explodingPlayer.GetComponent <Explodable>();

        explodable.fragmentInEditor();
        explodable.explode();
        explodable.setVelocity(GetComponent <Rigidbody2D>().velocity);
        Destroy(this.gameObject);
        onDied.Invoke();
        Time.timeScale      = 1f;
        Time.fixedDeltaTime = 0.02F * Time.timeScale;
    }
    // Start is called before the first frame update
    void Start()
    {
        life            = this.GetComponentInParent <BlockCreater>().Life;
        angularVelocity = this.GetComponentInParent <BlockCreater>().angularVelocity;
        explodable      = GetComponent <Explodable>();
        this.GetComponent <Rigidbody2D>().angularVelocity = angularVelocity;

        Quaternion tempRotation = this.GetComponentInParent <BlockCreater>().transform.rotation;

        //Debug.Log(tempRotation);

        this.GetComponentInParent <BlockCreater>().transform.rotation = new Quaternion(0f, 0f, 0f, 0f);
        explodable.fragmentInEditor();
        this.GetComponentInParent <BlockCreater>().transform.rotation = tempRotation;
        this.GetComponent <SpriteRenderer>().color = new Color(1f, 1f, 1f, 0f);
        if (this.GetComponentInParent <Animator>() != null)
        {
            this.GetComponentInParent <Animator>().enabled = true;
        }
    }
    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);
        }
    }