using System.Collections; using System.Collections.Generic; using UnityEngine; public class IsoItem : MonoBehaviour { public Vector3 CameraSpace; public float SetDepth; internal HashSet<IsoItem> Behind = new HashSet<IsoItem>(); public GameObject LinkedImage; public Vector3 lastPos = new Vector3(); public float IsoRadius = 0; public bool IsoPerspective = false; internal bool MarkTemp = false; internal bool MarkPerm = false; public bool AllowMovedFlag = false; public enum IsoTypes { Sprite, Object } public IsoTypes IsoType; void Start() { IsoHandler iso = GameObject.FindObjectOfType<IsoHandler>(); iso.AddIsoItem(this); if (IsoPerspective) { GameObject world = GameObject.Find("IsoWorld"); LinkedImage.transform.parent = world.transform; LinkedImage.transform.localRotation = Quaternion.identity; } if (IsoType == IsoTypes.Sprite && IsoRadius == 0) { MeshFilter mf = LinkedImage.GetComponent<MeshFilter>(); if (mf != null) { mf.sharedMesh.RecalculateBounds(); float maxX = Mathf.Abs(mf.sharedMesh.bounds.center.x) + Mathf.Abs(mf.sharedMesh.bounds.extents.x); float maxY = Mathf.Abs(mf.sharedMesh.bounds.center.y) + Mathf.Abs(mf.sharedMesh.bounds.extents.y); float maxZ = Mathf.Abs(mf.sharedMesh.bounds.center.z) + Mathf.Abs(mf.sharedMesh.bounds.extents.z); IsoRadius = Mathf.Max(maxX, Mathf.Max(maxY, maxZ)); } } } void Destroy() { IsoHandler iso = GameObject.FindObjectOfType<IsoHandler>(); iso.RemoveIsoItem(this); } // Update is called once per frame void Update () { } }