示例#1
0
 protected virtual void ResetAllRigidBodyValues()
 {
     Rigidbody2D[] v_allRigidInScene = KiltUtils.FindAllComponentsOfType <Rigidbody2D>(false);
     foreach (Rigidbody2D v_body in v_allRigidInScene)
     {
         KiltUtils.ClearRigidBody2D(v_body);
     }
 }
    private void AttachAllRopesToNewObject(GameObject p_newObject)
    {
        if (p_newObject != null && p_newObject.GetComponent <Rigidbody2D>() != null && this.GetComponent <Rigidbody2D>() != null)
        {
            if (Application.isPlaying)
            {
                RopesAttached v_attachedComponent = GetComponent <RopesAttached>();
                if (v_attachedComponent != null)
                {
                    foreach (Rope2D v_rope in v_attachedComponent.PluggedRopes)
                    {
                        if (v_rope.GetRigidBody2DFromObject(v_rope.ObjectA) == this.GetComponent <Rigidbody2D>())
                        {
                            v_rope.ObjectA = p_newObject;
                        }
                        if (v_rope.GetRigidBody2DFromObject(v_rope.ObjectB) == this.GetComponent <Rigidbody2D>())
                        {
                            v_rope.ObjectB = p_newObject;
                        }
                    }
                }
            }
            else
            {
                Rope2D[] v_arrayOfRopes = KiltUtils.FindAllComponentsOfType <Rope2D>(true);
                foreach (Rope2D v_rope in v_arrayOfRopes)
                {
                    bool v_changed = false;
                    if (v_rope.GetRigidBody2DFromObject(v_rope.ObjectA) == this.GetComponent <Rigidbody2D>())
                    {
                        v_changed      = true;
                        v_rope.ObjectA = p_newObject;
                    }
                    if (v_rope.GetRigidBody2DFromObject(v_rope.ObjectB) == this.GetComponent <Rigidbody2D>())
                    {
                        v_changed      = true;
                        v_rope.ObjectB = p_newObject;
                    }

                    if (v_changed)
                    {
                        ApplyModificationsInEditMode(v_rope);
                    }
                }
            }
        }
    }
 public static void RecreateAllBlockSelectors()
 {
     BlockSelector[] v_selectorsInScene = KiltUtils.FindAllComponentsOfType <BlockSelector>();
     foreach (BlockSelector v_selector in v_selectorsInScene)
     {
         if (v_selector != null)
         {
             v_selector.CorrectSelectedPrefabIndex();
             if (v_selector.SelectedObject != null)
             {
                 v_selector.InstantiateObjectByPrefab(v_selector.SelectedObject, true, true, true);
             }
             else
             {
                 Debug.Log("Fail Update Object with name \'" + v_selector.name + "\'. Select this object and update by yourself.");
             }
         }
     }
 }