diff --git a/Assets/IsoTools/Examples/Scenes/Scene10.unity b/Assets/IsoTools/Examples/Scenes/Scene10.unity index 99feb74..97dfdb4 100644 --- a/Assets/IsoTools/Examples/Scenes/Scene10.unity +++ b/Assets/IsoTools/Examples/Scenes/Scene10.unity @@ -91,110 +91,36 @@ NavMeshSettings: cellSize: 0.16666667 accuratePlacement: 0 m_NavMeshData: {fileID: 0} ---- !u!1001 &872182016 +--- !u!1001 &147835927 Prefab: m_ObjectHideFlags: 0 serializedVersion: 2 m_Modification: - m_TransformParent: {fileID: 0} + m_TransformParent: {fileID: 2048596123} m_Modifications: - target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} propertyPath: m_LocalPosition.x - value: 1.1380608 + value: 2.2000003 objectReference: {fileID: 0} - target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} propertyPath: m_LocalPosition.y - value: -3.30561 + value: -1.0999999 objectReference: {fileID: 0} - target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} propertyPath: m_LocalPosition.z - value: 1.2 + value: 1.3000001 objectReference: {fileID: 0} - target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} propertyPath: m_LocalRotation.x - value: 0 + value: -0 objectReference: {fileID: 0} - target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} propertyPath: m_LocalRotation.y - value: 0 + value: -0 objectReference: {fileID: 0} - target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} propertyPath: m_LocalRotation.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} - propertyPath: m_LocalRotation.w - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} - propertyPath: m_RootOrder - value: 4 - objectReference: {fileID: 0} - - target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} - propertyPath: _position.x - value: -1.2439 - objectReference: {fileID: 0} - - target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} - propertyPath: _position.y - value: -1.7612 - objectReference: {fileID: 0} - - target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} - propertyPath: _position.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} - propertyPath: _showTheirDepends - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} - propertyPath: _showIsoBounds - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} - propertyPath: _showScreenBounds - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} - propertyPath: _showSelfDepends - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 180122, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} - propertyPath: m_Name - value: TileA (3) - objectReference: {fileID: 0} - m_RemovedComponents: [] - m_ParentPrefab: {fileID: 100100000, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} - m_IsPrefabParent: 0 ---- !u!1001 &1124268487 -Prefab: - m_ObjectHideFlags: 0 - serializedVersion: 2 - m_Modification: - m_TransformParent: {fileID: 0} - m_Modifications: - - target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} - propertyPath: m_LocalPosition.x - value: 0.71808 - objectReference: {fileID: 0} - - target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} - propertyPath: m_LocalPosition.y - value: 0.020240039 - objectReference: {fileID: 0} - - target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} - propertyPath: m_LocalPosition.z - value: 1.5000001 - objectReference: {fileID: 0} - - target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} - propertyPath: m_LocalRotation.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} - propertyPath: m_LocalRotation.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} - propertyPath: m_LocalRotation.z - value: 0 + value: -0 objectReference: {fileID: 0} - target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} propertyPath: m_LocalRotation.w @@ -206,11 +132,11 @@ Prefab: objectReference: {fileID: 0} - target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} propertyPath: _position.x - value: 0.1724 + value: -0 objectReference: {fileID: 0} - target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} propertyPath: _position.y - value: -0.154 + value: -1 objectReference: {fileID: 0} - target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} propertyPath: _position.z @@ -232,6 +158,10 @@ Prefab: propertyPath: _showSelfDepends value: 0 objectReference: {fileID: 0} + - target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + propertyPath: m_Enabled + value: 1 + objectReference: {fileID: 0} - target: {fileID: 180122, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} propertyPath: m_Name value: TileA (2) @@ -239,34 +169,143 @@ Prefab: m_RemovedComponents: [] m_ParentPrefab: {fileID: 100100000, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} m_IsPrefabParent: 0 ---- !u!1 &1396455878 +--- !u!4 &147835928 stripped +Transform: + m_PrefabParentObject: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + m_PrefabInternal: {fileID: 147835927} +--- !u!1001 &488606076 +Prefab: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 2048596123} + m_Modifications: + - target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + propertyPath: m_LocalPosition.x + value: 0.00000047683716 + objectReference: {fileID: 0} + - target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + propertyPath: m_LocalPosition.y + value: -2.2 + objectReference: {fileID: 0} + - target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + propertyPath: m_LocalPosition.z + value: 1.2 + objectReference: {fileID: 0} + - target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + propertyPath: m_LocalRotation.x + value: -0 + objectReference: {fileID: 0} + - target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + propertyPath: m_LocalRotation.y + value: -0 + objectReference: {fileID: 0} + - target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + propertyPath: m_LocalRotation.z + value: -0 + objectReference: {fileID: 0} + - target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + propertyPath: m_RootOrder + value: 2 + objectReference: {fileID: 0} + - target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + propertyPath: _position.x + value: -1 + objectReference: {fileID: 0} + - target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + propertyPath: _position.y + value: -1 + objectReference: {fileID: 0} + - target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + propertyPath: _position.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + propertyPath: _showTheirDepends + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + propertyPath: _showIsoBounds + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + propertyPath: _showScreenBounds + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + propertyPath: _showSelfDepends + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + propertyPath: m_Enabled + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 180122, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + propertyPath: m_Name + value: TileA (1) + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 100100000, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + m_IsPrefabParent: 0 +--- !u!4 &488606077 stripped +Transform: + m_PrefabParentObject: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + m_PrefabInternal: {fileID: 488606076} +--- !u!1 &522845241 GameObject: m_ObjectHideFlags: 0 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 0} serializedVersion: 5 m_Component: - - component: {fileID: 1396455884} - - component: {fileID: 1396455883} - - component: {fileID: 1396455882} - - component: {fileID: 1396455881} - - component: {fileID: 1396455880} - - component: {fileID: 1396455879} + - component: {fileID: 522845242} + - component: {fileID: 522845244} + - component: {fileID: 522845243} m_Layer: 0 - m_Name: Camera - m_TagString: MainCamera + m_Name: IsoWorld (1) + m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!114 &1396455879 +--- !u!4 &522845242 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 522845241} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: -2.1996753, y: 1.1002207, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 1378790441} + - {fileID: 620192726} + m_Father: {fileID: 2048596123} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &522845243 MonoBehaviour: m_ObjectHideFlags: 0 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 1396455878} + m_GameObject: {fileID: 522845241} m_Enabled: 1 m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: f1e3b581728784cafa59b549fe35214b, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!114 &522845244 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 522845241} + m_Enabled: 0 + m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: 3f01619d3802e814f86f9e6bb965349a, type: 3} m_Name: m_EditorClassIdentifier: @@ -278,7 +317,337 @@ MonoBehaviour: _startDepth: 1 _showIsoBounds: 0 _showScreenBounds: 0 - _showDepends: 0 + _showDepends: 1 + _snappingEnabled: 1 +--- !u!1001 &620192725 +Prefab: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 522845242} + m_Modifications: + - target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + propertyPath: m_LocalPosition.x + value: 2.1996753 + objectReference: {fileID: 0} + - target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + propertyPath: m_LocalPosition.y + value: -1.1002207 + objectReference: {fileID: 0} + - target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + propertyPath: m_LocalPosition.z + value: 1.5000001 + objectReference: {fileID: 0} + - target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + propertyPath: m_LocalRotation.x + value: -0 + objectReference: {fileID: 0} + - target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + propertyPath: m_LocalRotation.y + value: -0 + objectReference: {fileID: 0} + - target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + propertyPath: m_LocalRotation.z + value: -0 + objectReference: {fileID: 0} + - target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + propertyPath: m_RootOrder + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + propertyPath: _position.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + propertyPath: _position.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + propertyPath: _position.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + propertyPath: _showTheirDepends + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + propertyPath: _showIsoBounds + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + propertyPath: _showScreenBounds + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + propertyPath: _showSelfDepends + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + propertyPath: m_Enabled + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 180122, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + propertyPath: m_Name + value: TileA (2) + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 100100000, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + m_IsPrefabParent: 0 +--- !u!4 &620192726 stripped +Transform: + m_PrefabParentObject: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + m_PrefabInternal: {fileID: 620192725} +--- !u!1001 &821196789 +Prefab: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 1019705740} + m_Modifications: + - target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + propertyPath: m_LocalPosition.x + value: -0.00021076202 + objectReference: {fileID: 0} + - target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + propertyPath: m_LocalPosition.y + value: -2.2004635 + objectReference: {fileID: 0} + - target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + propertyPath: m_LocalPosition.z + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + propertyPath: m_LocalRotation.x + value: -0 + objectReference: {fileID: 0} + - target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + propertyPath: m_LocalRotation.y + value: -0 + objectReference: {fileID: 0} + - target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + propertyPath: m_LocalRotation.z + value: -0 + objectReference: {fileID: 0} + - target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + propertyPath: m_RootOrder + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + propertyPath: _position.x + value: -1 + objectReference: {fileID: 0} + - target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + propertyPath: _position.y + value: -2 + objectReference: {fileID: 0} + - target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + propertyPath: _position.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + propertyPath: _showTheirDepends + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + propertyPath: _showIsoBounds + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + propertyPath: _showScreenBounds + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + propertyPath: _showSelfDepends + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + propertyPath: m_Enabled + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 180122, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + propertyPath: m_Name + value: TileA (1) + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 100100000, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + m_IsPrefabParent: 0 +--- !u!4 &821196790 stripped +Transform: + m_PrefabParentObject: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + m_PrefabInternal: {fileID: 821196789} +--- !u!1 &1019705739 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 5 + m_Component: + - component: {fileID: 1019705740} + - component: {fileID: 1019705742} + - component: {fileID: 1019705741} + m_Layer: 0 + m_Name: IsoWorld (2) + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &1019705740 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1019705739} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 2.2002115, y: -1.0995364, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 821196790} + - {fileID: 2135046319} + m_Father: {fileID: 2048596123} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &1019705741 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1019705739} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: f1e3b581728784cafa59b549fe35214b, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!114 &1019705742 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1019705739} + m_Enabled: 0 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 3f01619d3802e814f86f9e6bb965349a, type: 3} + m_Name: + m_EditorClassIdentifier: + _tileSize: 2.2 + _tileRatio: 0.5 + _tileAngle: 45 + _tileHeight: 1.6 + _stepDepth: 0.1 + _startDepth: 1 + _showIsoBounds: 0 + _showScreenBounds: 0 + _showDepends: 1 + _snappingEnabled: 1 +--- !u!1001 &1378790440 +Prefab: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 522845242} + m_Modifications: + - target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + propertyPath: m_LocalPosition.x + value: -0.0003244877 + objectReference: {fileID: 0} + - target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + propertyPath: m_LocalPosition.y + value: -2.2002208 + objectReference: {fileID: 0} + - target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + propertyPath: m_LocalPosition.z + value: 1.4000001 + objectReference: {fileID: 0} + - target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + propertyPath: m_LocalRotation.x + value: -0 + objectReference: {fileID: 0} + - target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + propertyPath: m_LocalRotation.y + value: -0 + objectReference: {fileID: 0} + - target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + propertyPath: m_LocalRotation.z + value: -0 + objectReference: {fileID: 0} + - target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + propertyPath: m_RootOrder + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + propertyPath: _position.x + value: -1 + objectReference: {fileID: 0} + - target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + propertyPath: _position.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + propertyPath: _position.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + propertyPath: _showTheirDepends + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + propertyPath: _showIsoBounds + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + propertyPath: _showScreenBounds + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + propertyPath: _showSelfDepends + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + propertyPath: m_Enabled + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 180122, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + propertyPath: m_Name + value: TileA (1) + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 100100000, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + m_IsPrefabParent: 0 +--- !u!4 &1378790441 stripped +Transform: + m_PrefabParentObject: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + m_PrefabInternal: {fileID: 1378790440} +--- !u!1 &1396455878 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 5 + m_Component: + - component: {fileID: 1396455884} + - component: {fileID: 1396455883} + - component: {fileID: 1396455882} + - component: {fileID: 1396455881} + - component: {fileID: 1396455880} + m_Layer: 0 + m_Name: Camera + m_TagString: MainCamera + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 --- !u!81 &1396455880 AudioListener: m_ObjectHideFlags: 0 @@ -347,238 +716,74 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!1001 &1516218150 +--- !u!1 &2048596121 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 5 + m_Component: + - component: {fileID: 2048596123} + - component: {fileID: 2048596122} + m_Layer: 0 + m_Name: MainIsoWorld + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &2048596122 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 2048596121} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 3f01619d3802e814f86f9e6bb965349a, type: 3} + m_Name: + m_EditorClassIdentifier: + _tileSize: 2.2 + _tileRatio: 0.5 + _tileAngle: 45 + _tileHeight: 1.6 + _stepDepth: 0.1 + _startDepth: 1 + _showIsoBounds: 0 + _showScreenBounds: 0 + _showDepends: 1 + _snappingEnabled: 1 +--- !u!4 &2048596123 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 2048596121} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 522845242} + - {fileID: 1019705740} + - {fileID: 488606077} + - {fileID: 147835928} + m_Father: {fileID: 0} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1001 &2135046318 Prefab: m_ObjectHideFlags: 0 serializedVersion: 2 m_Modification: - m_TransformParent: {fileID: 0} + m_TransformParent: {fileID: 1019705740} m_Modifications: - target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} propertyPath: m_LocalPosition.x - value: -1.801579 + value: 2.199789 objectReference: {fileID: 0} - target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} propertyPath: m_LocalPosition.y - value: -4.42387 - objectReference: {fileID: 0} - - target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} - propertyPath: m_LocalPosition.z - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} - propertyPath: m_LocalRotation.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} - propertyPath: m_LocalRotation.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} - propertyPath: m_LocalRotation.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} - propertyPath: m_LocalRotation.w - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} - propertyPath: m_RootOrder - value: 6 - objectReference: {fileID: 0} - - target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} - propertyPath: _position.x - value: -2.4203 - objectReference: {fileID: 0} - - target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} - propertyPath: _position.y - value: -1.6014 - objectReference: {fileID: 0} - - target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} - propertyPath: _position.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} - propertyPath: _showTheirDepends - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} - propertyPath: _showIsoBounds - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} - propertyPath: _showScreenBounds - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} - propertyPath: _showSelfDepends - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 180122, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} - propertyPath: m_Name - value: TileA (5) - objectReference: {fileID: 0} - m_RemovedComponents: [] - m_ParentPrefab: {fileID: 100100000, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} - m_IsPrefabParent: 0 ---- !u!1001 &1656047475 -Prefab: - m_ObjectHideFlags: 0 - serializedVersion: 2 - m_Modification: - m_TransformParent: {fileID: 0} - m_Modifications: - - target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} - propertyPath: m_LocalPosition.x - value: -2.8267798 - objectReference: {fileID: 0} - - target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} - propertyPath: m_LocalPosition.y - value: -0.8611902 - objectReference: {fileID: 0} - - target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} - propertyPath: m_LocalPosition.z - value: 1.3000001 - objectReference: {fileID: 0} - - target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} - propertyPath: m_LocalRotation.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} - propertyPath: m_LocalRotation.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} - propertyPath: m_LocalRotation.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} - propertyPath: m_LocalRotation.w - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} - propertyPath: m_RootOrder - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} - propertyPath: _position.x - value: -1.0339 - objectReference: {fileID: 0} - - target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} - propertyPath: _position.y - value: 0.251 - objectReference: {fileID: 0} - - target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} - propertyPath: _position.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} - propertyPath: _showTheirDepends - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} - propertyPath: _showIsoBounds - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} - propertyPath: _showScreenBounds - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} - propertyPath: _showSelfDepends - value: 0 - objectReference: {fileID: 0} - m_RemovedComponents: [] - m_ParentPrefab: {fileID: 100100000, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} - m_IsPrefabParent: 0 ---- !u!1001 &1690501142 -Prefab: - m_ObjectHideFlags: 0 - serializedVersion: 2 - m_Modification: - m_TransformParent: {fileID: 0} - m_Modifications: - - target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} - propertyPath: m_LocalPosition.x - value: 3.0190604 - objectReference: {fileID: 0} - - target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} - propertyPath: m_LocalPosition.y - value: -1.6175498 - objectReference: {fileID: 0} - - target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} - propertyPath: m_LocalPosition.z - value: 1.4000001 - objectReference: {fileID: 0} - - target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} - propertyPath: m_LocalRotation.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} - propertyPath: m_LocalRotation.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} - propertyPath: m_LocalRotation.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} - propertyPath: m_LocalRotation.w - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} - propertyPath: m_RootOrder - value: 2 - objectReference: {fileID: 0} - - target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} - propertyPath: _position.x - value: -0.0491 - objectReference: {fileID: 0} - - target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} - propertyPath: _position.y - value: -1.4214 - objectReference: {fileID: 0} - - target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} - propertyPath: _position.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} - propertyPath: _showTheirDepends - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} - propertyPath: _showIsoBounds - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} - propertyPath: _showScreenBounds - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} - propertyPath: _showSelfDepends - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 180122, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} - propertyPath: m_Name - value: TileA (1) - objectReference: {fileID: 0} - m_RemovedComponents: [] - m_ParentPrefab: {fileID: 100100000, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} - m_IsPrefabParent: 0 ---- !u!1001 &2003518606 -Prefab: - m_ObjectHideFlags: 0 - serializedVersion: 2 - m_Modification: - m_TransformParent: {fileID: 0} - m_Modifications: - - target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} - propertyPath: m_LocalPosition.x - value: -4.3724995 - objectReference: {fileID: 0} - - target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} - propertyPath: m_LocalPosition.y - value: -2.8609903 + value: -1.1004634 objectReference: {fileID: 0} - target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} propertyPath: m_LocalPosition.z @@ -586,15 +791,15 @@ Prefab: objectReference: {fileID: 0} - target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} propertyPath: m_LocalRotation.x - value: 0 + value: -0 objectReference: {fileID: 0} - target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} propertyPath: m_LocalRotation.y - value: 0 + value: -0 objectReference: {fileID: 0} - target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} propertyPath: m_LocalRotation.z - value: 0 + value: -0 objectReference: {fileID: 0} - target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} propertyPath: m_LocalRotation.w @@ -602,15 +807,15 @@ Prefab: objectReference: {fileID: 0} - target: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} propertyPath: m_RootOrder - value: 5 + value: 1 objectReference: {fileID: 0} - target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} propertyPath: _position.x - value: -2.2942 + value: -0 objectReference: {fileID: 0} - target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} propertyPath: _position.y - value: -0.3067 + value: -2 objectReference: {fileID: 0} - target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} propertyPath: _position.z @@ -632,10 +837,18 @@ Prefab: propertyPath: _showSelfDepends value: 0 objectReference: {fileID: 0} + - target: {fileID: 11472392, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + propertyPath: m_Enabled + value: 1 + objectReference: {fileID: 0} - target: {fileID: 180122, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} propertyPath: m_Name - value: TileA (4) + value: TileA (2) objectReference: {fileID: 0} m_RemovedComponents: [] m_ParentPrefab: {fileID: 100100000, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} m_IsPrefabParent: 0 +--- !u!4 &2135046319 stripped +Transform: + m_PrefabParentObject: {fileID: 417424, guid: 185575a05f87743c0b2ddb83dd39c6cd, type: 2} + m_PrefabInternal: {fileID: 2135046318} diff --git a/Assets/IsoTools/Scripts/Internal/Editor/IsoObjectEditor.cs b/Assets/IsoTools/Scripts/Internal/Editor/IsoObjectEditor.cs index c1b0e3b..084020f 100644 --- a/Assets/IsoTools/Scripts/Internal/Editor/IsoObjectEditor.cs +++ b/Assets/IsoTools/Scripts/Internal/Editor/IsoObjectEditor.cs @@ -24,12 +24,10 @@ namespace IsoTools.Internal { var iso_world = IsoWorld.Instance; if ( iso_world ) { _positions = targets - .Where(p => p is IsoObject) - .Select(p => p as IsoObject) + .OfType() .ToDictionary(p => p, p => p.transform.position); _isoZPositions = targets - .Where(p => p is IsoObject) - .Select(p => p as IsoObject) + .OfType() .ToDictionary(p => p, p => p.position.z); _center = _viewCenter = _positions.Aggregate(Vector3.zero, (AccIn, p) => { return AccIn + IsoUtils.Vec3FromVec2(iso_world.IsoToScreen(p.Key.position + p.Key.size * 0.5f)); @@ -72,6 +70,18 @@ namespace IsoTools.Internal { } } + void DrawSelfInfoProperties() { + var iso_objects = targets.OfType(); + if ( iso_objects.Count() > 0 ) { + var mixed_world = iso_objects.GroupBy(p => p.isoWorld).Count() > 1; + IsoEditorUtils.DoWithEnabledGUI(false, () => { + IsoEditorUtils.DoWithMixedValue(mixed_world, () => { + EditorGUILayout.ObjectField("Current Object World", iso_objects.First().isoWorld, typeof(IsoWorld), true); + }); + }); + } + } + static bool SnappingProcess(ref float min_a, float size_a, float min_b, float size_b) { var max_a = min_a + size_a; var max_b = min_b + size_b; @@ -350,6 +360,7 @@ namespace IsoTools.Internal { GrabPositions(); DirtyTargetPosition(); DrawWorldEditorProperties(); + DrawSelfInfoProperties(); } } } \ No newline at end of file diff --git a/Assets/IsoTools/Scripts/Internal/Editor/IsoSnappingParentEditor.cs b/Assets/IsoTools/Scripts/Internal/Editor/IsoSnappingParentEditor.cs index 3e64617..23590eb 100644 --- a/Assets/IsoTools/Scripts/Internal/Editor/IsoSnappingParentEditor.cs +++ b/Assets/IsoTools/Scripts/Internal/Editor/IsoSnappingParentEditor.cs @@ -17,8 +17,7 @@ namespace IsoTools.Internal { var iso_world = IsoWorld.Instance; if ( iso_world ) { _parents = targets - .Where(p => p is IsoSnappingParent) - .Select(p => p as IsoSnappingParent) + .OfType() .ToDictionary(p => p, p => p.transform.position); foreach ( var parent in _parents ) { var iso_objects = parent.Key.GetComponentsInChildren(true); diff --git a/Assets/IsoTools/Scripts/Internal/IsoHolder.cs b/Assets/IsoTools/Scripts/Internal/IsoHolder.cs new file mode 100644 index 0000000..a4fb699 --- /dev/null +++ b/Assets/IsoTools/Scripts/Internal/IsoHolder.cs @@ -0,0 +1,74 @@ +using UnityEngine; +using System.Collections.Generic; + +namespace IsoTools.Internal { + public abstract class IsoHolder : MonoBehaviour + where THold : IsoHolder + where TInst : IsoInstance + { + IsoAssocList _instances = new IsoAssocList(); + static List _tempInstances = new List(); + + // --------------------------------------------------------------------- + // + // Private + // + // --------------------------------------------------------------------- + + void RecacheChildrenHolders() { + GetComponentsInChildren(false, _tempInstances); + for ( int i = 0, e = _tempInstances.Count; i < e; ++i ) { + _tempInstances[i].RecacheHolder(); + } + _tempInstances.Clear(); + } + + // --------------------------------------------------------------------- + // + // Internal + // + // --------------------------------------------------------------------- + + public bool IsActive() { + return isActiveAndEnabled && gameObject.activeInHierarchy; + } + + public void AddInstance(TInst instance) { + if ( instance != null && instance.IsActive() ) { + _instances.Add(instance); + OnAddInstanceToHolder(instance); + } + } + + public void RemoveInstance(TInst instance) { + if ( instance != null ) { + _instances.Remove(instance); + OnRemoveInstanceFromHolder(instance); + } + } + + protected IsoAssocList GetInstances() { + return _instances; + } + + // --------------------------------------------------------------------- + // + // Virtual + // + // --------------------------------------------------------------------- + + protected virtual void OnEnable() { + RecacheChildrenHolders(); + } + + protected virtual void OnDisable() { + RecacheChildrenHolders(); + } + + protected virtual void OnAddInstanceToHolder(TInst instance) { + } + + protected virtual void OnRemoveInstanceFromHolder(TInst instance) { + } + } +} \ No newline at end of file diff --git a/Assets/IsoTools/Scripts/Internal/IsoHolder.cs.meta b/Assets/IsoTools/Scripts/Internal/IsoHolder.cs.meta new file mode 100644 index 0000000..5ebd704 --- /dev/null +++ b/Assets/IsoTools/Scripts/Internal/IsoHolder.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 4963ce054813647fa8324abd50969d0a +timeCreated: 1481918461 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/IsoTools/Scripts/Internal/IsoInstance.cs b/Assets/IsoTools/Scripts/Internal/IsoInstance.cs new file mode 100644 index 0000000..eea650d --- /dev/null +++ b/Assets/IsoTools/Scripts/Internal/IsoInstance.cs @@ -0,0 +1,72 @@ +using UnityEngine; +using System.Collections.Generic; + +namespace IsoTools.Internal { + public abstract class IsoInstance : MonoBehaviour + where THold : IsoHolder + where TInst : IsoInstance + { + THold _holder = null; + static List _tempHolders = new List(); + + // --------------------------------------------------------------------- + // + // Internal + // + // --------------------------------------------------------------------- + + public bool IsActive() { + return isActiveAndEnabled && gameObject.activeInHierarchy; + } + + public void ResetHolder() { + if ( _holder ) { + _holder.RemoveInstance(this as TInst); + _holder = null; + } + } + + public void RecacheHolder() { + ResetHolder(); + if ( IsActive() ) { + GetComponentsInParent(false, _tempHolders); + for ( int i = 0, e = _tempHolders.Count; i < e; ++i ) { + var holder = _tempHolders[i]; + if ( holder.IsActive() ) { + _holder = holder; + break; + } + } + _tempHolders.Clear(); + } + if ( _holder ) { + _holder.AddInstance(this as TInst); + } + } + + protected THold GetHolder() { + if ( !_holder ) { + RecacheHolder(); + } + return _holder; + } + + // --------------------------------------------------------------------- + // + // Messages + // + // --------------------------------------------------------------------- + + protected virtual void OnEnable() { + RecacheHolder(); + } + + protected virtual void OnDisable() { + ResetHolder(); + } + + protected virtual void OnTransformParentChanged() { + RecacheHolder(); + } + } +} \ No newline at end of file diff --git a/Assets/IsoTools/Scripts/Internal/IsoInstance.cs.meta b/Assets/IsoTools/Scripts/Internal/IsoInstance.cs.meta new file mode 100644 index 0000000..8957374 --- /dev/null +++ b/Assets/IsoTools/Scripts/Internal/IsoInstance.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 999fb85120b0d4fafaf990b86d3eb23b +timeCreated: 1481914140 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/IsoTools/Scripts/IsoObject.cs b/Assets/IsoTools/Scripts/IsoObject.cs index b977355..8d84b8b 100644 --- a/Assets/IsoTools/Scripts/IsoObject.cs +++ b/Assets/IsoTools/Scripts/IsoObject.cs @@ -9,7 +9,7 @@ using UnityEditor; namespace IsoTools { [SelectionBase] [ExecuteInEditMode, DisallowMultipleComponent] - public class IsoObject : MonoBehaviour { + public sealed class IsoObject : IsoInstance { // --------------------------------------------------------------------- // @@ -214,13 +214,9 @@ namespace IsoTools { // // --------------------------------------------------------------------- - IsoWorld _isoWorld = null; public IsoWorld isoWorld { get { - if ( !_isoWorld && gameObject.activeInHierarchy ) { - _isoWorld = IsoWorld.Instance; - } - return _isoWorld; + return GetHolder(); } } @@ -261,6 +257,8 @@ namespace IsoTools { var b = iso_world.IsoToScreen(position).y; var t = iso_world.IsoToScreen(position + size).y; Internal.ScreenBounds = new IsoRect(l, b, r, t); + } else { + Internal.ScreenBounds = IsoRect.zero; } } @@ -294,19 +292,20 @@ namespace IsoTools { FixIsoPosition(); } - void OnEnable() { - var iso_world = isoWorld; - if ( iso_world ) { - iso_world.AddIsoObject(this); - } + protected override void OnEnable() { + base.OnEnable(); MartDirtyIsoWorld(); } - void OnDisable() { - var iso_world = isoWorld; - if ( iso_world ) { - iso_world.RemoveIsoObject(this); - } + protected override void OnDisable() { + base.OnDisable(); + } + + protected override void OnTransformParentChanged() { + base.OnTransformParentChanged(); + FixCachedProperties(); + FixLastProperties(); + FixTransform(); } #if UNITY_EDITOR diff --git a/Assets/IsoTools/Scripts/IsoWorld.cs b/Assets/IsoTools/Scripts/IsoWorld.cs index 6a5e24a..43faa13 100644 --- a/Assets/IsoTools/Scripts/IsoWorld.cs +++ b/Assets/IsoTools/Scripts/IsoWorld.cs @@ -12,13 +12,12 @@ using UnityEngine.Profiling; namespace IsoTools { [ExecuteInEditMode, DisallowMultipleComponent] - public class IsoWorld : MonoBehaviour { + public sealed class IsoWorld : IsoHolder { static IsoWorld _instance = null; bool _dirty = false; Vector2 _minXY = Vector2.zero; - IsoAssocList _objects = new IsoAssocList(); IsoAssocList _visibles = new IsoAssocList(); IsoAssocList _oldVisibles = new IsoAssocList(); @@ -362,39 +361,6 @@ namespace IsoTools { } } - public void AddIsoObject(IsoObject iso_object) { - _objects.Add(iso_object); - if ( iso_object.cacheRenderers ) { - iso_object.UpdateCachedRenderers(); - } - } - - public void RemoveIsoObject(IsoObject iso_object) { - if ( iso_object.cacheRenderers ) { - iso_object.ClearCachedRenderers(); - } - ClearIsoObjectDepends(iso_object); - _objects.Remove(iso_object); - _visibles.Remove(iso_object); - _oldVisibles.Remove(iso_object); - } - - void GrabEnabledIsoObjects() { - var iso_objects = FindObjectsOfType(); - for ( int i = 0, e = iso_objects.Length; i < e; ++i ) { - var iso_object = iso_objects[i]; - if ( iso_object.enabled ) { - AddIsoObject(iso_object); - } - } - } - - void DropIsoObjects() { - while ( _objects.Count > 0 ) { - RemoveIsoObject(_objects.Peek()); - } - } - // --------------------------------------------------------------------- // // Private @@ -416,8 +382,9 @@ namespace IsoTools { } void FixAllTransforms() { - for ( int i = 0, e = _objects.Count; i < e; ++i ) { - _objects[i].FixTransform(); + var instances = GetInstances(); + for ( int i = 0, e = instances.Count; i < e; ++i ) { + instances[i].FixTransform(); } } @@ -442,15 +409,6 @@ namespace IsoTools { return false; } - List GetIsoObjectRenderers(IsoObject iso_object) { - if ( iso_object.cacheRenderers ) { - return iso_object.Internal.Renderers; - } else { - iso_object.GetComponentsInChildren(_tmpRenderers); - return _tmpRenderers; - } - } - IsoMinMax IsoObjectMinMax3D(IsoObject iso_object) { bool inited = false; var result = IsoMinMax.zero; @@ -478,6 +436,15 @@ namespace IsoTools { return inited ? result : IsoMinMax.zero; } + List GetIsoObjectRenderers(IsoObject iso_object) { + if ( iso_object.cacheRenderers ) { + return iso_object.Internal.Renderers; + } else { + iso_object.GetComponentsInChildren(_tmpRenderers); + return _tmpRenderers; + } + } + bool IsIsoObjectVisible(IsoObject iso_object) { var renderers = GetIsoObjectRenderers(iso_object); for ( int i = 0, e = renderers.Count; i < e; ++i ) { @@ -495,15 +462,29 @@ namespace IsoTools { if ( a_yesno ) { var b_yesno = b_max.x > a_min.x && b_max.y > a_min.y && a_max.z > b_min.z; if ( b_yesno ) { - var da_p = new Vector3(a_max.x - b_min.x, a_max.y - b_min.y, b_max.z - a_min.z); - var db_p = new Vector3(b_max.x - a_min.x, b_max.y - a_min.y, a_max.z - b_min.z); - var dp_p = a_size + b_size - IsoUtils.Vec3Abs(da_p - db_p); - if ( dp_p.x <= dp_p.y && dp_p.x <= dp_p.z ) { - return da_p.x > db_p.x; - } else if ( dp_p.y <= dp_p.x && dp_p.y <= dp_p.z ) { - return da_p.y > db_p.y; + + //var da_p = new Vector3(a_max.x - b_min.x, a_max.y - b_min.y, b_max.z - a_min.z); + //var db_p = new Vector3(b_max.x - a_min.x, b_max.y - a_min.y, a_max.z - b_min.z); + //var dp_p = a_size + b_size - IsoUtils.Vec3Abs(da_p - db_p); + + var dA_x = a_max.x - b_min.x; + var dA_y = a_max.y - b_min.y; + var dA_z = b_max.z - a_min.z; + + var dB_x = b_max.x - a_min.x; + var dB_y = b_max.y - a_min.y; + var dB_z = a_max.z - b_min.z; + + var dP_x = a_size.x + b_size.x - Mathf.Abs(dA_x - dB_x); + var dP_y = a_size.y + b_size.y - Mathf.Abs(dA_y - dB_y); + var dP_z = a_size.z + b_size.z - Mathf.Abs(dA_z - dB_z); + + if ( dP_x <= dP_y && dP_x <= dP_z ) { + return dA_x > dB_x; + } else if ( dP_y <= dP_x && dP_y <= dP_z ) { + return dA_y > dB_y; } else { - return da_p.z > db_p.z; + return dA_z > dB_z; } } } @@ -673,10 +654,11 @@ namespace IsoTools { void CalculateNewVisibles() { _oldVisibles.Clear(); - if ( _objects.Count > 0 ) { + var instances = GetInstances(); + if ( instances.Count > 0 ) { _minXY.Set(float.MaxValue, float.MaxValue); - for ( int i = 0, e = _objects.Count; i < e; ++i ) { - var iso_object = _objects[i]; + for ( int i = 0, e = instances.Count; i < e; ++i ) { + var iso_object = instances[i]; var iso_object_pos = iso_object.position; if ( _minXY.x > iso_object_pos.x ) { _minXY.x = iso_object_pos.x; @@ -795,21 +777,38 @@ namespace IsoTools { StepSort(); } - void OnEnable() { - GrabEnabledIsoObjects(); + protected override void OnEnable() { + base.OnEnable(); _visibles.Clear(); _oldVisibles.Clear(); _sectors.Clear(); MarkDirty(); } - void OnDisable() { - DropIsoObjects(); + protected override void OnDisable() { + base.OnDisable(); _visibles.Clear(); _oldVisibles.Clear(); _sectors.Clear(); } + protected override void OnAddInstanceToHolder(IsoObject instance) { + base.OnAddInstanceToHolder(instance); + if ( instance.cacheRenderers ) { + instance.UpdateCachedRenderers(); + } + } + + protected override void OnRemoveInstanceFromHolder(IsoObject instance) { + base.OnRemoveInstanceFromHolder(instance); + if ( instance.cacheRenderers ) { + instance.ClearCachedRenderers(); + } + ClearIsoObjectDepends(instance); + _visibles.Remove(instance); + _oldVisibles.Remove(instance); + } + #if UNITY_EDITOR void Reset() { tileSize = DefTileSize;