// MonoBehaviour callbacks. /** * @brief Constructor. * */ protected virtual void Awake() { renderer = (MeshRenderer)base.GetComponent <Renderer>(); renderer.hideFlags = HideFlags.HideInInspector | HideFlags.NotEditable; renderer.shadowCastingMode = ShadowCastingMode.Off; renderer.receiveShadows = false; renderer.useLightProbes = false; renderer.enabled = false; meshFilter = GetComponent <MeshFilter>(); meshFilter.hideFlags = HideFlags.HideInInspector | HideFlags.NotEditable; vertices = new Vector3[] {}; uv = new Vector2[] {}; uv2 = new Vector2[] {}; colors = new Color32[] {}; if ((meshFilter.sharedMesh == null) || !RegisterMesh(meshFilter.sharedMesh)) { mesh = new Mesh(); mesh.name = "Tile Grid"; meshFilter.mesh = mesh; regenerateMesh = true; RegisterMesh(mesh); } else { mesh = meshFilter.sharedMesh; } flippedHorizontally = m_flipHorizontal; flippedVertically = m_flipVertical; AddTexRef(m_sprite, this); #if UNITY_EDITOR if (!regenerateMesh && !Application.isPlaying) { // The tile texture may have been changed while this object has been inactive or even // not loaded at all. So we need to check the timestamp and update UV if needed. long timestamp = 0; int currentTsHigh = 0, currentTsLow = 0; if ((m_sprite != null) && (m_sprite.texture != null)) { timestamp = AssetMetaCache.GetTimestamp(m_sprite.texture); currentTsHigh = (int)(timestamp >> 32); currentTsLow = (int)(timestamp & 0xFFFFFFFF); } if ((currentTsLow != timestampLow) || (currentTsHigh != timestampHigh)) { regenerateMesh = true; timestampLow = currentTsLow; timestampHigh = currentTsHigh; } } #endif initialised = true; }
void UpdateTexTimestamp() { #if UNITY_EDITOR if ((m_sprite != null) && (m_sprite.texture != null)) { long texTimestamp = AssetMetaCache.GetTimestamp(m_sprite.texture); timestampHigh = (int)(texTimestamp >> 32); timestampLow = (int)(texTimestamp & 0xFFFFFFFF); } else { timestampHigh = 0; timestampLow = 0; } #endif }
void OnPostprocessTexture(Texture2D _tex) { AssetMetaCache.UpdateMetaInfo(assetImporter.assetPath); }