mirror of
https://github.com/BlackMATov/unity-iso-tools.git
synced 2025-12-15 01:12:05 +07:00
temp remove sorting for one object
This commit is contained in:
@@ -46,6 +46,7 @@
|
|||||||
</Reference>
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="Assets\IsoTools\Examples\Scripts\CircleFlyCamera.cs" />
|
||||||
<Compile Include="Assets\IsoTools\Examples\Scripts\IsoAutoController.cs" />
|
<Compile Include="Assets\IsoTools\Examples\Scripts\IsoAutoController.cs" />
|
||||||
<Compile Include="Assets\IsoTools\Examples\Scripts\IsoController.cs" />
|
<Compile Include="Assets\IsoTools\Examples\Scripts\IsoController.cs" />
|
||||||
<Compile Include="Assets\IsoTools\Scripts\IsoObject.cs" />
|
<Compile Include="Assets\IsoTools\Scripts\IsoObject.cs" />
|
||||||
|
|||||||
@@ -46,6 +46,7 @@
|
|||||||
</Reference>
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="Assets\IsoTools\Examples\Scripts\CircleFlyCamera.cs" />
|
||||||
<Compile Include="Assets\IsoTools\Examples\Scripts\IsoAutoController.cs" />
|
<Compile Include="Assets\IsoTools\Examples\Scripts\IsoAutoController.cs" />
|
||||||
<Compile Include="Assets\IsoTools\Examples\Scripts\IsoController.cs" />
|
<Compile Include="Assets\IsoTools\Examples\Scripts\IsoController.cs" />
|
||||||
<Compile Include="Assets\IsoTools\Scripts\IsoObject.cs" />
|
<Compile Include="Assets\IsoTools\Scripts\IsoObject.cs" />
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
24
Assets/IsoTools/Examples/Scripts/CircleFlyCamera.cs
Normal file
24
Assets/IsoTools/Examples/Scripts/CircleFlyCamera.cs
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
using System.Collections;
|
||||||
|
|
||||||
|
public class CircleFlyCamera : MonoBehaviour {
|
||||||
|
|
||||||
|
public float FlyRadius = 150.0f;
|
||||||
|
public float FlySpeed = 1.0f;
|
||||||
|
|
||||||
|
Vector3 _start_pos;
|
||||||
|
float _fly_timer;
|
||||||
|
|
||||||
|
void Start() {
|
||||||
|
_start_pos = transform.position;
|
||||||
|
_fly_timer = 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Update () {
|
||||||
|
_fly_timer += FlySpeed * Time.deltaTime;
|
||||||
|
transform.position = new Vector3(
|
||||||
|
_start_pos.x + Mathf.Cos(_fly_timer) * FlyRadius,
|
||||||
|
_start_pos.y + Mathf.Sin(_fly_timer) * FlyRadius,
|
||||||
|
_start_pos.z);
|
||||||
|
}
|
||||||
|
}
|
||||||
12
Assets/IsoTools/Examples/Scripts/CircleFlyCamera.cs.meta
Normal file
12
Assets/IsoTools/Examples/Scripts/CircleFlyCamera.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 28c0a5afc26a545b0be63d03f8b3d8f3
|
||||||
|
timeCreated: 1424879906
|
||||||
|
licenseType: Pro
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -9,11 +9,11 @@ namespace IsoTools {
|
|||||||
public class IsoObject : MonoBehaviour {
|
public class IsoObject : MonoBehaviour {
|
||||||
|
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
Vector2 _lastTransform = Vector2.zero;
|
Vector2 _lastTransform = Vector2.zero;
|
||||||
Vector3 _lastPosition = Vector3.zero;
|
Vector3 _lastPosition = Vector3.zero;
|
||||||
Vector3 _lastSize = Vector3.zero;
|
Vector3 _lastSize = Vector3.zero;
|
||||||
bool _lastSorting = false;
|
bool _lastSorting = false;
|
||||||
bool _lastAlignment = false;
|
bool _lastAlignment = false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
@@ -117,9 +117,7 @@ namespace IsoTools {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MartDirtyIsoWorld() {
|
void MartDirtyIsoWorld() {
|
||||||
if ( Sorting ) {
|
IsoWorld.MarkDirty(this);
|
||||||
IsoWorld.MarkDirty(this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MarkEditorObjectDirty() {
|
void MarkEditorObjectDirty() {
|
||||||
|
|||||||
@@ -30,13 +30,11 @@ namespace IsoTools {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool _dirty = true;
|
bool _dirty = true;
|
||||||
HashSet<IsoObject> _dirtyObjects = new HashSet<IsoObject>();
|
TileTypes _lastTileType = TileTypes.Isometric;
|
||||||
|
float _lastTileSize = 0.0f;
|
||||||
TileTypes _lastTileType = TileTypes.Isometric;
|
float _lastMinDepth = 0.0f;
|
||||||
float _lastTileSize = 0.0f;
|
float _lastMaxDepth = 0.0f;
|
||||||
float _lastMinDepth = 0.0f;
|
|
||||||
float _lastMaxDepth = 0.0f;
|
|
||||||
|
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
public TileTypes _tileType = TileTypes.Isometric;
|
public TileTypes _tileType = TileTypes.Isometric;
|
||||||
@@ -98,9 +96,8 @@ namespace IsoTools {
|
|||||||
/// <param name="obj">Isometric object for resorting.</param>
|
/// <param name="obj">Isometric object for resorting.</param>
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
public void MarkDirty(IsoObject obj) {
|
public void MarkDirty(IsoObject obj) {
|
||||||
_dirtyObjects.Add(obj);
|
if ( obj && obj.Sorting ) {
|
||||||
if ( !_dirty ) {
|
_dirty = true;
|
||||||
//ManualSort(obj, Scan)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -244,34 +241,6 @@ namespace IsoTools {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ManualSort(IsoObject obj, IList<ObjectInfo> objects) {
|
|
||||||
var min_depth = float.MinValue;
|
|
||||||
foreach ( var obj_b in objects ) {
|
|
||||||
if ( IsDepends(obj, obj_b.IsoObject) ) {
|
|
||||||
min_depth = Mathf.Max(min_depth, obj_b.IsoObject.transform.position.z);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var max_depth = float.MaxValue;
|
|
||||||
foreach ( var obj_a in objects ) {
|
|
||||||
if ( IsDepends(obj_a.IsoObject, obj) ) {
|
|
||||||
max_depth = Mathf.Min(max_depth, obj_a.IsoObject.transform.position.z);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( min_depth == float.MinValue ) {
|
|
||||||
min_depth = MinDepth;
|
|
||||||
}
|
|
||||||
if ( max_depth == float.MaxValue ) {
|
|
||||||
max_depth = MaxDepth;
|
|
||||||
}
|
|
||||||
//TODO: magic number
|
|
||||||
var min_depth_step = 0.01f;
|
|
||||||
if ( max_depth < min_depth || Mathf.Abs(max_depth - min_depth) < min_depth_step ) {
|
|
||||||
MarkDirty();
|
|
||||||
} else {
|
|
||||||
PlaceObject(obj, (min_depth + max_depth) / 2.0f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void PlaceObject(IsoObject obj, float depth) {
|
void PlaceObject(IsoObject obj, float depth) {
|
||||||
var trans = obj.gameObject.transform;
|
var trans = obj.gameObject.transform;
|
||||||
trans.position = new Vector3(trans.position.x, trans.position.y, depth);
|
trans.position = new Vector3(trans.position.x, trans.position.y, depth);
|
||||||
@@ -291,17 +260,9 @@ namespace IsoTools {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void StepSort() {
|
void StepSort() {
|
||||||
while ( !_dirty && _dirtyObjects.Count > 0 ) {
|
|
||||||
var objects = ScanObjects(p => p.Sorting && !_dirtyObjects.Contains(p));
|
|
||||||
var obj = _dirtyObjects.First();
|
|
||||||
ManualSort(obj, objects);
|
|
||||||
_dirtyObjects.Remove(obj);
|
|
||||||
}
|
|
||||||
if ( _dirty ) {
|
if ( _dirty ) {
|
||||||
ManualSort(ScanObjects(p => p.Sorting));
|
ManualSort(ScanObjects(p => p.Sorting));
|
||||||
_dirty = false;
|
_dirty = false;
|
||||||
_dirtyObjects.Clear();
|
|
||||||
Debug.Log("Resort!");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ Global
|
|||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(MonoDevelopProperties) = preSolution
|
GlobalSection(MonoDevelopProperties) = preSolution
|
||||||
StartupItem = Assembly-CSharp.csproj
|
StartupItem = Assembly-CSharp.csproj
|
||||||
Policies = $0
|
Policies = $0
|
||||||
$0.TextStylePolicy = $1
|
$0.TextStylePolicy = $1
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ Global
|
|||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(MonoDevelopProperties) = preSolution
|
GlobalSection(MonoDevelopProperties) = preSolution
|
||||||
StartupItem = Assembly-CSharp.csproj
|
StartupItem = Assembly-CSharp.csproj
|
||||||
Policies = $0
|
Policies = $0
|
||||||
$0.TextStylePolicy = $1
|
$0.TextStylePolicy = $1
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
<Properties>
|
<Properties>
|
||||||
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" />
|
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" PreferredExecutionTarget="MonoDevelop.Default" />
|
||||||
<MonoDevelop.Ide.Workbench ActiveDocument="Assets/IsoTools/Scripts/IsoWorld.cs">
|
<MonoDevelop.Ide.Workbench ActiveDocument="Assets/IsoTools/Scripts/IsoWorld.cs">
|
||||||
<Files>
|
<Files>
|
||||||
<File FileName="Assets/IsoTools/Scripts/IsoWorld.cs" Line="296" Column="34" />
|
<File FileName="Assets/IsoTools/Scripts/IsoWorld.cs" Line="272" Column="4" />
|
||||||
<File FileName="Assets/IsoTools/Scripts/IsoObject.cs" Line="147" Column="6" />
|
<File FileName="Assets/IsoTools/Scripts/IsoObject.cs" Line="104" Column="29" />
|
||||||
</Files>
|
</Files>
|
||||||
</MonoDevelop.Ide.Workbench>
|
</MonoDevelop.Ide.Workbench>
|
||||||
<MonoDevelop.Ide.DebuggingService.Breakpoints>
|
<MonoDevelop.Ide.DebuggingService.Breakpoints>
|
||||||
|
|||||||
Reference in New Issue
Block a user