diff --git a/Assets/Extensions.cs b/Assets/Extensions.cs new file mode 100644 index 0000000..26c3cab --- /dev/null +++ b/Assets/Extensions.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +public static class Extensions +{ + public static IEnumerable ToSingle(this T item) + { + yield return item; + } +} diff --git a/Assets/Extensions.cs b/Assets/Extensions.cs new file mode 100644 index 0000000..26c3cab --- /dev/null +++ b/Assets/Extensions.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +public static class Extensions +{ + public static IEnumerable ToSingle(this T item) + { + yield return item; + } +} diff --git a/Assets/Extensions.cs.meta b/Assets/Extensions.cs.meta new file mode 100644 index 0000000..f034002 --- /dev/null +++ b/Assets/Extensions.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 538cc91c599e24c409d54b93fd3f450b +timeCreated: 1572760855 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Extensions.cs b/Assets/Extensions.cs new file mode 100644 index 0000000..26c3cab --- /dev/null +++ b/Assets/Extensions.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +public static class Extensions +{ + public static IEnumerable ToSingle(this T item) + { + yield return item; + } +} diff --git a/Assets/Extensions.cs.meta b/Assets/Extensions.cs.meta new file mode 100644 index 0000000..f034002 --- /dev/null +++ b/Assets/Extensions.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 538cc91c599e24c409d54b93fd3f450b +timeCreated: 1572760855 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/IsoEditor.cs b/Assets/IsoEditor.cs index 2cea357..0895cdb 100755 --- a/Assets/IsoEditor.cs +++ b/Assets/IsoEditor.cs @@ -17,9 +17,21 @@ EnableButtons(); } + private void OnDisable() + { + DisableButtons(); + } + // Update is called once per frame void Update () { + if (isoMode) + { + foreach (SceneView sv in SceneView.sceneViews) + { + sv.rotation = IsoCamera.transform.rotation; + } + } } private bool isoMode = false; @@ -41,6 +53,15 @@ SceneView.RepaintAll(); } + private struct SaveScene + { + public Vector3 P; + public Quaternion Q; + public bool O; + } + + private Dictionary saved = new Dictionary(); + public void OnSceneGUI(SceneView sceneView) { Handles.BeginGUI(); @@ -51,19 +72,35 @@ if (isoMode) { - lastCameraP = sceneView.pivot; - lastCameraQ = sceneView.rotation; - lastOrtho = sceneView.orthographic; - - sceneView.AlignViewToObject(IsoCamera.transform); - sceneView.orthographic = true; - + saved.Clear(); } - else + + foreach (SceneView sv in SceneView.sceneViews) { - sceneView.pivot = lastCameraP; - sceneView.rotation = lastCameraQ; - sceneView.orthographic = lastOrtho; + if (isoMode) + { + saved[sv] = new SaveScene + { + P = sv.pivot, + Q = sv.rotation, + O = sv.orthographic + }; + + sv.AlignViewToObject(IsoCamera.transform); + sv.orthographic = true; + sv.isRotationLocked = true; + + } + else + { + if (saved.ContainsKey(sv)) + { + sv.pivot = saved[sv].P; + sv.rotation = saved[sv].Q; + sv.orthographic = saved[sv].O; + } + sv.isRotationLocked = false; + } } } Handles.EndGUI(); diff --git a/Assets/Extensions.cs b/Assets/Extensions.cs new file mode 100644 index 0000000..26c3cab --- /dev/null +++ b/Assets/Extensions.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +public static class Extensions +{ + public static IEnumerable ToSingle(this T item) + { + yield return item; + } +} diff --git a/Assets/Extensions.cs.meta b/Assets/Extensions.cs.meta new file mode 100644 index 0000000..f034002 --- /dev/null +++ b/Assets/Extensions.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 538cc91c599e24c409d54b93fd3f450b +timeCreated: 1572760855 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/IsoEditor.cs b/Assets/IsoEditor.cs index 2cea357..0895cdb 100755 --- a/Assets/IsoEditor.cs +++ b/Assets/IsoEditor.cs @@ -17,9 +17,21 @@ EnableButtons(); } + private void OnDisable() + { + DisableButtons(); + } + // Update is called once per frame void Update () { + if (isoMode) + { + foreach (SceneView sv in SceneView.sceneViews) + { + sv.rotation = IsoCamera.transform.rotation; + } + } } private bool isoMode = false; @@ -41,6 +53,15 @@ SceneView.RepaintAll(); } + private struct SaveScene + { + public Vector3 P; + public Quaternion Q; + public bool O; + } + + private Dictionary saved = new Dictionary(); + public void OnSceneGUI(SceneView sceneView) { Handles.BeginGUI(); @@ -51,19 +72,35 @@ if (isoMode) { - lastCameraP = sceneView.pivot; - lastCameraQ = sceneView.rotation; - lastOrtho = sceneView.orthographic; - - sceneView.AlignViewToObject(IsoCamera.transform); - sceneView.orthographic = true; - + saved.Clear(); } - else + + foreach (SceneView sv in SceneView.sceneViews) { - sceneView.pivot = lastCameraP; - sceneView.rotation = lastCameraQ; - sceneView.orthographic = lastOrtho; + if (isoMode) + { + saved[sv] = new SaveScene + { + P = sv.pivot, + Q = sv.rotation, + O = sv.orthographic + }; + + sv.AlignViewToObject(IsoCamera.transform); + sv.orthographic = true; + sv.isRotationLocked = true; + + } + else + { + if (saved.ContainsKey(sv)) + { + sv.pivot = saved[sv].P; + sv.rotation = saved[sv].Q; + sv.orthographic = saved[sv].O; + } + sv.isRotationLocked = false; + } } } Handles.EndGUI(); diff --git a/Assets/IsoObject.cs b/Assets/IsoObject.cs index 86ecd64..9782b6f 100755 --- a/Assets/IsoObject.cs +++ b/Assets/IsoObject.cs @@ -1,8 +1,43 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Linq; +using UnityEditor; using UnityEngine; +[CustomEditor(typeof(IsoObject))] +public class IsoObjectEditor : Editor +{ + private int textureSelected = 0; + private List textures = new List(); + public override void OnInspectorGUI() + { + DrawDefaultInspector(); + + textures.Clear(); + if (target is IsoObject) + { + IsoObject isoObject = target as IsoObject; + foreach (MeshRenderer mr in isoObject.gameObject.GetComponentsInChildren()) + { + if (mr.sharedMaterial.shader.name == "Unlit/IsoShader") + { + textures.Add(mr.sharedMaterial.GetTexture("_MainTex")); + } + } + + textureSelected = EditorGUILayout.Popup(Math.Min(textures.Count, textureSelected), new GUIContent("Select Texture").ToSingle().Concat(textures.Select(t => new GUIContent(t.name))).ToArray()); + if (textureSelected != 0) + { + IsoTextureEditor editor = EditorWindow.GetWindow(); + editor.Init(textures[textureSelected - 1]); + editor.Show(); + textureSelected = 0; + } + } + } +} + [ExecuteInEditMode] public class IsoObject : MonoBehaviour { @@ -19,7 +54,7 @@ private void PreRender(Camera cam) { //Debug.Log(cam.GetInstanceID()); - if (cam.orthographic && isoEditor.IsoMode) + if (cam.orthographic && (isoEditor.IsoMode || cam == isoEditor.IsoCamera)) { Vector3 viewPos = cam.WorldToViewportPoint(gameObject.transform.position); foreach (MeshRenderer mr in IsoMeshes) diff --git a/Assets/Extensions.cs b/Assets/Extensions.cs new file mode 100644 index 0000000..26c3cab --- /dev/null +++ b/Assets/Extensions.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +public static class Extensions +{ + public static IEnumerable ToSingle(this T item) + { + yield return item; + } +} diff --git a/Assets/Extensions.cs.meta b/Assets/Extensions.cs.meta new file mode 100644 index 0000000..f034002 --- /dev/null +++ b/Assets/Extensions.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 538cc91c599e24c409d54b93fd3f450b +timeCreated: 1572760855 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/IsoEditor.cs b/Assets/IsoEditor.cs index 2cea357..0895cdb 100755 --- a/Assets/IsoEditor.cs +++ b/Assets/IsoEditor.cs @@ -17,9 +17,21 @@ EnableButtons(); } + private void OnDisable() + { + DisableButtons(); + } + // Update is called once per frame void Update () { + if (isoMode) + { + foreach (SceneView sv in SceneView.sceneViews) + { + sv.rotation = IsoCamera.transform.rotation; + } + } } private bool isoMode = false; @@ -41,6 +53,15 @@ SceneView.RepaintAll(); } + private struct SaveScene + { + public Vector3 P; + public Quaternion Q; + public bool O; + } + + private Dictionary saved = new Dictionary(); + public void OnSceneGUI(SceneView sceneView) { Handles.BeginGUI(); @@ -51,19 +72,35 @@ if (isoMode) { - lastCameraP = sceneView.pivot; - lastCameraQ = sceneView.rotation; - lastOrtho = sceneView.orthographic; - - sceneView.AlignViewToObject(IsoCamera.transform); - sceneView.orthographic = true; - + saved.Clear(); } - else + + foreach (SceneView sv in SceneView.sceneViews) { - sceneView.pivot = lastCameraP; - sceneView.rotation = lastCameraQ; - sceneView.orthographic = lastOrtho; + if (isoMode) + { + saved[sv] = new SaveScene + { + P = sv.pivot, + Q = sv.rotation, + O = sv.orthographic + }; + + sv.AlignViewToObject(IsoCamera.transform); + sv.orthographic = true; + sv.isRotationLocked = true; + + } + else + { + if (saved.ContainsKey(sv)) + { + sv.pivot = saved[sv].P; + sv.rotation = saved[sv].Q; + sv.orthographic = saved[sv].O; + } + sv.isRotationLocked = false; + } } } Handles.EndGUI(); diff --git a/Assets/IsoObject.cs b/Assets/IsoObject.cs index 86ecd64..9782b6f 100755 --- a/Assets/IsoObject.cs +++ b/Assets/IsoObject.cs @@ -1,8 +1,43 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Linq; +using UnityEditor; using UnityEngine; +[CustomEditor(typeof(IsoObject))] +public class IsoObjectEditor : Editor +{ + private int textureSelected = 0; + private List textures = new List(); + public override void OnInspectorGUI() + { + DrawDefaultInspector(); + + textures.Clear(); + if (target is IsoObject) + { + IsoObject isoObject = target as IsoObject; + foreach (MeshRenderer mr in isoObject.gameObject.GetComponentsInChildren()) + { + if (mr.sharedMaterial.shader.name == "Unlit/IsoShader") + { + textures.Add(mr.sharedMaterial.GetTexture("_MainTex")); + } + } + + textureSelected = EditorGUILayout.Popup(Math.Min(textures.Count, textureSelected), new GUIContent("Select Texture").ToSingle().Concat(textures.Select(t => new GUIContent(t.name))).ToArray()); + if (textureSelected != 0) + { + IsoTextureEditor editor = EditorWindow.GetWindow(); + editor.Init(textures[textureSelected - 1]); + editor.Show(); + textureSelected = 0; + } + } + } +} + [ExecuteInEditMode] public class IsoObject : MonoBehaviour { @@ -19,7 +54,7 @@ private void PreRender(Camera cam) { //Debug.Log(cam.GetInstanceID()); - if (cam.orthographic && isoEditor.IsoMode) + if (cam.orthographic && (isoEditor.IsoMode || cam == isoEditor.IsoCamera)) { Vector3 viewPos = cam.WorldToViewportPoint(gameObject.transform.position); foreach (MeshRenderer mr in IsoMeshes) diff --git a/Assets/IsoShader.shader b/Assets/IsoShader.shader index 73db29a..fa1b1cb 100755 --- a/Assets/IsoShader.shader +++ b/Assets/IsoShader.shader @@ -5,7 +5,7 @@ _MainTex ("Texture", 2D) = "white" {} _CenterPoint ("Object Center", Vector) = (0,0,0,0) _TextureOffset("Texture Offset", Vector) = (0,0,0,0) - _TextureScale("Texture Scale", Float) = 1 + _PixelsPerUnit("Pixels Per World Unit", Float) = 1 } SubShader { @@ -42,7 +42,7 @@ float4 _CenterPoint; float4 _TextureOffset; - float _TextureScale; + float _PixelsPerUnit; v2f vert (appdata v) { @@ -56,8 +56,25 @@ fixed4 frag (v2f i) : SV_Target { + // unity_OrthoParams.xy / 0.70710678 = Wu/Vp + // PixelsPerUnit = Px/Wu + // _MainTex_TexelSize.xy = Uv/Px + + // we want Uv from: + // (i.screenPos.xy - CenterPoint.xy) = Vp + // (i.screenPos.xy - CenterPoint.xy) * unity_OrthoParams.x * _PixelsPerUnit * _MainTex_TexelSize.xy = Uv + + float2 worldUnitScale = unity_OrthoParams.xy / 0.70710678; + float2 offset = float2(i.screenPos.x - _CenterPoint.x, _CenterPoint.y - i.screenPos.y); + float2 uvs = float2((offset.x * worldUnitScale.x * _PixelsPerUnit - _TextureOffset.x) * _MainTex_TexelSize.x, + 1 - (offset.y * worldUnitScale.y * _PixelsPerUnit - _TextureOffset.y) * _MainTex_TexelSize.y); + // sample the texture - fixed4 col = tex2D(_MainTex, (i.screenPos.xy - _CenterPoint.xy - _TextureOffset.xy * _MainTex_TexelSize.xy) / _TextureScale); + fixed4 col = tex2D(_MainTex, uvs); + + clip(col.a - 0.5); + //fixed4 col = fixed4(uvs.x, 0, 0, 1); + //fixed4 col = fixed4(uvs.xy, 0, 1); // apply fog //UNITY_APPLY_FOG(i.fogCoord, col); diff --git a/Assets/Extensions.cs b/Assets/Extensions.cs new file mode 100644 index 0000000..26c3cab --- /dev/null +++ b/Assets/Extensions.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +public static class Extensions +{ + public static IEnumerable ToSingle(this T item) + { + yield return item; + } +} diff --git a/Assets/Extensions.cs.meta b/Assets/Extensions.cs.meta new file mode 100644 index 0000000..f034002 --- /dev/null +++ b/Assets/Extensions.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 538cc91c599e24c409d54b93fd3f450b +timeCreated: 1572760855 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/IsoEditor.cs b/Assets/IsoEditor.cs index 2cea357..0895cdb 100755 --- a/Assets/IsoEditor.cs +++ b/Assets/IsoEditor.cs @@ -17,9 +17,21 @@ EnableButtons(); } + private void OnDisable() + { + DisableButtons(); + } + // Update is called once per frame void Update () { + if (isoMode) + { + foreach (SceneView sv in SceneView.sceneViews) + { + sv.rotation = IsoCamera.transform.rotation; + } + } } private bool isoMode = false; @@ -41,6 +53,15 @@ SceneView.RepaintAll(); } + private struct SaveScene + { + public Vector3 P; + public Quaternion Q; + public bool O; + } + + private Dictionary saved = new Dictionary(); + public void OnSceneGUI(SceneView sceneView) { Handles.BeginGUI(); @@ -51,19 +72,35 @@ if (isoMode) { - lastCameraP = sceneView.pivot; - lastCameraQ = sceneView.rotation; - lastOrtho = sceneView.orthographic; - - sceneView.AlignViewToObject(IsoCamera.transform); - sceneView.orthographic = true; - + saved.Clear(); } - else + + foreach (SceneView sv in SceneView.sceneViews) { - sceneView.pivot = lastCameraP; - sceneView.rotation = lastCameraQ; - sceneView.orthographic = lastOrtho; + if (isoMode) + { + saved[sv] = new SaveScene + { + P = sv.pivot, + Q = sv.rotation, + O = sv.orthographic + }; + + sv.AlignViewToObject(IsoCamera.transform); + sv.orthographic = true; + sv.isRotationLocked = true; + + } + else + { + if (saved.ContainsKey(sv)) + { + sv.pivot = saved[sv].P; + sv.rotation = saved[sv].Q; + sv.orthographic = saved[sv].O; + } + sv.isRotationLocked = false; + } } } Handles.EndGUI(); diff --git a/Assets/IsoObject.cs b/Assets/IsoObject.cs index 86ecd64..9782b6f 100755 --- a/Assets/IsoObject.cs +++ b/Assets/IsoObject.cs @@ -1,8 +1,43 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Linq; +using UnityEditor; using UnityEngine; +[CustomEditor(typeof(IsoObject))] +public class IsoObjectEditor : Editor +{ + private int textureSelected = 0; + private List textures = new List(); + public override void OnInspectorGUI() + { + DrawDefaultInspector(); + + textures.Clear(); + if (target is IsoObject) + { + IsoObject isoObject = target as IsoObject; + foreach (MeshRenderer mr in isoObject.gameObject.GetComponentsInChildren()) + { + if (mr.sharedMaterial.shader.name == "Unlit/IsoShader") + { + textures.Add(mr.sharedMaterial.GetTexture("_MainTex")); + } + } + + textureSelected = EditorGUILayout.Popup(Math.Min(textures.Count, textureSelected), new GUIContent("Select Texture").ToSingle().Concat(textures.Select(t => new GUIContent(t.name))).ToArray()); + if (textureSelected != 0) + { + IsoTextureEditor editor = EditorWindow.GetWindow(); + editor.Init(textures[textureSelected - 1]); + editor.Show(); + textureSelected = 0; + } + } + } +} + [ExecuteInEditMode] public class IsoObject : MonoBehaviour { @@ -19,7 +54,7 @@ private void PreRender(Camera cam) { //Debug.Log(cam.GetInstanceID()); - if (cam.orthographic && isoEditor.IsoMode) + if (cam.orthographic && (isoEditor.IsoMode || cam == isoEditor.IsoCamera)) { Vector3 viewPos = cam.WorldToViewportPoint(gameObject.transform.position); foreach (MeshRenderer mr in IsoMeshes) diff --git a/Assets/IsoShader.shader b/Assets/IsoShader.shader index 73db29a..fa1b1cb 100755 --- a/Assets/IsoShader.shader +++ b/Assets/IsoShader.shader @@ -5,7 +5,7 @@ _MainTex ("Texture", 2D) = "white" {} _CenterPoint ("Object Center", Vector) = (0,0,0,0) _TextureOffset("Texture Offset", Vector) = (0,0,0,0) - _TextureScale("Texture Scale", Float) = 1 + _PixelsPerUnit("Pixels Per World Unit", Float) = 1 } SubShader { @@ -42,7 +42,7 @@ float4 _CenterPoint; float4 _TextureOffset; - float _TextureScale; + float _PixelsPerUnit; v2f vert (appdata v) { @@ -56,8 +56,25 @@ fixed4 frag (v2f i) : SV_Target { + // unity_OrthoParams.xy / 0.70710678 = Wu/Vp + // PixelsPerUnit = Px/Wu + // _MainTex_TexelSize.xy = Uv/Px + + // we want Uv from: + // (i.screenPos.xy - CenterPoint.xy) = Vp + // (i.screenPos.xy - CenterPoint.xy) * unity_OrthoParams.x * _PixelsPerUnit * _MainTex_TexelSize.xy = Uv + + float2 worldUnitScale = unity_OrthoParams.xy / 0.70710678; + float2 offset = float2(i.screenPos.x - _CenterPoint.x, _CenterPoint.y - i.screenPos.y); + float2 uvs = float2((offset.x * worldUnitScale.x * _PixelsPerUnit - _TextureOffset.x) * _MainTex_TexelSize.x, + 1 - (offset.y * worldUnitScale.y * _PixelsPerUnit - _TextureOffset.y) * _MainTex_TexelSize.y); + // sample the texture - fixed4 col = tex2D(_MainTex, (i.screenPos.xy - _CenterPoint.xy - _TextureOffset.xy * _MainTex_TexelSize.xy) / _TextureScale); + fixed4 col = tex2D(_MainTex, uvs); + + clip(col.a - 0.5); + //fixed4 col = fixed4(uvs.x, 0, 0, 1); + //fixed4 col = fixed4(uvs.xy, 0, 1); // apply fog //UNITY_APPLY_FOG(i.fogCoord, col); diff --git a/Assets/IsoTextureEditor.cs b/Assets/IsoTextureEditor.cs new file mode 100644 index 0000000..a5f5037 --- /dev/null +++ b/Assets/IsoTextureEditor.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEditor; +using UnityEngine; + +public class IsoTextureEditor : EditorWindow +{ + private Camera cam; + private Texture texture; + private RenderTexture handleTex; + private void Awake() + { + cam = EditorUtility.CreateGameObjectWithHideFlags("testCam", HideFlags.HideAndDontSave, typeof(Camera)).GetComponent(); + cam.clearFlags = CameraClearFlags.SolidColor; + cam.backgroundColor = new Color(0, 0, 0, 0); + cam.cullingMask = 0; + cam.orthographic = true; + } + private void OnDestroy() + { + DestroyImmediate(cam); + } + public void Init(Texture texture) + { + this.texture = texture; + titleContent = new GUIContent(texture.name + ": Iso Boxes"); + minSize = new Vector2(texture.width, texture.height + 30); + + handleTex = new RenderTexture(texture.width, texture.height, 0); + cam.targetTexture = handleTex; + + cam.orthographicSize = texture.height * 0.5f; + cam.transform.position = new Vector3(texture.width * 0.5f, texture.height * 0.5f, 0); + cam.transform.rotation = Quaternion.identity; + } + private void OnGUI() + { + if (texture != null) + { + GUI.DrawTexture(new Rect(0, 0, texture.width, texture.height), texture); + if (GUI.Button(new Rect(5, texture.height + 5, 80, 25), "Save")) + { + + } + + Handles.SetCamera(cam); + Handles.PositionHandle(new Vector3(), Quaternion.identity); + Handles.DrawCamera(new Rect(0, 0, texture.width, texture.height), cam); + } + } +} \ No newline at end of file diff --git a/Assets/Extensions.cs b/Assets/Extensions.cs new file mode 100644 index 0000000..26c3cab --- /dev/null +++ b/Assets/Extensions.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +public static class Extensions +{ + public static IEnumerable ToSingle(this T item) + { + yield return item; + } +} diff --git a/Assets/Extensions.cs.meta b/Assets/Extensions.cs.meta new file mode 100644 index 0000000..f034002 --- /dev/null +++ b/Assets/Extensions.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 538cc91c599e24c409d54b93fd3f450b +timeCreated: 1572760855 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/IsoEditor.cs b/Assets/IsoEditor.cs index 2cea357..0895cdb 100755 --- a/Assets/IsoEditor.cs +++ b/Assets/IsoEditor.cs @@ -17,9 +17,21 @@ EnableButtons(); } + private void OnDisable() + { + DisableButtons(); + } + // Update is called once per frame void Update () { + if (isoMode) + { + foreach (SceneView sv in SceneView.sceneViews) + { + sv.rotation = IsoCamera.transform.rotation; + } + } } private bool isoMode = false; @@ -41,6 +53,15 @@ SceneView.RepaintAll(); } + private struct SaveScene + { + public Vector3 P; + public Quaternion Q; + public bool O; + } + + private Dictionary saved = new Dictionary(); + public void OnSceneGUI(SceneView sceneView) { Handles.BeginGUI(); @@ -51,19 +72,35 @@ if (isoMode) { - lastCameraP = sceneView.pivot; - lastCameraQ = sceneView.rotation; - lastOrtho = sceneView.orthographic; - - sceneView.AlignViewToObject(IsoCamera.transform); - sceneView.orthographic = true; - + saved.Clear(); } - else + + foreach (SceneView sv in SceneView.sceneViews) { - sceneView.pivot = lastCameraP; - sceneView.rotation = lastCameraQ; - sceneView.orthographic = lastOrtho; + if (isoMode) + { + saved[sv] = new SaveScene + { + P = sv.pivot, + Q = sv.rotation, + O = sv.orthographic + }; + + sv.AlignViewToObject(IsoCamera.transform); + sv.orthographic = true; + sv.isRotationLocked = true; + + } + else + { + if (saved.ContainsKey(sv)) + { + sv.pivot = saved[sv].P; + sv.rotation = saved[sv].Q; + sv.orthographic = saved[sv].O; + } + sv.isRotationLocked = false; + } } } Handles.EndGUI(); diff --git a/Assets/IsoObject.cs b/Assets/IsoObject.cs index 86ecd64..9782b6f 100755 --- a/Assets/IsoObject.cs +++ b/Assets/IsoObject.cs @@ -1,8 +1,43 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Linq; +using UnityEditor; using UnityEngine; +[CustomEditor(typeof(IsoObject))] +public class IsoObjectEditor : Editor +{ + private int textureSelected = 0; + private List textures = new List(); + public override void OnInspectorGUI() + { + DrawDefaultInspector(); + + textures.Clear(); + if (target is IsoObject) + { + IsoObject isoObject = target as IsoObject; + foreach (MeshRenderer mr in isoObject.gameObject.GetComponentsInChildren()) + { + if (mr.sharedMaterial.shader.name == "Unlit/IsoShader") + { + textures.Add(mr.sharedMaterial.GetTexture("_MainTex")); + } + } + + textureSelected = EditorGUILayout.Popup(Math.Min(textures.Count, textureSelected), new GUIContent("Select Texture").ToSingle().Concat(textures.Select(t => new GUIContent(t.name))).ToArray()); + if (textureSelected != 0) + { + IsoTextureEditor editor = EditorWindow.GetWindow(); + editor.Init(textures[textureSelected - 1]); + editor.Show(); + textureSelected = 0; + } + } + } +} + [ExecuteInEditMode] public class IsoObject : MonoBehaviour { @@ -19,7 +54,7 @@ private void PreRender(Camera cam) { //Debug.Log(cam.GetInstanceID()); - if (cam.orthographic && isoEditor.IsoMode) + if (cam.orthographic && (isoEditor.IsoMode || cam == isoEditor.IsoCamera)) { Vector3 viewPos = cam.WorldToViewportPoint(gameObject.transform.position); foreach (MeshRenderer mr in IsoMeshes) diff --git a/Assets/IsoShader.shader b/Assets/IsoShader.shader index 73db29a..fa1b1cb 100755 --- a/Assets/IsoShader.shader +++ b/Assets/IsoShader.shader @@ -5,7 +5,7 @@ _MainTex ("Texture", 2D) = "white" {} _CenterPoint ("Object Center", Vector) = (0,0,0,0) _TextureOffset("Texture Offset", Vector) = (0,0,0,0) - _TextureScale("Texture Scale", Float) = 1 + _PixelsPerUnit("Pixels Per World Unit", Float) = 1 } SubShader { @@ -42,7 +42,7 @@ float4 _CenterPoint; float4 _TextureOffset; - float _TextureScale; + float _PixelsPerUnit; v2f vert (appdata v) { @@ -56,8 +56,25 @@ fixed4 frag (v2f i) : SV_Target { + // unity_OrthoParams.xy / 0.70710678 = Wu/Vp + // PixelsPerUnit = Px/Wu + // _MainTex_TexelSize.xy = Uv/Px + + // we want Uv from: + // (i.screenPos.xy - CenterPoint.xy) = Vp + // (i.screenPos.xy - CenterPoint.xy) * unity_OrthoParams.x * _PixelsPerUnit * _MainTex_TexelSize.xy = Uv + + float2 worldUnitScale = unity_OrthoParams.xy / 0.70710678; + float2 offset = float2(i.screenPos.x - _CenterPoint.x, _CenterPoint.y - i.screenPos.y); + float2 uvs = float2((offset.x * worldUnitScale.x * _PixelsPerUnit - _TextureOffset.x) * _MainTex_TexelSize.x, + 1 - (offset.y * worldUnitScale.y * _PixelsPerUnit - _TextureOffset.y) * _MainTex_TexelSize.y); + // sample the texture - fixed4 col = tex2D(_MainTex, (i.screenPos.xy - _CenterPoint.xy - _TextureOffset.xy * _MainTex_TexelSize.xy) / _TextureScale); + fixed4 col = tex2D(_MainTex, uvs); + + clip(col.a - 0.5); + //fixed4 col = fixed4(uvs.x, 0, 0, 1); + //fixed4 col = fixed4(uvs.xy, 0, 1); // apply fog //UNITY_APPLY_FOG(i.fogCoord, col); diff --git a/Assets/IsoTextureEditor.cs b/Assets/IsoTextureEditor.cs new file mode 100644 index 0000000..a5f5037 --- /dev/null +++ b/Assets/IsoTextureEditor.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEditor; +using UnityEngine; + +public class IsoTextureEditor : EditorWindow +{ + private Camera cam; + private Texture texture; + private RenderTexture handleTex; + private void Awake() + { + cam = EditorUtility.CreateGameObjectWithHideFlags("testCam", HideFlags.HideAndDontSave, typeof(Camera)).GetComponent(); + cam.clearFlags = CameraClearFlags.SolidColor; + cam.backgroundColor = new Color(0, 0, 0, 0); + cam.cullingMask = 0; + cam.orthographic = true; + } + private void OnDestroy() + { + DestroyImmediate(cam); + } + public void Init(Texture texture) + { + this.texture = texture; + titleContent = new GUIContent(texture.name + ": Iso Boxes"); + minSize = new Vector2(texture.width, texture.height + 30); + + handleTex = new RenderTexture(texture.width, texture.height, 0); + cam.targetTexture = handleTex; + + cam.orthographicSize = texture.height * 0.5f; + cam.transform.position = new Vector3(texture.width * 0.5f, texture.height * 0.5f, 0); + cam.transform.rotation = Quaternion.identity; + } + private void OnGUI() + { + if (texture != null) + { + GUI.DrawTexture(new Rect(0, 0, texture.width, texture.height), texture); + if (GUI.Button(new Rect(5, texture.height + 5, 80, 25), "Save")) + { + + } + + Handles.SetCamera(cam); + Handles.PositionHandle(new Vector3(), Quaternion.identity); + Handles.DrawCamera(new Rect(0, 0, texture.width, texture.height), cam); + } + } +} \ No newline at end of file diff --git a/Assets/IsoTextureEditor.cs.meta b/Assets/IsoTextureEditor.cs.meta new file mode 100644 index 0000000..d89c534 --- /dev/null +++ b/Assets/IsoTextureEditor.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: c740ebdf5f67c96448e4b8878a4eb94c +timeCreated: 1572759990 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Extensions.cs b/Assets/Extensions.cs new file mode 100644 index 0000000..26c3cab --- /dev/null +++ b/Assets/Extensions.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +public static class Extensions +{ + public static IEnumerable ToSingle(this T item) + { + yield return item; + } +} diff --git a/Assets/Extensions.cs.meta b/Assets/Extensions.cs.meta new file mode 100644 index 0000000..f034002 --- /dev/null +++ b/Assets/Extensions.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 538cc91c599e24c409d54b93fd3f450b +timeCreated: 1572760855 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/IsoEditor.cs b/Assets/IsoEditor.cs index 2cea357..0895cdb 100755 --- a/Assets/IsoEditor.cs +++ b/Assets/IsoEditor.cs @@ -17,9 +17,21 @@ EnableButtons(); } + private void OnDisable() + { + DisableButtons(); + } + // Update is called once per frame void Update () { + if (isoMode) + { + foreach (SceneView sv in SceneView.sceneViews) + { + sv.rotation = IsoCamera.transform.rotation; + } + } } private bool isoMode = false; @@ -41,6 +53,15 @@ SceneView.RepaintAll(); } + private struct SaveScene + { + public Vector3 P; + public Quaternion Q; + public bool O; + } + + private Dictionary saved = new Dictionary(); + public void OnSceneGUI(SceneView sceneView) { Handles.BeginGUI(); @@ -51,19 +72,35 @@ if (isoMode) { - lastCameraP = sceneView.pivot; - lastCameraQ = sceneView.rotation; - lastOrtho = sceneView.orthographic; - - sceneView.AlignViewToObject(IsoCamera.transform); - sceneView.orthographic = true; - + saved.Clear(); } - else + + foreach (SceneView sv in SceneView.sceneViews) { - sceneView.pivot = lastCameraP; - sceneView.rotation = lastCameraQ; - sceneView.orthographic = lastOrtho; + if (isoMode) + { + saved[sv] = new SaveScene + { + P = sv.pivot, + Q = sv.rotation, + O = sv.orthographic + }; + + sv.AlignViewToObject(IsoCamera.transform); + sv.orthographic = true; + sv.isRotationLocked = true; + + } + else + { + if (saved.ContainsKey(sv)) + { + sv.pivot = saved[sv].P; + sv.rotation = saved[sv].Q; + sv.orthographic = saved[sv].O; + } + sv.isRotationLocked = false; + } } } Handles.EndGUI(); diff --git a/Assets/IsoObject.cs b/Assets/IsoObject.cs index 86ecd64..9782b6f 100755 --- a/Assets/IsoObject.cs +++ b/Assets/IsoObject.cs @@ -1,8 +1,43 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Linq; +using UnityEditor; using UnityEngine; +[CustomEditor(typeof(IsoObject))] +public class IsoObjectEditor : Editor +{ + private int textureSelected = 0; + private List textures = new List(); + public override void OnInspectorGUI() + { + DrawDefaultInspector(); + + textures.Clear(); + if (target is IsoObject) + { + IsoObject isoObject = target as IsoObject; + foreach (MeshRenderer mr in isoObject.gameObject.GetComponentsInChildren()) + { + if (mr.sharedMaterial.shader.name == "Unlit/IsoShader") + { + textures.Add(mr.sharedMaterial.GetTexture("_MainTex")); + } + } + + textureSelected = EditorGUILayout.Popup(Math.Min(textures.Count, textureSelected), new GUIContent("Select Texture").ToSingle().Concat(textures.Select(t => new GUIContent(t.name))).ToArray()); + if (textureSelected != 0) + { + IsoTextureEditor editor = EditorWindow.GetWindow(); + editor.Init(textures[textureSelected - 1]); + editor.Show(); + textureSelected = 0; + } + } + } +} + [ExecuteInEditMode] public class IsoObject : MonoBehaviour { @@ -19,7 +54,7 @@ private void PreRender(Camera cam) { //Debug.Log(cam.GetInstanceID()); - if (cam.orthographic && isoEditor.IsoMode) + if (cam.orthographic && (isoEditor.IsoMode || cam == isoEditor.IsoCamera)) { Vector3 viewPos = cam.WorldToViewportPoint(gameObject.transform.position); foreach (MeshRenderer mr in IsoMeshes) diff --git a/Assets/IsoShader.shader b/Assets/IsoShader.shader index 73db29a..fa1b1cb 100755 --- a/Assets/IsoShader.shader +++ b/Assets/IsoShader.shader @@ -5,7 +5,7 @@ _MainTex ("Texture", 2D) = "white" {} _CenterPoint ("Object Center", Vector) = (0,0,0,0) _TextureOffset("Texture Offset", Vector) = (0,0,0,0) - _TextureScale("Texture Scale", Float) = 1 + _PixelsPerUnit("Pixels Per World Unit", Float) = 1 } SubShader { @@ -42,7 +42,7 @@ float4 _CenterPoint; float4 _TextureOffset; - float _TextureScale; + float _PixelsPerUnit; v2f vert (appdata v) { @@ -56,8 +56,25 @@ fixed4 frag (v2f i) : SV_Target { + // unity_OrthoParams.xy / 0.70710678 = Wu/Vp + // PixelsPerUnit = Px/Wu + // _MainTex_TexelSize.xy = Uv/Px + + // we want Uv from: + // (i.screenPos.xy - CenterPoint.xy) = Vp + // (i.screenPos.xy - CenterPoint.xy) * unity_OrthoParams.x * _PixelsPerUnit * _MainTex_TexelSize.xy = Uv + + float2 worldUnitScale = unity_OrthoParams.xy / 0.70710678; + float2 offset = float2(i.screenPos.x - _CenterPoint.x, _CenterPoint.y - i.screenPos.y); + float2 uvs = float2((offset.x * worldUnitScale.x * _PixelsPerUnit - _TextureOffset.x) * _MainTex_TexelSize.x, + 1 - (offset.y * worldUnitScale.y * _PixelsPerUnit - _TextureOffset.y) * _MainTex_TexelSize.y); + // sample the texture - fixed4 col = tex2D(_MainTex, (i.screenPos.xy - _CenterPoint.xy - _TextureOffset.xy * _MainTex_TexelSize.xy) / _TextureScale); + fixed4 col = tex2D(_MainTex, uvs); + + clip(col.a - 0.5); + //fixed4 col = fixed4(uvs.x, 0, 0, 1); + //fixed4 col = fixed4(uvs.xy, 0, 1); // apply fog //UNITY_APPLY_FOG(i.fogCoord, col); diff --git a/Assets/IsoTextureEditor.cs b/Assets/IsoTextureEditor.cs new file mode 100644 index 0000000..a5f5037 --- /dev/null +++ b/Assets/IsoTextureEditor.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEditor; +using UnityEngine; + +public class IsoTextureEditor : EditorWindow +{ + private Camera cam; + private Texture texture; + private RenderTexture handleTex; + private void Awake() + { + cam = EditorUtility.CreateGameObjectWithHideFlags("testCam", HideFlags.HideAndDontSave, typeof(Camera)).GetComponent(); + cam.clearFlags = CameraClearFlags.SolidColor; + cam.backgroundColor = new Color(0, 0, 0, 0); + cam.cullingMask = 0; + cam.orthographic = true; + } + private void OnDestroy() + { + DestroyImmediate(cam); + } + public void Init(Texture texture) + { + this.texture = texture; + titleContent = new GUIContent(texture.name + ": Iso Boxes"); + minSize = new Vector2(texture.width, texture.height + 30); + + handleTex = new RenderTexture(texture.width, texture.height, 0); + cam.targetTexture = handleTex; + + cam.orthographicSize = texture.height * 0.5f; + cam.transform.position = new Vector3(texture.width * 0.5f, texture.height * 0.5f, 0); + cam.transform.rotation = Quaternion.identity; + } + private void OnGUI() + { + if (texture != null) + { + GUI.DrawTexture(new Rect(0, 0, texture.width, texture.height), texture); + if (GUI.Button(new Rect(5, texture.height + 5, 80, 25), "Save")) + { + + } + + Handles.SetCamera(cam); + Handles.PositionHandle(new Vector3(), Quaternion.identity); + Handles.DrawCamera(new Rect(0, 0, texture.width, texture.height), cam); + } + } +} \ No newline at end of file diff --git a/Assets/IsoTextureEditor.cs.meta b/Assets/IsoTextureEditor.cs.meta new file mode 100644 index 0000000..d89c534 --- /dev/null +++ b/Assets/IsoTextureEditor.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: c740ebdf5f67c96448e4b8878a4eb94c +timeCreated: 1572759990 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Textures/House_FallingLeaves.png b/Assets/Textures/House_FallingLeaves.png index 7c42a99..4bf6fed 100644 --- a/Assets/Textures/House_FallingLeaves.png +++ b/Assets/Textures/House_FallingLeaves.png Binary files differ diff --git a/Assets/Extensions.cs b/Assets/Extensions.cs new file mode 100644 index 0000000..26c3cab --- /dev/null +++ b/Assets/Extensions.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +public static class Extensions +{ + public static IEnumerable ToSingle(this T item) + { + yield return item; + } +} diff --git a/Assets/Extensions.cs.meta b/Assets/Extensions.cs.meta new file mode 100644 index 0000000..f034002 --- /dev/null +++ b/Assets/Extensions.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 538cc91c599e24c409d54b93fd3f450b +timeCreated: 1572760855 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/IsoEditor.cs b/Assets/IsoEditor.cs index 2cea357..0895cdb 100755 --- a/Assets/IsoEditor.cs +++ b/Assets/IsoEditor.cs @@ -17,9 +17,21 @@ EnableButtons(); } + private void OnDisable() + { + DisableButtons(); + } + // Update is called once per frame void Update () { + if (isoMode) + { + foreach (SceneView sv in SceneView.sceneViews) + { + sv.rotation = IsoCamera.transform.rotation; + } + } } private bool isoMode = false; @@ -41,6 +53,15 @@ SceneView.RepaintAll(); } + private struct SaveScene + { + public Vector3 P; + public Quaternion Q; + public bool O; + } + + private Dictionary saved = new Dictionary(); + public void OnSceneGUI(SceneView sceneView) { Handles.BeginGUI(); @@ -51,19 +72,35 @@ if (isoMode) { - lastCameraP = sceneView.pivot; - lastCameraQ = sceneView.rotation; - lastOrtho = sceneView.orthographic; - - sceneView.AlignViewToObject(IsoCamera.transform); - sceneView.orthographic = true; - + saved.Clear(); } - else + + foreach (SceneView sv in SceneView.sceneViews) { - sceneView.pivot = lastCameraP; - sceneView.rotation = lastCameraQ; - sceneView.orthographic = lastOrtho; + if (isoMode) + { + saved[sv] = new SaveScene + { + P = sv.pivot, + Q = sv.rotation, + O = sv.orthographic + }; + + sv.AlignViewToObject(IsoCamera.transform); + sv.orthographic = true; + sv.isRotationLocked = true; + + } + else + { + if (saved.ContainsKey(sv)) + { + sv.pivot = saved[sv].P; + sv.rotation = saved[sv].Q; + sv.orthographic = saved[sv].O; + } + sv.isRotationLocked = false; + } } } Handles.EndGUI(); diff --git a/Assets/IsoObject.cs b/Assets/IsoObject.cs index 86ecd64..9782b6f 100755 --- a/Assets/IsoObject.cs +++ b/Assets/IsoObject.cs @@ -1,8 +1,43 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Linq; +using UnityEditor; using UnityEngine; +[CustomEditor(typeof(IsoObject))] +public class IsoObjectEditor : Editor +{ + private int textureSelected = 0; + private List textures = new List(); + public override void OnInspectorGUI() + { + DrawDefaultInspector(); + + textures.Clear(); + if (target is IsoObject) + { + IsoObject isoObject = target as IsoObject; + foreach (MeshRenderer mr in isoObject.gameObject.GetComponentsInChildren()) + { + if (mr.sharedMaterial.shader.name == "Unlit/IsoShader") + { + textures.Add(mr.sharedMaterial.GetTexture("_MainTex")); + } + } + + textureSelected = EditorGUILayout.Popup(Math.Min(textures.Count, textureSelected), new GUIContent("Select Texture").ToSingle().Concat(textures.Select(t => new GUIContent(t.name))).ToArray()); + if (textureSelected != 0) + { + IsoTextureEditor editor = EditorWindow.GetWindow(); + editor.Init(textures[textureSelected - 1]); + editor.Show(); + textureSelected = 0; + } + } + } +} + [ExecuteInEditMode] public class IsoObject : MonoBehaviour { @@ -19,7 +54,7 @@ private void PreRender(Camera cam) { //Debug.Log(cam.GetInstanceID()); - if (cam.orthographic && isoEditor.IsoMode) + if (cam.orthographic && (isoEditor.IsoMode || cam == isoEditor.IsoCamera)) { Vector3 viewPos = cam.WorldToViewportPoint(gameObject.transform.position); foreach (MeshRenderer mr in IsoMeshes) diff --git a/Assets/IsoShader.shader b/Assets/IsoShader.shader index 73db29a..fa1b1cb 100755 --- a/Assets/IsoShader.shader +++ b/Assets/IsoShader.shader @@ -5,7 +5,7 @@ _MainTex ("Texture", 2D) = "white" {} _CenterPoint ("Object Center", Vector) = (0,0,0,0) _TextureOffset("Texture Offset", Vector) = (0,0,0,0) - _TextureScale("Texture Scale", Float) = 1 + _PixelsPerUnit("Pixels Per World Unit", Float) = 1 } SubShader { @@ -42,7 +42,7 @@ float4 _CenterPoint; float4 _TextureOffset; - float _TextureScale; + float _PixelsPerUnit; v2f vert (appdata v) { @@ -56,8 +56,25 @@ fixed4 frag (v2f i) : SV_Target { + // unity_OrthoParams.xy / 0.70710678 = Wu/Vp + // PixelsPerUnit = Px/Wu + // _MainTex_TexelSize.xy = Uv/Px + + // we want Uv from: + // (i.screenPos.xy - CenterPoint.xy) = Vp + // (i.screenPos.xy - CenterPoint.xy) * unity_OrthoParams.x * _PixelsPerUnit * _MainTex_TexelSize.xy = Uv + + float2 worldUnitScale = unity_OrthoParams.xy / 0.70710678; + float2 offset = float2(i.screenPos.x - _CenterPoint.x, _CenterPoint.y - i.screenPos.y); + float2 uvs = float2((offset.x * worldUnitScale.x * _PixelsPerUnit - _TextureOffset.x) * _MainTex_TexelSize.x, + 1 - (offset.y * worldUnitScale.y * _PixelsPerUnit - _TextureOffset.y) * _MainTex_TexelSize.y); + // sample the texture - fixed4 col = tex2D(_MainTex, (i.screenPos.xy - _CenterPoint.xy - _TextureOffset.xy * _MainTex_TexelSize.xy) / _TextureScale); + fixed4 col = tex2D(_MainTex, uvs); + + clip(col.a - 0.5); + //fixed4 col = fixed4(uvs.x, 0, 0, 1); + //fixed4 col = fixed4(uvs.xy, 0, 1); // apply fog //UNITY_APPLY_FOG(i.fogCoord, col); diff --git a/Assets/IsoTextureEditor.cs b/Assets/IsoTextureEditor.cs new file mode 100644 index 0000000..a5f5037 --- /dev/null +++ b/Assets/IsoTextureEditor.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEditor; +using UnityEngine; + +public class IsoTextureEditor : EditorWindow +{ + private Camera cam; + private Texture texture; + private RenderTexture handleTex; + private void Awake() + { + cam = EditorUtility.CreateGameObjectWithHideFlags("testCam", HideFlags.HideAndDontSave, typeof(Camera)).GetComponent(); + cam.clearFlags = CameraClearFlags.SolidColor; + cam.backgroundColor = new Color(0, 0, 0, 0); + cam.cullingMask = 0; + cam.orthographic = true; + } + private void OnDestroy() + { + DestroyImmediate(cam); + } + public void Init(Texture texture) + { + this.texture = texture; + titleContent = new GUIContent(texture.name + ": Iso Boxes"); + minSize = new Vector2(texture.width, texture.height + 30); + + handleTex = new RenderTexture(texture.width, texture.height, 0); + cam.targetTexture = handleTex; + + cam.orthographicSize = texture.height * 0.5f; + cam.transform.position = new Vector3(texture.width * 0.5f, texture.height * 0.5f, 0); + cam.transform.rotation = Quaternion.identity; + } + private void OnGUI() + { + if (texture != null) + { + GUI.DrawTexture(new Rect(0, 0, texture.width, texture.height), texture); + if (GUI.Button(new Rect(5, texture.height + 5, 80, 25), "Save")) + { + + } + + Handles.SetCamera(cam); + Handles.PositionHandle(new Vector3(), Quaternion.identity); + Handles.DrawCamera(new Rect(0, 0, texture.width, texture.height), cam); + } + } +} \ No newline at end of file diff --git a/Assets/IsoTextureEditor.cs.meta b/Assets/IsoTextureEditor.cs.meta new file mode 100644 index 0000000..d89c534 --- /dev/null +++ b/Assets/IsoTextureEditor.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: c740ebdf5f67c96448e4b8878a4eb94c +timeCreated: 1572759990 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Textures/House_FallingLeaves.png b/Assets/Textures/House_FallingLeaves.png index 7c42a99..4bf6fed 100644 --- a/Assets/Textures/House_FallingLeaves.png +++ b/Assets/Textures/House_FallingLeaves.png Binary files differ diff --git a/Assets/Textures/House_FallingLeaves.png.meta b/Assets/Textures/House_FallingLeaves.png.meta index f454001..fda83d9 100755 --- a/Assets/Textures/House_FallingLeaves.png.meta +++ b/Assets/Textures/House_FallingLeaves.png.meta @@ -35,7 +35,7 @@ wrapU: 1 wrapV: 1 wrapW: 1 - nPOTScale: 1 + nPOTScale: 0 lightmap: 0 compressionQuality: 50 spriteMode: 0 @@ -43,9 +43,8 @@ spriteMeshType: 1 alignment: 0 spritePivot: {x: 0.5, y: 0.5} - spritePixelsToUnits: 100 spriteBorder: {x: 0, y: 0, z: 0, w: 0} - spriteGenerateFallbackPhysicsShape: 1 + spritePixelsToUnits: 100 alphaUsage: 1 alphaIsTransparency: 0 spriteTessellationDetail: -1 @@ -64,7 +63,6 @@ crunchedCompression: 0 allowsAlphaSplitting: 0 overridden: 0 - androidETC2FallbackOverride: 0 - buildTarget: Standalone maxTextureSize: 2048 resizeAlgorithm: 0 @@ -74,7 +72,6 @@ crunchedCompression: 0 allowsAlphaSplitting: 0 overridden: 0 - androidETC2FallbackOverride: 0 - buildTarget: Android maxTextureSize: 2048 resizeAlgorithm: 0 @@ -84,7 +81,6 @@ crunchedCompression: 0 allowsAlphaSplitting: 0 overridden: 0 - androidETC2FallbackOverride: 0 - buildTarget: WebGL maxTextureSize: 2048 resizeAlgorithm: 0 @@ -94,7 +90,6 @@ crunchedCompression: 0 allowsAlphaSplitting: 0 overridden: 0 - androidETC2FallbackOverride: 0 spriteSheet: serializedVersion: 2 sprites: [] diff --git a/Assets/Extensions.cs b/Assets/Extensions.cs new file mode 100644 index 0000000..26c3cab --- /dev/null +++ b/Assets/Extensions.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +public static class Extensions +{ + public static IEnumerable ToSingle(this T item) + { + yield return item; + } +} diff --git a/Assets/Extensions.cs.meta b/Assets/Extensions.cs.meta new file mode 100644 index 0000000..f034002 --- /dev/null +++ b/Assets/Extensions.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 538cc91c599e24c409d54b93fd3f450b +timeCreated: 1572760855 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/IsoEditor.cs b/Assets/IsoEditor.cs index 2cea357..0895cdb 100755 --- a/Assets/IsoEditor.cs +++ b/Assets/IsoEditor.cs @@ -17,9 +17,21 @@ EnableButtons(); } + private void OnDisable() + { + DisableButtons(); + } + // Update is called once per frame void Update () { + if (isoMode) + { + foreach (SceneView sv in SceneView.sceneViews) + { + sv.rotation = IsoCamera.transform.rotation; + } + } } private bool isoMode = false; @@ -41,6 +53,15 @@ SceneView.RepaintAll(); } + private struct SaveScene + { + public Vector3 P; + public Quaternion Q; + public bool O; + } + + private Dictionary saved = new Dictionary(); + public void OnSceneGUI(SceneView sceneView) { Handles.BeginGUI(); @@ -51,19 +72,35 @@ if (isoMode) { - lastCameraP = sceneView.pivot; - lastCameraQ = sceneView.rotation; - lastOrtho = sceneView.orthographic; - - sceneView.AlignViewToObject(IsoCamera.transform); - sceneView.orthographic = true; - + saved.Clear(); } - else + + foreach (SceneView sv in SceneView.sceneViews) { - sceneView.pivot = lastCameraP; - sceneView.rotation = lastCameraQ; - sceneView.orthographic = lastOrtho; + if (isoMode) + { + saved[sv] = new SaveScene + { + P = sv.pivot, + Q = sv.rotation, + O = sv.orthographic + }; + + sv.AlignViewToObject(IsoCamera.transform); + sv.orthographic = true; + sv.isRotationLocked = true; + + } + else + { + if (saved.ContainsKey(sv)) + { + sv.pivot = saved[sv].P; + sv.rotation = saved[sv].Q; + sv.orthographic = saved[sv].O; + } + sv.isRotationLocked = false; + } } } Handles.EndGUI(); diff --git a/Assets/IsoObject.cs b/Assets/IsoObject.cs index 86ecd64..9782b6f 100755 --- a/Assets/IsoObject.cs +++ b/Assets/IsoObject.cs @@ -1,8 +1,43 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Linq; +using UnityEditor; using UnityEngine; +[CustomEditor(typeof(IsoObject))] +public class IsoObjectEditor : Editor +{ + private int textureSelected = 0; + private List textures = new List(); + public override void OnInspectorGUI() + { + DrawDefaultInspector(); + + textures.Clear(); + if (target is IsoObject) + { + IsoObject isoObject = target as IsoObject; + foreach (MeshRenderer mr in isoObject.gameObject.GetComponentsInChildren()) + { + if (mr.sharedMaterial.shader.name == "Unlit/IsoShader") + { + textures.Add(mr.sharedMaterial.GetTexture("_MainTex")); + } + } + + textureSelected = EditorGUILayout.Popup(Math.Min(textures.Count, textureSelected), new GUIContent("Select Texture").ToSingle().Concat(textures.Select(t => new GUIContent(t.name))).ToArray()); + if (textureSelected != 0) + { + IsoTextureEditor editor = EditorWindow.GetWindow(); + editor.Init(textures[textureSelected - 1]); + editor.Show(); + textureSelected = 0; + } + } + } +} + [ExecuteInEditMode] public class IsoObject : MonoBehaviour { @@ -19,7 +54,7 @@ private void PreRender(Camera cam) { //Debug.Log(cam.GetInstanceID()); - if (cam.orthographic && isoEditor.IsoMode) + if (cam.orthographic && (isoEditor.IsoMode || cam == isoEditor.IsoCamera)) { Vector3 viewPos = cam.WorldToViewportPoint(gameObject.transform.position); foreach (MeshRenderer mr in IsoMeshes) diff --git a/Assets/IsoShader.shader b/Assets/IsoShader.shader index 73db29a..fa1b1cb 100755 --- a/Assets/IsoShader.shader +++ b/Assets/IsoShader.shader @@ -5,7 +5,7 @@ _MainTex ("Texture", 2D) = "white" {} _CenterPoint ("Object Center", Vector) = (0,0,0,0) _TextureOffset("Texture Offset", Vector) = (0,0,0,0) - _TextureScale("Texture Scale", Float) = 1 + _PixelsPerUnit("Pixels Per World Unit", Float) = 1 } SubShader { @@ -42,7 +42,7 @@ float4 _CenterPoint; float4 _TextureOffset; - float _TextureScale; + float _PixelsPerUnit; v2f vert (appdata v) { @@ -56,8 +56,25 @@ fixed4 frag (v2f i) : SV_Target { + // unity_OrthoParams.xy / 0.70710678 = Wu/Vp + // PixelsPerUnit = Px/Wu + // _MainTex_TexelSize.xy = Uv/Px + + // we want Uv from: + // (i.screenPos.xy - CenterPoint.xy) = Vp + // (i.screenPos.xy - CenterPoint.xy) * unity_OrthoParams.x * _PixelsPerUnit * _MainTex_TexelSize.xy = Uv + + float2 worldUnitScale = unity_OrthoParams.xy / 0.70710678; + float2 offset = float2(i.screenPos.x - _CenterPoint.x, _CenterPoint.y - i.screenPos.y); + float2 uvs = float2((offset.x * worldUnitScale.x * _PixelsPerUnit - _TextureOffset.x) * _MainTex_TexelSize.x, + 1 - (offset.y * worldUnitScale.y * _PixelsPerUnit - _TextureOffset.y) * _MainTex_TexelSize.y); + // sample the texture - fixed4 col = tex2D(_MainTex, (i.screenPos.xy - _CenterPoint.xy - _TextureOffset.xy * _MainTex_TexelSize.xy) / _TextureScale); + fixed4 col = tex2D(_MainTex, uvs); + + clip(col.a - 0.5); + //fixed4 col = fixed4(uvs.x, 0, 0, 1); + //fixed4 col = fixed4(uvs.xy, 0, 1); // apply fog //UNITY_APPLY_FOG(i.fogCoord, col); diff --git a/Assets/IsoTextureEditor.cs b/Assets/IsoTextureEditor.cs new file mode 100644 index 0000000..a5f5037 --- /dev/null +++ b/Assets/IsoTextureEditor.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEditor; +using UnityEngine; + +public class IsoTextureEditor : EditorWindow +{ + private Camera cam; + private Texture texture; + private RenderTexture handleTex; + private void Awake() + { + cam = EditorUtility.CreateGameObjectWithHideFlags("testCam", HideFlags.HideAndDontSave, typeof(Camera)).GetComponent(); + cam.clearFlags = CameraClearFlags.SolidColor; + cam.backgroundColor = new Color(0, 0, 0, 0); + cam.cullingMask = 0; + cam.orthographic = true; + } + private void OnDestroy() + { + DestroyImmediate(cam); + } + public void Init(Texture texture) + { + this.texture = texture; + titleContent = new GUIContent(texture.name + ": Iso Boxes"); + minSize = new Vector2(texture.width, texture.height + 30); + + handleTex = new RenderTexture(texture.width, texture.height, 0); + cam.targetTexture = handleTex; + + cam.orthographicSize = texture.height * 0.5f; + cam.transform.position = new Vector3(texture.width * 0.5f, texture.height * 0.5f, 0); + cam.transform.rotation = Quaternion.identity; + } + private void OnGUI() + { + if (texture != null) + { + GUI.DrawTexture(new Rect(0, 0, texture.width, texture.height), texture); + if (GUI.Button(new Rect(5, texture.height + 5, 80, 25), "Save")) + { + + } + + Handles.SetCamera(cam); + Handles.PositionHandle(new Vector3(), Quaternion.identity); + Handles.DrawCamera(new Rect(0, 0, texture.width, texture.height), cam); + } + } +} \ No newline at end of file diff --git a/Assets/IsoTextureEditor.cs.meta b/Assets/IsoTextureEditor.cs.meta new file mode 100644 index 0000000..d89c534 --- /dev/null +++ b/Assets/IsoTextureEditor.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: c740ebdf5f67c96448e4b8878a4eb94c +timeCreated: 1572759990 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Textures/House_FallingLeaves.png b/Assets/Textures/House_FallingLeaves.png index 7c42a99..4bf6fed 100644 --- a/Assets/Textures/House_FallingLeaves.png +++ b/Assets/Textures/House_FallingLeaves.png Binary files differ diff --git a/Assets/Textures/House_FallingLeaves.png.meta b/Assets/Textures/House_FallingLeaves.png.meta index f454001..fda83d9 100755 --- a/Assets/Textures/House_FallingLeaves.png.meta +++ b/Assets/Textures/House_FallingLeaves.png.meta @@ -35,7 +35,7 @@ wrapU: 1 wrapV: 1 wrapW: 1 - nPOTScale: 1 + nPOTScale: 0 lightmap: 0 compressionQuality: 50 spriteMode: 0 @@ -43,9 +43,8 @@ spriteMeshType: 1 alignment: 0 spritePivot: {x: 0.5, y: 0.5} - spritePixelsToUnits: 100 spriteBorder: {x: 0, y: 0, z: 0, w: 0} - spriteGenerateFallbackPhysicsShape: 1 + spritePixelsToUnits: 100 alphaUsage: 1 alphaIsTransparency: 0 spriteTessellationDetail: -1 @@ -64,7 +63,6 @@ crunchedCompression: 0 allowsAlphaSplitting: 0 overridden: 0 - androidETC2FallbackOverride: 0 - buildTarget: Standalone maxTextureSize: 2048 resizeAlgorithm: 0 @@ -74,7 +72,6 @@ crunchedCompression: 0 allowsAlphaSplitting: 0 overridden: 0 - androidETC2FallbackOverride: 0 - buildTarget: Android maxTextureSize: 2048 resizeAlgorithm: 0 @@ -84,7 +81,6 @@ crunchedCompression: 0 allowsAlphaSplitting: 0 overridden: 0 - androidETC2FallbackOverride: 0 - buildTarget: WebGL maxTextureSize: 2048 resizeAlgorithm: 0 @@ -94,7 +90,6 @@ crunchedCompression: 0 allowsAlphaSplitting: 0 overridden: 0 - androidETC2FallbackOverride: 0 spriteSheet: serializedVersion: 2 sprites: [] diff --git a/Assets/main.unity b/Assets/main.unity index a1f1390..61315eb 100755 --- a/Assets/main.unity +++ b/Assets/main.unity @@ -88,7 +88,6 @@ m_PVRFilteringAtrousPositionSigmaDirect: 0.5 m_PVRFilteringAtrousPositionSigmaIndirect: 2 m_PVRFilteringAtrousPositionSigmaAO: 1 - m_ShowResolutionOverlay: 1 m_LightingDataAsset: {fileID: 0} m_UseShadowmask: 1 --- !u!196 &4 @@ -191,8 +190,8 @@ m_PrefabInternal: {fileID: 0} m_GameObject: {fileID: 516672264} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: -0.54, y: -0.23, z: 1.26} - m_LocalScale: {x: 0.7618044, y: 0.59613603, z: 1.8864031} + m_LocalPosition: {x: -0.5, y: 0.75, z: 1.05} + m_LocalScale: {x: 1, y: 1.5, z: 2.1} m_Children: [] m_Father: {fileID: 1646089004} m_RootOrder: 0 @@ -261,7 +260,6 @@ m_TargetEye: 3 m_HDR: 1 m_AllowMSAA: 1 - m_AllowDynamicResolution: 0 m_ForceIntoRT: 0 m_OcclusionCulling: 1 m_StereoConvergence: 10 @@ -341,7 +339,6 @@ m_TargetEye: 3 m_HDR: 1 m_AllowMSAA: 1 - m_AllowDynamicResolution: 0 m_ForceIntoRT: 0 m_OcclusionCulling: 1 m_StereoConvergence: 10 @@ -366,13 +363,13 @@ m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 0} m_GameObject: {fileID: 1211379094} - m_LocalRotation: {x: 0.20791169, y: 0, z: 0, w: 0.9781476} + m_LocalRotation: {x: 0.30070576, y: 0, z: 0, w: 0.953717} m_LocalPosition: {x: 0, y: 7.41, z: -10.48} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 24, y: 0, z: 0} + m_LocalEulerAnglesHint: {x: 35, y: 0, z: 0} --- !u!21 &1424158291 Material: serializedVersion: 6 @@ -439,6 +436,7 @@ - _Mode: 0 - _OcclusionStrength: 1 - _Parallax: 0.02 + - _PixelsPerUnit: 422 - _SmoothnessTextureChannel: 0 - _SpecularHighlights: 1 - _SrcBlend: 1 @@ -446,10 +444,10 @@ - _UVSec: 0 - _ZWrite: 1 m_Colors: - - _CenterPoint: {r: 0.5, g: 0.2493228, b: 0, a: 0} + - _CenterPoint: {r: 0.5, g: 0.49411634, b: 0, a: 0} - _Color: {r: 1, g: 1, b: 1, a: 1} - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} - - _TextureOffset: {r: 0, g: 0, b: 0, a: 0} + - _TextureOffset: {r: -219, g: -631, b: 0, a: 0} --- !u!1 &1493590970 GameObject: m_ObjectHideFlags: 0 @@ -532,7 +530,6 @@ m_Script: {fileID: 11500000, guid: bcdae60ce96b110429adb0dc2736286a, type: 3} m_Name: m_EditorClassIdentifier: - IsoCamera: {fileID: 1211379095} IsoMeshes: - {fileID: 516672265} --- !u!1 &1707129767 diff --git a/Assets/Extensions.cs b/Assets/Extensions.cs new file mode 100644 index 0000000..26c3cab --- /dev/null +++ b/Assets/Extensions.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +public static class Extensions +{ + public static IEnumerable ToSingle(this T item) + { + yield return item; + } +} diff --git a/Assets/Extensions.cs.meta b/Assets/Extensions.cs.meta new file mode 100644 index 0000000..f034002 --- /dev/null +++ b/Assets/Extensions.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 538cc91c599e24c409d54b93fd3f450b +timeCreated: 1572760855 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/IsoEditor.cs b/Assets/IsoEditor.cs index 2cea357..0895cdb 100755 --- a/Assets/IsoEditor.cs +++ b/Assets/IsoEditor.cs @@ -17,9 +17,21 @@ EnableButtons(); } + private void OnDisable() + { + DisableButtons(); + } + // Update is called once per frame void Update () { + if (isoMode) + { + foreach (SceneView sv in SceneView.sceneViews) + { + sv.rotation = IsoCamera.transform.rotation; + } + } } private bool isoMode = false; @@ -41,6 +53,15 @@ SceneView.RepaintAll(); } + private struct SaveScene + { + public Vector3 P; + public Quaternion Q; + public bool O; + } + + private Dictionary saved = new Dictionary(); + public void OnSceneGUI(SceneView sceneView) { Handles.BeginGUI(); @@ -51,19 +72,35 @@ if (isoMode) { - lastCameraP = sceneView.pivot; - lastCameraQ = sceneView.rotation; - lastOrtho = sceneView.orthographic; - - sceneView.AlignViewToObject(IsoCamera.transform); - sceneView.orthographic = true; - + saved.Clear(); } - else + + foreach (SceneView sv in SceneView.sceneViews) { - sceneView.pivot = lastCameraP; - sceneView.rotation = lastCameraQ; - sceneView.orthographic = lastOrtho; + if (isoMode) + { + saved[sv] = new SaveScene + { + P = sv.pivot, + Q = sv.rotation, + O = sv.orthographic + }; + + sv.AlignViewToObject(IsoCamera.transform); + sv.orthographic = true; + sv.isRotationLocked = true; + + } + else + { + if (saved.ContainsKey(sv)) + { + sv.pivot = saved[sv].P; + sv.rotation = saved[sv].Q; + sv.orthographic = saved[sv].O; + } + sv.isRotationLocked = false; + } } } Handles.EndGUI(); diff --git a/Assets/IsoObject.cs b/Assets/IsoObject.cs index 86ecd64..9782b6f 100755 --- a/Assets/IsoObject.cs +++ b/Assets/IsoObject.cs @@ -1,8 +1,43 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Linq; +using UnityEditor; using UnityEngine; +[CustomEditor(typeof(IsoObject))] +public class IsoObjectEditor : Editor +{ + private int textureSelected = 0; + private List textures = new List(); + public override void OnInspectorGUI() + { + DrawDefaultInspector(); + + textures.Clear(); + if (target is IsoObject) + { + IsoObject isoObject = target as IsoObject; + foreach (MeshRenderer mr in isoObject.gameObject.GetComponentsInChildren()) + { + if (mr.sharedMaterial.shader.name == "Unlit/IsoShader") + { + textures.Add(mr.sharedMaterial.GetTexture("_MainTex")); + } + } + + textureSelected = EditorGUILayout.Popup(Math.Min(textures.Count, textureSelected), new GUIContent("Select Texture").ToSingle().Concat(textures.Select(t => new GUIContent(t.name))).ToArray()); + if (textureSelected != 0) + { + IsoTextureEditor editor = EditorWindow.GetWindow(); + editor.Init(textures[textureSelected - 1]); + editor.Show(); + textureSelected = 0; + } + } + } +} + [ExecuteInEditMode] public class IsoObject : MonoBehaviour { @@ -19,7 +54,7 @@ private void PreRender(Camera cam) { //Debug.Log(cam.GetInstanceID()); - if (cam.orthographic && isoEditor.IsoMode) + if (cam.orthographic && (isoEditor.IsoMode || cam == isoEditor.IsoCamera)) { Vector3 viewPos = cam.WorldToViewportPoint(gameObject.transform.position); foreach (MeshRenderer mr in IsoMeshes) diff --git a/Assets/IsoShader.shader b/Assets/IsoShader.shader index 73db29a..fa1b1cb 100755 --- a/Assets/IsoShader.shader +++ b/Assets/IsoShader.shader @@ -5,7 +5,7 @@ _MainTex ("Texture", 2D) = "white" {} _CenterPoint ("Object Center", Vector) = (0,0,0,0) _TextureOffset("Texture Offset", Vector) = (0,0,0,0) - _TextureScale("Texture Scale", Float) = 1 + _PixelsPerUnit("Pixels Per World Unit", Float) = 1 } SubShader { @@ -42,7 +42,7 @@ float4 _CenterPoint; float4 _TextureOffset; - float _TextureScale; + float _PixelsPerUnit; v2f vert (appdata v) { @@ -56,8 +56,25 @@ fixed4 frag (v2f i) : SV_Target { + // unity_OrthoParams.xy / 0.70710678 = Wu/Vp + // PixelsPerUnit = Px/Wu + // _MainTex_TexelSize.xy = Uv/Px + + // we want Uv from: + // (i.screenPos.xy - CenterPoint.xy) = Vp + // (i.screenPos.xy - CenterPoint.xy) * unity_OrthoParams.x * _PixelsPerUnit * _MainTex_TexelSize.xy = Uv + + float2 worldUnitScale = unity_OrthoParams.xy / 0.70710678; + float2 offset = float2(i.screenPos.x - _CenterPoint.x, _CenterPoint.y - i.screenPos.y); + float2 uvs = float2((offset.x * worldUnitScale.x * _PixelsPerUnit - _TextureOffset.x) * _MainTex_TexelSize.x, + 1 - (offset.y * worldUnitScale.y * _PixelsPerUnit - _TextureOffset.y) * _MainTex_TexelSize.y); + // sample the texture - fixed4 col = tex2D(_MainTex, (i.screenPos.xy - _CenterPoint.xy - _TextureOffset.xy * _MainTex_TexelSize.xy) / _TextureScale); + fixed4 col = tex2D(_MainTex, uvs); + + clip(col.a - 0.5); + //fixed4 col = fixed4(uvs.x, 0, 0, 1); + //fixed4 col = fixed4(uvs.xy, 0, 1); // apply fog //UNITY_APPLY_FOG(i.fogCoord, col); diff --git a/Assets/IsoTextureEditor.cs b/Assets/IsoTextureEditor.cs new file mode 100644 index 0000000..a5f5037 --- /dev/null +++ b/Assets/IsoTextureEditor.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEditor; +using UnityEngine; + +public class IsoTextureEditor : EditorWindow +{ + private Camera cam; + private Texture texture; + private RenderTexture handleTex; + private void Awake() + { + cam = EditorUtility.CreateGameObjectWithHideFlags("testCam", HideFlags.HideAndDontSave, typeof(Camera)).GetComponent(); + cam.clearFlags = CameraClearFlags.SolidColor; + cam.backgroundColor = new Color(0, 0, 0, 0); + cam.cullingMask = 0; + cam.orthographic = true; + } + private void OnDestroy() + { + DestroyImmediate(cam); + } + public void Init(Texture texture) + { + this.texture = texture; + titleContent = new GUIContent(texture.name + ": Iso Boxes"); + minSize = new Vector2(texture.width, texture.height + 30); + + handleTex = new RenderTexture(texture.width, texture.height, 0); + cam.targetTexture = handleTex; + + cam.orthographicSize = texture.height * 0.5f; + cam.transform.position = new Vector3(texture.width * 0.5f, texture.height * 0.5f, 0); + cam.transform.rotation = Quaternion.identity; + } + private void OnGUI() + { + if (texture != null) + { + GUI.DrawTexture(new Rect(0, 0, texture.width, texture.height), texture); + if (GUI.Button(new Rect(5, texture.height + 5, 80, 25), "Save")) + { + + } + + Handles.SetCamera(cam); + Handles.PositionHandle(new Vector3(), Quaternion.identity); + Handles.DrawCamera(new Rect(0, 0, texture.width, texture.height), cam); + } + } +} \ No newline at end of file diff --git a/Assets/IsoTextureEditor.cs.meta b/Assets/IsoTextureEditor.cs.meta new file mode 100644 index 0000000..d89c534 --- /dev/null +++ b/Assets/IsoTextureEditor.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: c740ebdf5f67c96448e4b8878a4eb94c +timeCreated: 1572759990 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Textures/House_FallingLeaves.png b/Assets/Textures/House_FallingLeaves.png index 7c42a99..4bf6fed 100644 --- a/Assets/Textures/House_FallingLeaves.png +++ b/Assets/Textures/House_FallingLeaves.png Binary files differ diff --git a/Assets/Textures/House_FallingLeaves.png.meta b/Assets/Textures/House_FallingLeaves.png.meta index f454001..fda83d9 100755 --- a/Assets/Textures/House_FallingLeaves.png.meta +++ b/Assets/Textures/House_FallingLeaves.png.meta @@ -35,7 +35,7 @@ wrapU: 1 wrapV: 1 wrapW: 1 - nPOTScale: 1 + nPOTScale: 0 lightmap: 0 compressionQuality: 50 spriteMode: 0 @@ -43,9 +43,8 @@ spriteMeshType: 1 alignment: 0 spritePivot: {x: 0.5, y: 0.5} - spritePixelsToUnits: 100 spriteBorder: {x: 0, y: 0, z: 0, w: 0} - spriteGenerateFallbackPhysicsShape: 1 + spritePixelsToUnits: 100 alphaUsage: 1 alphaIsTransparency: 0 spriteTessellationDetail: -1 @@ -64,7 +63,6 @@ crunchedCompression: 0 allowsAlphaSplitting: 0 overridden: 0 - androidETC2FallbackOverride: 0 - buildTarget: Standalone maxTextureSize: 2048 resizeAlgorithm: 0 @@ -74,7 +72,6 @@ crunchedCompression: 0 allowsAlphaSplitting: 0 overridden: 0 - androidETC2FallbackOverride: 0 - buildTarget: Android maxTextureSize: 2048 resizeAlgorithm: 0 @@ -84,7 +81,6 @@ crunchedCompression: 0 allowsAlphaSplitting: 0 overridden: 0 - androidETC2FallbackOverride: 0 - buildTarget: WebGL maxTextureSize: 2048 resizeAlgorithm: 0 @@ -94,7 +90,6 @@ crunchedCompression: 0 allowsAlphaSplitting: 0 overridden: 0 - androidETC2FallbackOverride: 0 spriteSheet: serializedVersion: 2 sprites: [] diff --git a/Assets/main.unity b/Assets/main.unity index a1f1390..61315eb 100755 --- a/Assets/main.unity +++ b/Assets/main.unity @@ -88,7 +88,6 @@ m_PVRFilteringAtrousPositionSigmaDirect: 0.5 m_PVRFilteringAtrousPositionSigmaIndirect: 2 m_PVRFilteringAtrousPositionSigmaAO: 1 - m_ShowResolutionOverlay: 1 m_LightingDataAsset: {fileID: 0} m_UseShadowmask: 1 --- !u!196 &4 @@ -191,8 +190,8 @@ m_PrefabInternal: {fileID: 0} m_GameObject: {fileID: 516672264} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: -0.54, y: -0.23, z: 1.26} - m_LocalScale: {x: 0.7618044, y: 0.59613603, z: 1.8864031} + m_LocalPosition: {x: -0.5, y: 0.75, z: 1.05} + m_LocalScale: {x: 1, y: 1.5, z: 2.1} m_Children: [] m_Father: {fileID: 1646089004} m_RootOrder: 0 @@ -261,7 +260,6 @@ m_TargetEye: 3 m_HDR: 1 m_AllowMSAA: 1 - m_AllowDynamicResolution: 0 m_ForceIntoRT: 0 m_OcclusionCulling: 1 m_StereoConvergence: 10 @@ -341,7 +339,6 @@ m_TargetEye: 3 m_HDR: 1 m_AllowMSAA: 1 - m_AllowDynamicResolution: 0 m_ForceIntoRT: 0 m_OcclusionCulling: 1 m_StereoConvergence: 10 @@ -366,13 +363,13 @@ m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 0} m_GameObject: {fileID: 1211379094} - m_LocalRotation: {x: 0.20791169, y: 0, z: 0, w: 0.9781476} + m_LocalRotation: {x: 0.30070576, y: 0, z: 0, w: 0.953717} m_LocalPosition: {x: 0, y: 7.41, z: -10.48} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 24, y: 0, z: 0} + m_LocalEulerAnglesHint: {x: 35, y: 0, z: 0} --- !u!21 &1424158291 Material: serializedVersion: 6 @@ -439,6 +436,7 @@ - _Mode: 0 - _OcclusionStrength: 1 - _Parallax: 0.02 + - _PixelsPerUnit: 422 - _SmoothnessTextureChannel: 0 - _SpecularHighlights: 1 - _SrcBlend: 1 @@ -446,10 +444,10 @@ - _UVSec: 0 - _ZWrite: 1 m_Colors: - - _CenterPoint: {r: 0.5, g: 0.2493228, b: 0, a: 0} + - _CenterPoint: {r: 0.5, g: 0.49411634, b: 0, a: 0} - _Color: {r: 1, g: 1, b: 1, a: 1} - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} - - _TextureOffset: {r: 0, g: 0, b: 0, a: 0} + - _TextureOffset: {r: -219, g: -631, b: 0, a: 0} --- !u!1 &1493590970 GameObject: m_ObjectHideFlags: 0 @@ -532,7 +530,6 @@ m_Script: {fileID: 11500000, guid: bcdae60ce96b110429adb0dc2736286a, type: 3} m_Name: m_EditorClassIdentifier: - IsoCamera: {fileID: 1211379095} IsoMeshes: - {fileID: 516672265} --- !u!1 &1707129767 diff --git a/ProjectSettings/DynamicsManager.asset b/ProjectSettings/DynamicsManager.asset index 78992f0..0be3d78 100755 --- a/ProjectSettings/DynamicsManager.asset +++ b/ProjectSettings/DynamicsManager.asset @@ -3,7 +3,7 @@ --- !u!55 &1 PhysicsManager: m_ObjectHideFlags: 0 - serializedVersion: 7 + serializedVersion: 3 m_Gravity: {x: 0, y: -9.81, z: 0} m_DefaultMaterial: {fileID: 0} m_BounceThreshold: 2 @@ -14,16 +14,7 @@ m_QueriesHitBackfaces: 0 m_QueriesHitTriggers: 1 m_EnableAdaptiveForce: 0 - m_ClothInterCollisionDistance: 0 - m_ClothInterCollisionStiffness: 0 - m_ContactsGeneration: 1 + m_EnablePCM: 1 m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff m_AutoSimulation: 1 m_AutoSyncTransforms: 1 - m_ClothInterCollisionSettingsToggle: 0 - m_ContactPairsMode: 0 - m_BroadphaseType: 0 - m_WorldBounds: - m_Center: {x: 0, y: 0, z: 0} - m_Extent: {x: 250, y: 250, z: 250} - m_WorldSubdivisions: 8 diff --git a/Assets/Extensions.cs b/Assets/Extensions.cs new file mode 100644 index 0000000..26c3cab --- /dev/null +++ b/Assets/Extensions.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +public static class Extensions +{ + public static IEnumerable ToSingle(this T item) + { + yield return item; + } +} diff --git a/Assets/Extensions.cs.meta b/Assets/Extensions.cs.meta new file mode 100644 index 0000000..f034002 --- /dev/null +++ b/Assets/Extensions.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 538cc91c599e24c409d54b93fd3f450b +timeCreated: 1572760855 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/IsoEditor.cs b/Assets/IsoEditor.cs index 2cea357..0895cdb 100755 --- a/Assets/IsoEditor.cs +++ b/Assets/IsoEditor.cs @@ -17,9 +17,21 @@ EnableButtons(); } + private void OnDisable() + { + DisableButtons(); + } + // Update is called once per frame void Update () { + if (isoMode) + { + foreach (SceneView sv in SceneView.sceneViews) + { + sv.rotation = IsoCamera.transform.rotation; + } + } } private bool isoMode = false; @@ -41,6 +53,15 @@ SceneView.RepaintAll(); } + private struct SaveScene + { + public Vector3 P; + public Quaternion Q; + public bool O; + } + + private Dictionary saved = new Dictionary(); + public void OnSceneGUI(SceneView sceneView) { Handles.BeginGUI(); @@ -51,19 +72,35 @@ if (isoMode) { - lastCameraP = sceneView.pivot; - lastCameraQ = sceneView.rotation; - lastOrtho = sceneView.orthographic; - - sceneView.AlignViewToObject(IsoCamera.transform); - sceneView.orthographic = true; - + saved.Clear(); } - else + + foreach (SceneView sv in SceneView.sceneViews) { - sceneView.pivot = lastCameraP; - sceneView.rotation = lastCameraQ; - sceneView.orthographic = lastOrtho; + if (isoMode) + { + saved[sv] = new SaveScene + { + P = sv.pivot, + Q = sv.rotation, + O = sv.orthographic + }; + + sv.AlignViewToObject(IsoCamera.transform); + sv.orthographic = true; + sv.isRotationLocked = true; + + } + else + { + if (saved.ContainsKey(sv)) + { + sv.pivot = saved[sv].P; + sv.rotation = saved[sv].Q; + sv.orthographic = saved[sv].O; + } + sv.isRotationLocked = false; + } } } Handles.EndGUI(); diff --git a/Assets/IsoObject.cs b/Assets/IsoObject.cs index 86ecd64..9782b6f 100755 --- a/Assets/IsoObject.cs +++ b/Assets/IsoObject.cs @@ -1,8 +1,43 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Linq; +using UnityEditor; using UnityEngine; +[CustomEditor(typeof(IsoObject))] +public class IsoObjectEditor : Editor +{ + private int textureSelected = 0; + private List textures = new List(); + public override void OnInspectorGUI() + { + DrawDefaultInspector(); + + textures.Clear(); + if (target is IsoObject) + { + IsoObject isoObject = target as IsoObject; + foreach (MeshRenderer mr in isoObject.gameObject.GetComponentsInChildren()) + { + if (mr.sharedMaterial.shader.name == "Unlit/IsoShader") + { + textures.Add(mr.sharedMaterial.GetTexture("_MainTex")); + } + } + + textureSelected = EditorGUILayout.Popup(Math.Min(textures.Count, textureSelected), new GUIContent("Select Texture").ToSingle().Concat(textures.Select(t => new GUIContent(t.name))).ToArray()); + if (textureSelected != 0) + { + IsoTextureEditor editor = EditorWindow.GetWindow(); + editor.Init(textures[textureSelected - 1]); + editor.Show(); + textureSelected = 0; + } + } + } +} + [ExecuteInEditMode] public class IsoObject : MonoBehaviour { @@ -19,7 +54,7 @@ private void PreRender(Camera cam) { //Debug.Log(cam.GetInstanceID()); - if (cam.orthographic && isoEditor.IsoMode) + if (cam.orthographic && (isoEditor.IsoMode || cam == isoEditor.IsoCamera)) { Vector3 viewPos = cam.WorldToViewportPoint(gameObject.transform.position); foreach (MeshRenderer mr in IsoMeshes) diff --git a/Assets/IsoShader.shader b/Assets/IsoShader.shader index 73db29a..fa1b1cb 100755 --- a/Assets/IsoShader.shader +++ b/Assets/IsoShader.shader @@ -5,7 +5,7 @@ _MainTex ("Texture", 2D) = "white" {} _CenterPoint ("Object Center", Vector) = (0,0,0,0) _TextureOffset("Texture Offset", Vector) = (0,0,0,0) - _TextureScale("Texture Scale", Float) = 1 + _PixelsPerUnit("Pixels Per World Unit", Float) = 1 } SubShader { @@ -42,7 +42,7 @@ float4 _CenterPoint; float4 _TextureOffset; - float _TextureScale; + float _PixelsPerUnit; v2f vert (appdata v) { @@ -56,8 +56,25 @@ fixed4 frag (v2f i) : SV_Target { + // unity_OrthoParams.xy / 0.70710678 = Wu/Vp + // PixelsPerUnit = Px/Wu + // _MainTex_TexelSize.xy = Uv/Px + + // we want Uv from: + // (i.screenPos.xy - CenterPoint.xy) = Vp + // (i.screenPos.xy - CenterPoint.xy) * unity_OrthoParams.x * _PixelsPerUnit * _MainTex_TexelSize.xy = Uv + + float2 worldUnitScale = unity_OrthoParams.xy / 0.70710678; + float2 offset = float2(i.screenPos.x - _CenterPoint.x, _CenterPoint.y - i.screenPos.y); + float2 uvs = float2((offset.x * worldUnitScale.x * _PixelsPerUnit - _TextureOffset.x) * _MainTex_TexelSize.x, + 1 - (offset.y * worldUnitScale.y * _PixelsPerUnit - _TextureOffset.y) * _MainTex_TexelSize.y); + // sample the texture - fixed4 col = tex2D(_MainTex, (i.screenPos.xy - _CenterPoint.xy - _TextureOffset.xy * _MainTex_TexelSize.xy) / _TextureScale); + fixed4 col = tex2D(_MainTex, uvs); + + clip(col.a - 0.5); + //fixed4 col = fixed4(uvs.x, 0, 0, 1); + //fixed4 col = fixed4(uvs.xy, 0, 1); // apply fog //UNITY_APPLY_FOG(i.fogCoord, col); diff --git a/Assets/IsoTextureEditor.cs b/Assets/IsoTextureEditor.cs new file mode 100644 index 0000000..a5f5037 --- /dev/null +++ b/Assets/IsoTextureEditor.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEditor; +using UnityEngine; + +public class IsoTextureEditor : EditorWindow +{ + private Camera cam; + private Texture texture; + private RenderTexture handleTex; + private void Awake() + { + cam = EditorUtility.CreateGameObjectWithHideFlags("testCam", HideFlags.HideAndDontSave, typeof(Camera)).GetComponent(); + cam.clearFlags = CameraClearFlags.SolidColor; + cam.backgroundColor = new Color(0, 0, 0, 0); + cam.cullingMask = 0; + cam.orthographic = true; + } + private void OnDestroy() + { + DestroyImmediate(cam); + } + public void Init(Texture texture) + { + this.texture = texture; + titleContent = new GUIContent(texture.name + ": Iso Boxes"); + minSize = new Vector2(texture.width, texture.height + 30); + + handleTex = new RenderTexture(texture.width, texture.height, 0); + cam.targetTexture = handleTex; + + cam.orthographicSize = texture.height * 0.5f; + cam.transform.position = new Vector3(texture.width * 0.5f, texture.height * 0.5f, 0); + cam.transform.rotation = Quaternion.identity; + } + private void OnGUI() + { + if (texture != null) + { + GUI.DrawTexture(new Rect(0, 0, texture.width, texture.height), texture); + if (GUI.Button(new Rect(5, texture.height + 5, 80, 25), "Save")) + { + + } + + Handles.SetCamera(cam); + Handles.PositionHandle(new Vector3(), Quaternion.identity); + Handles.DrawCamera(new Rect(0, 0, texture.width, texture.height), cam); + } + } +} \ No newline at end of file diff --git a/Assets/IsoTextureEditor.cs.meta b/Assets/IsoTextureEditor.cs.meta new file mode 100644 index 0000000..d89c534 --- /dev/null +++ b/Assets/IsoTextureEditor.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: c740ebdf5f67c96448e4b8878a4eb94c +timeCreated: 1572759990 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Textures/House_FallingLeaves.png b/Assets/Textures/House_FallingLeaves.png index 7c42a99..4bf6fed 100644 --- a/Assets/Textures/House_FallingLeaves.png +++ b/Assets/Textures/House_FallingLeaves.png Binary files differ diff --git a/Assets/Textures/House_FallingLeaves.png.meta b/Assets/Textures/House_FallingLeaves.png.meta index f454001..fda83d9 100755 --- a/Assets/Textures/House_FallingLeaves.png.meta +++ b/Assets/Textures/House_FallingLeaves.png.meta @@ -35,7 +35,7 @@ wrapU: 1 wrapV: 1 wrapW: 1 - nPOTScale: 1 + nPOTScale: 0 lightmap: 0 compressionQuality: 50 spriteMode: 0 @@ -43,9 +43,8 @@ spriteMeshType: 1 alignment: 0 spritePivot: {x: 0.5, y: 0.5} - spritePixelsToUnits: 100 spriteBorder: {x: 0, y: 0, z: 0, w: 0} - spriteGenerateFallbackPhysicsShape: 1 + spritePixelsToUnits: 100 alphaUsage: 1 alphaIsTransparency: 0 spriteTessellationDetail: -1 @@ -64,7 +63,6 @@ crunchedCompression: 0 allowsAlphaSplitting: 0 overridden: 0 - androidETC2FallbackOverride: 0 - buildTarget: Standalone maxTextureSize: 2048 resizeAlgorithm: 0 @@ -74,7 +72,6 @@ crunchedCompression: 0 allowsAlphaSplitting: 0 overridden: 0 - androidETC2FallbackOverride: 0 - buildTarget: Android maxTextureSize: 2048 resizeAlgorithm: 0 @@ -84,7 +81,6 @@ crunchedCompression: 0 allowsAlphaSplitting: 0 overridden: 0 - androidETC2FallbackOverride: 0 - buildTarget: WebGL maxTextureSize: 2048 resizeAlgorithm: 0 @@ -94,7 +90,6 @@ crunchedCompression: 0 allowsAlphaSplitting: 0 overridden: 0 - androidETC2FallbackOverride: 0 spriteSheet: serializedVersion: 2 sprites: [] diff --git a/Assets/main.unity b/Assets/main.unity index a1f1390..61315eb 100755 --- a/Assets/main.unity +++ b/Assets/main.unity @@ -88,7 +88,6 @@ m_PVRFilteringAtrousPositionSigmaDirect: 0.5 m_PVRFilteringAtrousPositionSigmaIndirect: 2 m_PVRFilteringAtrousPositionSigmaAO: 1 - m_ShowResolutionOverlay: 1 m_LightingDataAsset: {fileID: 0} m_UseShadowmask: 1 --- !u!196 &4 @@ -191,8 +190,8 @@ m_PrefabInternal: {fileID: 0} m_GameObject: {fileID: 516672264} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: -0.54, y: -0.23, z: 1.26} - m_LocalScale: {x: 0.7618044, y: 0.59613603, z: 1.8864031} + m_LocalPosition: {x: -0.5, y: 0.75, z: 1.05} + m_LocalScale: {x: 1, y: 1.5, z: 2.1} m_Children: [] m_Father: {fileID: 1646089004} m_RootOrder: 0 @@ -261,7 +260,6 @@ m_TargetEye: 3 m_HDR: 1 m_AllowMSAA: 1 - m_AllowDynamicResolution: 0 m_ForceIntoRT: 0 m_OcclusionCulling: 1 m_StereoConvergence: 10 @@ -341,7 +339,6 @@ m_TargetEye: 3 m_HDR: 1 m_AllowMSAA: 1 - m_AllowDynamicResolution: 0 m_ForceIntoRT: 0 m_OcclusionCulling: 1 m_StereoConvergence: 10 @@ -366,13 +363,13 @@ m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 0} m_GameObject: {fileID: 1211379094} - m_LocalRotation: {x: 0.20791169, y: 0, z: 0, w: 0.9781476} + m_LocalRotation: {x: 0.30070576, y: 0, z: 0, w: 0.953717} m_LocalPosition: {x: 0, y: 7.41, z: -10.48} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 24, y: 0, z: 0} + m_LocalEulerAnglesHint: {x: 35, y: 0, z: 0} --- !u!21 &1424158291 Material: serializedVersion: 6 @@ -439,6 +436,7 @@ - _Mode: 0 - _OcclusionStrength: 1 - _Parallax: 0.02 + - _PixelsPerUnit: 422 - _SmoothnessTextureChannel: 0 - _SpecularHighlights: 1 - _SrcBlend: 1 @@ -446,10 +444,10 @@ - _UVSec: 0 - _ZWrite: 1 m_Colors: - - _CenterPoint: {r: 0.5, g: 0.2493228, b: 0, a: 0} + - _CenterPoint: {r: 0.5, g: 0.49411634, b: 0, a: 0} - _Color: {r: 1, g: 1, b: 1, a: 1} - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} - - _TextureOffset: {r: 0, g: 0, b: 0, a: 0} + - _TextureOffset: {r: -219, g: -631, b: 0, a: 0} --- !u!1 &1493590970 GameObject: m_ObjectHideFlags: 0 @@ -532,7 +530,6 @@ m_Script: {fileID: 11500000, guid: bcdae60ce96b110429adb0dc2736286a, type: 3} m_Name: m_EditorClassIdentifier: - IsoCamera: {fileID: 1211379095} IsoMeshes: - {fileID: 516672265} --- !u!1 &1707129767 diff --git a/ProjectSettings/DynamicsManager.asset b/ProjectSettings/DynamicsManager.asset index 78992f0..0be3d78 100755 --- a/ProjectSettings/DynamicsManager.asset +++ b/ProjectSettings/DynamicsManager.asset @@ -3,7 +3,7 @@ --- !u!55 &1 PhysicsManager: m_ObjectHideFlags: 0 - serializedVersion: 7 + serializedVersion: 3 m_Gravity: {x: 0, y: -9.81, z: 0} m_DefaultMaterial: {fileID: 0} m_BounceThreshold: 2 @@ -14,16 +14,7 @@ m_QueriesHitBackfaces: 0 m_QueriesHitTriggers: 1 m_EnableAdaptiveForce: 0 - m_ClothInterCollisionDistance: 0 - m_ClothInterCollisionStiffness: 0 - m_ContactsGeneration: 1 + m_EnablePCM: 1 m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff m_AutoSimulation: 1 m_AutoSyncTransforms: 1 - m_ClothInterCollisionSettingsToggle: 0 - m_ContactPairsMode: 0 - m_BroadphaseType: 0 - m_WorldBounds: - m_Center: {x: 0, y: 0, z: 0} - m_Extent: {x: 250, y: 250, z: 250} - m_WorldSubdivisions: 8 diff --git a/ProjectSettings/ProjectVersion.txt b/ProjectSettings/ProjectVersion.txt index 7d258c8..7a6fffb 100755 --- a/ProjectSettings/ProjectVersion.txt +++ b/ProjectSettings/ProjectVersion.txt @@ -1 +1 @@ -m_EditorVersion: 2017.4.31f1 +m_EditorVersion: 2017.2.0f3