Ledger Nano X - The secure hardware wallet
SHARE
TWEET

TilePhysicsFix

HeroicMaou Feb 11th, 2020 (edited) 156 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Just download script, Import into project, and open Window/Tile Physics Fix.
  2. //After this, Instructions are shown in window but will also be reiterated here.
  3. //Drag Tile Assets Into Array
  4. //Click Go
  5. //Test Play Once To Update
  6.  
  7. using UnityEngine;
  8. using UnityEditor;
  9. using UnityEngine.Tilemaps;
  10.  
  11. public class TilePhysicsFix : MonoBehaviour
  12. {
  13.     public static void FixPhysics(Tile[] tiles)
  14.     {
  15.         for (int i = 0; i < tiles.Length; i++)
  16.         {
  17.             int PhysicsShape = tiles[i].sprite.GetPhysicsShapeCount();
  18.             if (PhysicsShape == 0)
  19.             {
  20.                 tiles[i].colliderType = Tile.ColliderType.None;
  21.             }
  22.             else if (PhysicsShape >= 1)
  23.             {
  24.                 tiles[i].colliderType = Tile.ColliderType.Sprite;
  25.             }
  26.         }
  27.     }
  28. }
  29.  
  30. public class TilePhysicsFixWindow : EditorWindow
  31. {
  32.     public Tile[] tiles;
  33.  
  34.     [MenuItem("Window/Tile Physics Fix")]
  35.     public static void ShowWindow()
  36.     {
  37.         EditorWindow.GetWindow(typeof(TilePhysicsFixWindow));
  38.     }
  39.     void OnGUI()
  40.     {
  41.         EditorGUILayout.LabelField("Drag Tile Assets Into Array");
  42.         EditorGUILayout.LabelField("Click Go");
  43.         EditorGUILayout.LabelField("Test Play Once To Update");
  44.         ScriptableObject scriptableObj = this;
  45.         SerializedObject serialObj = new SerializedObject(scriptableObj);
  46.         SerializedProperty serialProp = serialObj.FindProperty("tiles");
  47.         EditorGUILayout.PropertyField(serialProp, true);
  48.         serialObj.ApplyModifiedProperties();
  49.         if (GUILayout.Button("Go"))
  50.         {
  51.             TilePhysicsFix.FixPhysics(tiles);
  52.         }
  53.     }
  54. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top