Пример #1
0
        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++;
            }
        }
Пример #2
0
        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);
                }
            }
        }
Пример #3
0
        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;
        }
        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);
        }
Пример #5
0
        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;
        }
Пример #6
0
        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);
        }
Пример #7
0
        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);
        }
Пример #8
0
        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);
        }