private void RebuildRenderTexture(UMAData data) { var rt = data.GetFirstRenderTexture(); if (rt != null && !rt.IsCreated()) { if (NoCoroutines) { UMAGeneratorPro ugp = new UMAGeneratorPro(); ugp.ProcessTexture(this, umaData, true, InitialScaleFactor); TextureChanged++; } else { umaData = data; TextureProcessBaseCoroutine textureProcessCoroutine; textureProcessCoroutine = new TextureProcessPROCoroutine(); textureProcessCoroutine.Prepare(data, this); activeGeneratorCoroutine = new UMAGeneratorCoroutine(); activeGeneratorCoroutine.Prepare(this, umaData, textureProcessCoroutine, true, InitialScaleFactor); while (!activeGeneratorCoroutine.Work()) { ; } activeGeneratorCoroutine = null; } TextureChanged++; } }
public void ProcessCurrentOverlays(bool retry = true) { if (baseOverlayProperty == null) { return; } if (BaseOverlay == null || (BaseOverlay.asset.GetInstanceID() != (baseOverlayProperty.objectReferenceValue as OverlayDataAsset).GetInstanceID())) { OverlayDataAsset overlayDataAsset = baseOverlayProperty.objectReferenceValue as OverlayDataAsset; BaseOverlay = new OverlayData(overlayDataAsset); } OverlayViewer viewerobj = serializedObject.targetObject as OverlayViewer; List <OverlayData> od = new List <OverlayData>(); od.Add(BaseOverlay); foreach (OverlayDataAsset o in viewerobj.Overlays) { if (o != null) { if (!AdditionalOverlays.ContainsKey(o.GetInstanceID())) { AdditionalOverlays.Add(o.GetInstanceID(), new OverlayData(o)); } od.Add(AdditionalOverlays[o.GetInstanceID()]); } } TempSlot.asset.material = od[0].asset.material; TempSlot.SetOverlayList(od); SlotData[] slot = new SlotData[1]; slot[0] = TempSlot; TempUMAData.SetSlots(slot); TextureProcessBaseCoroutine textureProcessCoroutine; textureProcessCoroutine = new TextureProcessPROCoroutine(); textureProcessCoroutine.Prepare(TempUMAData, TempUMAData.umaGenerator); activeGeneratorCoroutine.Prepare(TempUMAData.umaGenerator, TempUMAData, textureProcessCoroutine, false, 1); try { bool workDone = activeGeneratorCoroutine.Work(); //Debug.Log("Workdone is " + workDone); rawImage.material = TempUMAData.generatedMaterials.materials[0].material; } catch (Exception ex) { Debug.Log("Something has gone wrong. Reinitializing. Text of error was: " + ex.Message); if (retry) { Initialize(false); } } }
public virtual bool HandleDirtyUpdate(UMAData data) { umaData = data; if (umaData.isMeshDirty) { if (!umaData.isTextureDirty) { UpdateUMAMesh(false); } umaData.isMeshDirty = false; } if (umaData.isTextureDirty) { if( activeGeneratorCoroutine == null ) { activeGeneratorCoroutine = umaGeneratorCoroutine; TextureProcessBaseCoroutine textureProcessCoroutine; if (usePRO) { textureProcessCoroutine = new TextureProcessPROCoroutine(); textureProcessCoroutine.Prepare(data, this); } else { textureProcessCoroutine = new TextureProcessIndieCoroutine(); } activeGeneratorCoroutine.Prepare(this, umaData, textureProcessCoroutine); } if (umaGeneratorCoroutine.Work()) { activeGeneratorCoroutine = null; UpdateUMAMesh(true); umaData.isTextureDirty = false; } else { return false; } } else if (umaData.isShapeDirty) { UpdateUMABody(umaData); umaData.isShapeDirty = false; UMAReady(); return true; } else { UMAReady(); return true; } return false; }
protected override void Start() { backUpTexture = umaGenerator.umaData.backUpTextures(); umaGenerator.umaData.cleanTextures(); materialDefinitionList = new List<UMAData.MaterialDefinition>(); //Update atlas area can be handled here UMAData.MaterialDefinition tempMaterialDefinition = new UMAData.MaterialDefinition(); SlotData[] slots = umaGenerator.umaData.umaRecipe.slotDataList; for(int i = 0; i < slots.Length; i++){ if(slots[i] != null){ tempMaterialDefinition = new UMAData.MaterialDefinition(); tempMaterialDefinition.baseTexture = slots[i].GetOverlay(0).textureList; tempMaterialDefinition.baseColor = slots[i].GetOverlay(0).color; tempMaterialDefinition.materialSample = slots[i].materialSample; tempMaterialDefinition.overlays = new UMAData.textureData[slots[i].OverlayCount -1]; tempMaterialDefinition.overlayColors = new Color32[tempMaterialDefinition.overlays.Length]; tempMaterialDefinition.rects = new Rect[tempMaterialDefinition.overlays.Length]; tempMaterialDefinition.channelMask = new Color32[tempMaterialDefinition.overlays.Length+1][]; tempMaterialDefinition.channelAdditiveMask = new Color32[tempMaterialDefinition.overlays.Length+1][]; tempMaterialDefinition.channelMask[0] = slots[i].GetOverlay(0).channelMask; tempMaterialDefinition.channelAdditiveMask[0] = slots[i].GetOverlay(0).channelAdditiveMask; tempMaterialDefinition.slotData = slots[i]; for(int overlayID = 0; overlayID < slots[i].OverlayCount-1; overlayID++){ tempMaterialDefinition.overlays[overlayID] = new UMAData.textureData(); tempMaterialDefinition.rects[overlayID] = slots[i].GetOverlay(overlayID+1).rect; tempMaterialDefinition.overlays[overlayID].textureList = slots[i].GetOverlay(overlayID+1).textureList; tempMaterialDefinition.overlayColors[overlayID] = slots[i].GetOverlay(overlayID+1).color; tempMaterialDefinition.channelMask[overlayID+1] = slots[i].GetOverlay(overlayID + 1).channelMask; tempMaterialDefinition.channelAdditiveMask[overlayID+1] = slots[i].GetOverlay(overlayID + 1).channelAdditiveMask; } materialDefinitionList.Add(tempMaterialDefinition); } } if(umaGenerator.usePRO){ textureProcessPROCoroutine = new TextureProcessPROCoroutine(); }else{ textureProcessIndieCoroutine = new TextureProcessIndieCoroutine(); } packTexture = new MaxRectsBinPack(umaGenerator.atlasResolution,umaGenerator.atlasResolution,false); }
public virtual bool HandleDirtyUpdate(UMAData data) { if (data == null) { return(true); } if (umaData != data) { umaData = data; if (!umaData.Validate()) { return(true); } if (meshCombiner != null) { meshCombiner.Preprocess(umaData); } umaData.FireCharacterBegunEvents(); } if (umaData.isTextureDirty) { if (activeGeneratorCoroutine == null) { TextureProcessBaseCoroutine textureProcessCoroutine; textureProcessCoroutine = new TextureProcessPROCoroutine(); textureProcessCoroutine.Prepare(data, this); activeGeneratorCoroutine = new UMAGeneratorCoroutine(); activeGeneratorCoroutine.Prepare(this, umaData, textureProcessCoroutine, !umaData.isMeshDirty); } bool workDone = activeGeneratorCoroutine.Work(); if (workDone) { activeGeneratorCoroutine = null; umaData.isTextureDirty = false; umaData.isAtlasDirty = true; } if (!workDone || !fastGeneration || umaData.isMeshDirty) { return(false); } } if (umaData.isMeshDirty) { UpdateUMAMesh(umaData.isAtlasDirty); umaData.isAtlasDirty = false; umaData.isMeshDirty = false; if (!fastGeneration) { return(false); } } if (umaData.isShapeDirty) { UpdateUMABody(umaData); umaData.isShapeDirty = false; } UMAReady(); return(true); }
public virtual bool HandleDirtyUpdate(UMAData data) { if (data == null) return true; if (umaData != data) { umaData = data; if (!umaData.Validate()) return true; if (meshCombiner != null) { meshCombiner.Preprocess(umaData); } umaData.FireCharacterBegunEvents(); } if (umaData.isTextureDirty) { if (activeGeneratorCoroutine == null) { activeGeneratorCoroutine = umaGeneratorCoroutine; TextureProcessBaseCoroutine textureProcessCoroutine; textureProcessCoroutine = new TextureProcessPROCoroutine(); textureProcessCoroutine.Prepare(data, this); activeGeneratorCoroutine.Prepare(this, umaData, textureProcessCoroutine, !umaData.isMeshDirty); } bool workDone = umaGeneratorCoroutine.Work(); if (workDone) { activeGeneratorCoroutine = null; umaData.isTextureDirty = false; umaData.isAtlasDirty = true; } if (!workDone || !fastGeneration || umaData.isMeshDirty) return false; } if (umaData.isMeshDirty) { UpdateUMAMesh(umaData.isAtlasDirty); umaData.isAtlasDirty = false; umaData.isMeshDirty = false; if (!fastGeneration) return false; } if (umaData.isShapeDirty) { UpdateUMABody(umaData); umaData.isShapeDirty = false; } UMAReady(); return true; }
public virtual bool HandleDirtyUpdate(UMAData data) { if (umaData != data) { umaData = data; if (!umaData.Validate()) { return(true); } } if (umaData.isMeshDirty) { if (!umaData.isTextureDirty) { UpdateUMAMesh(false); } umaData.isMeshDirty = false; } if (umaData.isTextureDirty) { if (activeGeneratorCoroutine == null) { activeGeneratorCoroutine = umaGeneratorCoroutine; TextureProcessBaseCoroutine textureProcessCoroutine; if (usePRO) { textureProcessCoroutine = new TextureProcessPROCoroutine(); textureProcessCoroutine.Prepare(data, this); } else { textureProcessCoroutine = new TextureProcessIndieCoroutine(); } activeGeneratorCoroutine.Prepare(this, umaData, textureProcessCoroutine); } if (umaGeneratorCoroutine.Work()) { activeGeneratorCoroutine = null; UpdateUMAMesh(true); umaData.isTextureDirty = false; } else { return(false); } } else if (umaData.isShapeDirty) { UpdateUMABody(umaData); umaData.isShapeDirty = false; UMAReady(); return(true); } else { UMAReady(); return(true); } return(false); }
public virtual bool HandleDirtyUpdate(UMAData data) { if (data == null) { return(true); } if (umaData != data) { umaData = data; if (!umaData.Validate()) { return(true); } if (meshCombiner != null) { meshCombiner.Preprocess(umaData); } umaData.FireCharacterBegunEvents(); } PreApply(umaData); if (umaData.isTextureDirty) { bool meshWasDirty = umaData.isMeshDirty; if (activeGeneratorCoroutine == null) { TextureProcessBaseCoroutine textureProcessCoroutine; textureProcessCoroutine = new TextureProcessPROCoroutine(); textureProcessCoroutine.Prepare(data, this); activeGeneratorCoroutine = new UMAGeneratorCoroutine(); activeGeneratorCoroutine.Prepare(this, umaData, textureProcessCoroutine, !umaData.isMeshDirty, InitialScaleFactor); } bool workDone = activeGeneratorCoroutine.Work(); if (workDone) { activeGeneratorCoroutine = null; umaData.isTextureDirty = false; umaData.isAtlasDirty |= umaData.isMeshDirty; TextureChanged++; } //shouldn't this only cause another loop if this part MADE the mesh dirty? if (!workDone || !fastGeneration || (!meshWasDirty && umaData.isMeshDirty)) { //Debug.Log("workDone = " + workDone + " fastGeneration = " + fastGeneration + " umaData.isMeshDirty = " + umaData.isMeshDirty); return(false); } } if (umaData.isMeshDirty) { UpdateUMAMesh(umaData.isAtlasDirty); umaData.isAtlasDirty = false; umaData.isMeshDirty = false; SlotsChanged++; forceGarbageCollect++; if (!fastGeneration) { return(false); } } if (umaData.isShapeDirty) { if (!umaData.skeleton.isUpdating) { umaData.skeleton.BeginSkeletonUpdate(); } UpdateUMABody(umaData); umaData.isShapeDirty = false; DnaChanged++; } else if (umaData.skeleton.isUpdating) { umaData.skeleton.EndSkeletonUpdate(); } UMAReady(); return(true); }
public virtual bool HandleDirtyUpdate(UMAData data) { if (data == null) { return(true); } if (umaData != data) { umaData = data; if (!umaData.Validate()) { return(true); } if (meshCombiner != null) { meshCombiner.Preprocess(umaData); } umaData.FireCharacterBegunEvents(); } if (umaData.isTextureDirty) { if (activeGeneratorCoroutine == null) { TextureProcessBaseCoroutine textureProcessCoroutine; textureProcessCoroutine = new TextureProcessPROCoroutine(); textureProcessCoroutine.Prepare(data, this); activeGeneratorCoroutine = new UMAGeneratorCoroutine(); activeGeneratorCoroutine.Prepare(this, umaData, textureProcessCoroutine, !umaData.isMeshDirty, InitialScaleFactor); } bool workDone = activeGeneratorCoroutine.Work(); if (workDone) { activeGeneratorCoroutine = null; umaData.isTextureDirty = false; umaData.isAtlasDirty |= umaData.isMeshDirty; TextureChanged++; } if (!workDone || !fastGeneration || umaData.isMeshDirty) { return(false); } } if (umaData.isMeshDirty) { UpdateUMAMesh(umaData.isAtlasDirty); umaData.isAtlasDirty = false; umaData.isMeshDirty = false; SlotsChanged++; forceGarbageCollect++; if (!fastGeneration) { return(false); } } if (umaData.isShapeDirty) { if (!umaData.skeleton.isUpdating) { umaData.skeleton.BeginSkeletonUpdate(); } UpdateUMABody(umaData); umaData.isShapeDirty = false; DnaChanged++; } else if (umaData.skeleton.isUpdating) { umaData.skeleton.EndSkeletonUpdate(); } UMAReady(); return(true); }