// Save Mesh resources private void BreakResourcesConnection() { // Replace the prefab default material by a copy of the source instance (this sprite from wich the prefab has just been create) if the material is not persistent Material rGeneratedMaterialInstance = SpriteData.generatedMaterial; if (rGeneratedMaterialInstance != null) { Uni2DSprite rSpritePrefab = PrefabUtility.GetPrefabParent(this) as Uni2DSprite; Material rPrefabMaterial = rSpritePrefab.SpriteData.generatedMaterial; // If prefab material isn't created yet wait for it if (rPrefabMaterial == null) { return; } rPrefabMaterial.shader = rGeneratedMaterialInstance.shader; rPrefabMaterial.CopyPropertiesFromMaterial(rGeneratedMaterialInstance); } //Debug.Log("Break Resources"); Uni2DEditorResourceCopyUtils.DuplicateResources(this, true); PrefabUtility.DisconnectPrefabInstance(gameObject); }
// Awake private void Awake() { #if UNITY_EDITOR if (Application.isPlaying) #endif { m_rCurrentFrameAtlas = m_rSpriteSettings.atlas; m_rCurrentFrameTextureContainer = m_rSpriteSettings.textureContainer; m_iCurrentFrameTextureWidth = (int)m_rSpriteData.spriteWidth; m_iCurrentFrameTextureHeight = (int)m_rSpriteData.spriteHeight; spriteAnimation.Start(this); } #if UNITY_EDITOR // Is a prefab instance else if (IsADuplicate( )) { //Debug.Log("Duplicate"); Uni2DEditorResourceCopyUtils.DuplicateResources(this); } #endif // Create the duplicata marker if needed if (m_oDuplicataMarker == null || m_oDuplicataMarker.IsADuplicate(this)) { m_oDuplicataMarker = ScriptableObject.CreateInstance <DuplicataMarker>(); m_oDuplicataMarker.Create(this); } }