Beispiel #1
0
 public PackedOverlayColorDataV2(OverlayColorData colorData)
 {
     name     = colorData.name;
     color    = new byte[4];
     color[0] = (byte)Mathf.FloorToInt(colorData.color.r * 255f);
     color[1] = (byte)Mathf.FloorToInt(colorData.color.g * 255f);
     color[2] = (byte)Mathf.FloorToInt(colorData.color.b * 255f);
     color[3] = (byte)Mathf.FloorToInt(colorData.color.a * 255f);
     if (UMAPackRecipe.ArrayHasData(colorData.channelMask))
     {
         int channelCount = colorData.channelMask.Length;
         masks    = new byte[channelCount][];
         addMasks = new byte[channelCount][];
         for (int channel = 0; channel < channelCount; channel++)
         {
             masks[channel]    = new byte[4];
             addMasks[channel] = new byte[4];
             Color32 maskColor = colorData.channelMask[channel];
             masks[channel][0] = maskColor.r;
             masks[channel][1] = maskColor.g;
             masks[channel][2] = maskColor.b;
             masks[channel][3] = maskColor.a;
             Color32 additiveMaskColor = colorData.channelAdditiveMask[channel];
             addMasks[channel][0] = additiveMaskColor.r;
             addMasks[channel][1] = additiveMaskColor.g;
             addMasks[channel][2] = additiveMaskColor.b;
             addMasks[channel][3] = additiveMaskColor.a;
         }
     }
 }
Beispiel #2
0
 public void SetOverlayColorData(OverlayColorData overlayColorData)
 {
     overlayColorData.name = name;
     if (UMAPackRecipe.ArrayHasData(masks))
     {
         int channelCount = masks.Length;
         overlayColorData.channelMask         = new Color[channelCount];
         overlayColorData.channelAdditiveMask = new Color[channelCount];
         for (int channel = 0; channel < channelCount; channel++)
         {
             overlayColorData.channelMask[channel].r         = masks[channel][0] / 255f;
             overlayColorData.channelMask[channel].g         = masks[channel][1] / 255f;
             overlayColorData.channelMask[channel].b         = masks[channel][2] / 255f;
             overlayColorData.channelMask[channel].a         = masks[channel][3] / 255f;
             overlayColorData.channelAdditiveMask[channel].r = addMasks[channel][0];
             overlayColorData.channelAdditiveMask[channel].g = addMasks[channel][1];
             overlayColorData.channelAdditiveMask[channel].b = addMasks[channel][2];
             overlayColorData.channelAdditiveMask[channel].a = addMasks[channel][3];
         }
     }
     else
     {
         overlayColorData.channelMask         = new Color[1];
         overlayColorData.channelAdditiveMask = new Color[1];
         overlayColorData.channelMask[0]      = new Color(color[0] / 255f, color[1] / 255f, color[2] / 255f, color[3] / 255f);
     }
 }
Beispiel #3
0
        /// <summary>
        /// Constructor for overlay using the given asset.
        /// </summary>
        /// <param name="asset">Asset.</param>
        public OverlayData(OverlayDataAsset asset)
        {
            if (asset == null)
            {
                Debug.LogError("Overlay Data Asset is NULL!");
                return;
            }
            if (asset.material == null)
            {
                Debug.LogError("Error: Materials are missing on Asset: " + asset.name + ". Have you imported all packages?");
                this.colorData = new OverlayColorData(3);                 // Don't know. Just create it for standard PBR material size.
            }
            else
            {
                this.colorData = new OverlayColorData(asset.material.channels.Length);
            }
            this.asset = asset;
            this.rect  = asset.rect;

            #if UNITY_STANDALONE || UNITY_IOS || UNITY_ANDROID || UNITY_PS4 || UNITY_XBOXONE //supported platforms for procedural materials
            if (this.isProcedural)
            {
                this.proceduralData = new OverlayProceduralData[0];
            }
            #endif
        }
Beispiel #4
0
 public void Validate()
 {
     if (asset == null)
     {
         return;
     }
     if (isEmpty)
     {
         return;
     }
     if (asset.material == null)
     {
         asset.material = UMAAssetIndexer.Instance.GetAsset <UMAMaterial>(asset.materialName);
         if (asset.material == null)
         {
             this.colorData = new OverlayColorData(3);                     // Don't know. Just create it for standard PBR material size.
         }
         else
         {
             this.colorData = new OverlayColorData(asset.material.channels.Length);
         }
     }
     else
     {
         if (!colorData)
         {
             this.colorData = new OverlayColorData(asset.material.channels.Length);
         }
     }
 }
Beispiel #5
0
 private void AddRandomSlot(DynamicCharacterAvatar Avatar, RandomWardrobeSlot uwr)
 {
     Avatar.SetSlot(uwr.WardrobeSlot);
     if (uwr.Colors != null)
     {
         foreach (RandomColors rc in uwr.Colors)
         {
             if (rc.ColorTable != null)
             {
                 OverlayColorData ocd = GetRandomColor(rc);
                 Avatar.SetColor(rc.ColorName, ocd, false);
             }
         }
     }
 }
Beispiel #6
0
 /// <summary>
 /// Constructor for overlay using the given asset.
 /// </summary>
 /// <param name="asset">Asset.</param>
 public OverlayData(OverlayDataAsset asset)
 {
     if (asset == null)
     {
         Debug.LogError("Overlay Data Asset is NULL!");
         return;
     }
     if (asset.material == null)
     {
         Debug.LogError("Error: Materials are missing on Asset: " + asset.name + ". Have you imported all packages?");
         this.colorData = new OverlayColorData(3);                 // ?? Don't know. Just create it for standard PBR material size.
     }
     else
     {
         this.colorData = new OverlayColorData(asset.material.channels.Length);
     }
     this.asset = asset;
     this.rect  = asset.rect;
 }
Beispiel #7
0
 public void SetOverlayColorData(OverlayColorData overlayColorData)
 {
     overlayColorData.name = name;
     if (UMAPackRecipe.ArrayHasData(colors))
     {
         int channelCount = colors.Length / 8;
         overlayColorData.channelMask         = new Color[channelCount];
         overlayColorData.channelAdditiveMask = new Color[channelCount];
         int colorIndex = 0;
         for (int channel = 0; channel < channelCount; channel++)
         {
             overlayColorData.channelMask[channel].r         = colors[colorIndex++] / 255f;
             overlayColorData.channelMask[channel].g         = colors[colorIndex++] / 255f;
             overlayColorData.channelMask[channel].b         = colors[colorIndex++] / 255f;
             overlayColorData.channelMask[channel].a         = colors[colorIndex++] / 255f;
             overlayColorData.channelAdditiveMask[channel].r = colors[colorIndex++] / 255f;
             overlayColorData.channelAdditiveMask[channel].g = colors[colorIndex++] / 255f;
             overlayColorData.channelAdditiveMask[channel].b = colors[colorIndex++] / 255f;
             overlayColorData.channelAdditiveMask[channel].a = colors[colorIndex++] / 255f;
         }
     }
 }
Beispiel #8
0
 public PackedOverlayColorDataV3(OverlayColorData colorData)
 {
     name = colorData.name;
     if (UMAPackRecipe.ArrayHasData(colorData.channelMask))
     {
         int channelCount = colorData.channelMask.Length;
         colors = new short[channelCount * 8];
         int colorIndex = 0;
         for (int channel = 0; channel < channelCount; channel++)
         {
             Color maskColor = colorData.channelMask[channel];
             colors[colorIndex++] = (short)Mathf.FloorToInt(maskColor.r * 255f);
             colors[colorIndex++] = (short)Mathf.FloorToInt(maskColor.g * 255f);
             colors[colorIndex++] = (short)Mathf.FloorToInt(maskColor.b * 255f);
             colors[colorIndex++] = (short)Mathf.FloorToInt(maskColor.a * 255f);
             Color additiveMaskColor = colorData.channelAdditiveMask[channel];
             colors[colorIndex++] = (short)Mathf.FloorToInt(additiveMaskColor.r * 255f);
             colors[colorIndex++] = (short)Mathf.FloorToInt(additiveMaskColor.g * 255f);
             colors[colorIndex++] = (short)Mathf.FloorToInt(additiveMaskColor.b * 255f);
             colors[colorIndex++] = (short)Mathf.FloorToInt(additiveMaskColor.a * 255f);
         }
     }
 }
Beispiel #9
0
        public static void UnpackRecipeVersion3(UMA.UMAData.UMARecipe umaRecipe, UMAPackRecipe umaPackRecipe, UMAContext context)
        {
            umaRecipe.slotDataList = new SlotData[umaPackRecipe.slotsV3.Length];
            umaRecipe.SetRace(context.GetRace(umaPackRecipe.race));

            umaRecipe.ClearDna();
            List <UMADnaBase> packedDna = UnPackDNA(umaPackRecipe.packedDna);

            foreach (UMADnaBase umd in packedDna)
            {
                umaRecipe.AddDna(umd);
            }

            OverlayColorData[] colorData;
            if (UMAPackRecipe.ArrayHasData(umaPackRecipe.fColors))
            {
                colorData = new OverlayColorData[umaPackRecipe.fColors.Length];
                for (int i = 0; i < colorData.Length; i++)
                {
                    colorData[i] = new OverlayColorData();
                    umaPackRecipe.fColors[i].SetOverlayColorData(colorData[i]);
                }
            }
            else if (UMAPackRecipe.ArrayHasData(umaPackRecipe.colors))
            {
                colorData = new OverlayColorData[umaPackRecipe.colors.Length];
                for (int i = 0; i < colorData.Length; i++)
                {
                    colorData[i] = new OverlayColorData();
                    umaPackRecipe.colors[i].SetOverlayColorData(colorData[i]);
                }
            }
            else
            {
                colorData = new OverlayColorData[0];
            }

            umaRecipe.sharedColors = new OverlayColorData[umaPackRecipe.sharedColorCount];
            for (int i = 0; i < umaRecipe.sharedColors.Length; i++)
            {
                umaRecipe.sharedColors[i] = colorData[i];
            }

            for (int i = 0; i < umaPackRecipe.slotsV3.Length; i++)
            {
                PackedSlotDataV3 packedSlot = umaPackRecipe.slotsV3[i];
                if (UMAPackRecipe.SlotIsValid(packedSlot))
                {
                    var tempSlotData = context.InstantiateSlot(packedSlot.id);
                    tempSlotData.overlayScale = packedSlot.scale * 0.01f;
                    umaRecipe.slotDataList[i] = tempSlotData;

                    if (packedSlot.copyIdx == -1)
                    {
                        for (int i2 = 0; i2 < packedSlot.overlays.Length; i2++)
                        {
                            PackedOverlayDataV3 packedOverlay = packedSlot.overlays[i2];
                            OverlayData         overlayData   = context.InstantiateOverlay(packedOverlay.id);
                            overlayData.rect = new Rect(
                                packedOverlay.rect[0],
                                packedOverlay.rect[1],
                                packedOverlay.rect[2],
                                packedOverlay.rect[3]);

                            if (packedOverlay.colorIdx < umaPackRecipe.sharedColorCount)
                            {
                                overlayData.colorData = umaRecipe.sharedColors[packedOverlay.colorIdx];
                            }
                            else
                            {
                                overlayData.colorData      = colorData[packedOverlay.colorIdx].Duplicate();
                                overlayData.colorData.name = OverlayColorData.UNSHARED;
                            }

                            if (UMAPackRecipe.MaterialIsValid(overlayData.asset.material))
                            {
                                overlayData.EnsureChannels(overlayData.asset.material.channels.Length);
                            }

                                                        #if (UNITY_STANDALONE || UNITY_IOS || UNITY_ANDROID || UNITY_PS4 || UNITY_XBOXONE) && !UNITY_2017_3_OR_NEWER //supported platforms for procedural materials
                            if (packedOverlay.data == null)
                            {
                                overlayData.proceduralData = new OverlayData.OverlayProceduralData[0];
                            }
                            else
                            {
                                overlayData.proceduralData = new OverlayData.OverlayProceduralData[packedOverlay.data.Length];

                                for (int dataIdx = 0; dataIdx < packedOverlay.data.Length; dataIdx++)
                                {
                                    OverlayData.OverlayProceduralData proceduralData = new OverlayData.OverlayProceduralData();
                                    packedOverlay.data[dataIdx].SetOverlayProceduralData(proceduralData);
                                    overlayData.proceduralData[dataIdx] = proceduralData;
                                }
                            }
                            #endif

                            tempSlotData.AddOverlay(overlayData);
                        }
                    }
                    else
                    {
                        tempSlotData.SetOverlayList(umaRecipe.slotDataList[packedSlot.copyIdx].GetOverlayList());
                    }
                }
            }
        }
Beispiel #10
0
        public static void UnpackRecipeVersion2(UMA.UMAData.UMARecipe umaRecipe, UMAPackRecipe umaPackRecipe, UMAContext context)
        {
            umaRecipe.slotDataList = new SlotData[umaPackRecipe.slotsV2.Length];
            umaRecipe.SetRace(context.GetRace(umaPackRecipe.race));

            umaRecipe.ClearDna();
            List <UMADnaBase> packedDna = UnPackDNA(umaPackRecipe.packedDna);

            foreach (UMADnaBase umd in packedDna)
            {
                umaRecipe.AddDna(umd);
            }

            OverlayColorData[] colorData;
            if (UMAPackRecipe.ArrayHasData(umaPackRecipe.fColors))
            {
                colorData = new OverlayColorData[umaPackRecipe.fColors.Length];
                for (int i = 0; i < colorData.Length; i++)
                {
                    colorData[i] = new OverlayColorData();
                    umaPackRecipe.fColors[i].SetOverlayColorData(colorData[i]);
                }
            }
            else if (UMAPackRecipe.ArrayHasData(umaPackRecipe.colors))
            {
                colorData = new OverlayColorData[umaPackRecipe.colors.Length];
                for (int i = 0; i < colorData.Length; i++)
                {
                    colorData[i] = new OverlayColorData();
                    umaPackRecipe.colors[i].SetOverlayColorData(colorData[i]);
                }
            }
            else
            {
                colorData = new OverlayColorData[0];
            }

            umaRecipe.sharedColors = new OverlayColorData[umaPackRecipe.sharedColorCount];
            for (int i = 0; i < umaRecipe.sharedColors.Length; i++)
            {
                umaRecipe.sharedColors[i] = colorData[i];
            }

            for (int i = 0; i < umaPackRecipe.slotsV2.Length; i++)
            {
                PackedSlotDataV2 packedSlot = umaPackRecipe.slotsV2[i];
                if (UMAPackRecipe.SlotIsValid(packedSlot))
                {
                    var tempSlotData = context.InstantiateSlot(packedSlot.id);
                    tempSlotData.overlayScale = packedSlot.scale * 0.01f;
                    umaRecipe.slotDataList[i] = tempSlotData;

                    if (packedSlot.copyIdx == -1)
                    {
                        for (int i2 = 0; i2 < packedSlot.overlays.Length; i2++)
                        {
                            PackedOverlayDataV2 packedOverlay = packedSlot.overlays[i2];
                            OverlayData         overlayData   = context.InstantiateOverlay(packedOverlay.id);
                            overlayData.rect = new Rect(packedOverlay.rect[0],
                                                        packedOverlay.rect[1],
                                                        packedOverlay.rect[2],
                                                        packedOverlay.rect[3]);
                            if (packedOverlay.colorIdx < umaPackRecipe.sharedColorCount)
                            {
                                overlayData.colorData = umaRecipe.sharedColors[packedOverlay.colorIdx];
                            }
                            else
                            {
                                overlayData.colorData      = colorData[packedOverlay.colorIdx].Duplicate();
                                overlayData.colorData.name = OverlayColorData.UNSHARED;
                            }
                            if (UMAPackRecipe.MaterialIsValid(overlayData.asset.material))
                            {
                                overlayData.EnsureChannels(overlayData.asset.material.channels.Length);
                            }
                            tempSlotData.AddOverlay(overlayData);
                        }
                    }
                    else
                    {
                        tempSlotData.SetOverlayList(umaRecipe.slotDataList[packedSlot.copyIdx].GetOverlayList());
                    }
                }
            }
        }
Beispiel #11
0
        /*
         * public static UMAPackRecipe PackRecipeV2(UMA.UMAData.UMARecipe umaRecipe)
         * {
         * UMAPackRecipe umaPackRecipe = new UMAPackRecipe();
         * umaPackRecipe.version = 2;
         *
         * int slotCount = umaRecipe.slotDataList.Length;
         * umaPackRecipe.slotsV2 = new PackedSlotDataV2[slotCount];
         * if (UMAPackRecipe.RaceIsValid(umaRecipe.raceData))
         * {
         *      umaPackRecipe.race = umaRecipe.raceData.raceName;
         * }
         *
         * umaPackRecipe.packedDna = GetPackedDNA(umaRecipe);
         *
         * umaPackRecipe.sharedColorCount = 0;
         * if (UMAPackRecipe.ArrayHasData(umaRecipe.sharedColors))
         *      umaPackRecipe.sharedColorCount = umaRecipe.sharedColors.Length;
         * List<OverlayColorData> colorEntries = new List<OverlayColorData>(umaPackRecipe.sharedColorCount);
         * List<PackedOverlayColorDataV3> packedColorEntries = new List<PackedOverlayColorDataV3>(umaPackRecipe.sharedColorCount);
         * for (int i = 0; i < umaPackRecipe.sharedColorCount; i++)
         * {
         *      colorEntries.Add(umaRecipe.sharedColors[i]);
         *      packedColorEntries.Add(new PackedOverlayColorDataV3(umaRecipe.sharedColors[i]));
         * }
         *
         * for (int i = 0; i < slotCount; i++)
         * {
         *      if (UMAPackRecipe.SlotIsValid(umaRecipe.slotDataList[i]) && !umaRecipe.slotDataList[i].dontSerialize)
         *      {
         *              PackedSlotDataV2 tempPackedSlotData = new PackedSlotDataV2();
         *              umaPackRecipe.slotsV2[i] = tempPackedSlotData;
         *
         *              tempPackedSlotData.id = umaRecipe.slotDataList[i].asset.slotName;
         *              tempPackedSlotData.scale = Mathf.FloorToInt(umaRecipe.slotDataList[i].overlayScale * 100);
         *
         *              bool copiedOverlays = false;
         *              for (int i2 = 0; i2 < i; i2++)
         *              {
         *                      if (UMAPackRecipe.SlotIsValid(umaRecipe.slotDataList[i2]) && UMAPackRecipe.SlotIsValid(umaPackRecipe.slotsV2[i2]))
         *                      {
         *                              if (umaRecipe.slotDataList[i].GetOverlayList() == umaRecipe.slotDataList[i2].GetOverlayList())
         *                              {
         *                                      tempPackedSlotData.copyIdx = i2;
         *                                      copiedOverlays = true;
         *                                      break;
         *                              }
         *                      }
         *              }
         *              if (copiedOverlays) continue;
         *
         *              tempPackedSlotData.overlays = new PackedOverlayDataV2[umaRecipe.slotDataList[i].OverlayCount];
         *
         *              for (int overlayIdx = 0; overlayIdx < tempPackedSlotData.overlays.Length; overlayIdx++)
         *              {
         *                      PackedOverlayDataV2 tempPackedOverlay = new PackedOverlayDataV2();
         *
         *                      OverlayData overlayData = umaRecipe.slotDataList[i].GetOverlay(overlayIdx);
         *                      tempPackedOverlay.id = overlayData.overlayName;
         *                      tempPackedOverlay.rect = new int[4];
         *                      tempPackedOverlay.rect[0] = Mathf.FloorToInt(overlayData.rect.x);
         *                      tempPackedOverlay.rect[1] = Mathf.FloorToInt(overlayData.rect.y);
         *                      tempPackedOverlay.rect[2] = Mathf.FloorToInt(overlayData.rect.width);
         *                      tempPackedOverlay.rect[3] = Mathf.FloorToInt(overlayData.rect.height);
         *
         *                      OverlayColorData colorData = overlayData.colorData;
         *                      int colorIndex = -1;
         *                      int cIndex = 0;
         *                      foreach (OverlayColorData cData in colorEntries)
         *                      {
         *                              if (cData.name != null && cData.name.Equals(colorData.name) && cData.Equals(colorData))
         *                              {
         *                                      colorIndex = cIndex;
         *                                      break;
         *                              }
         *                              cIndex++;
         *                      }
         *
         *                      if (colorIndex < 0)
         *                      {
         *                              PackedOverlayColorDataV3 newColorEntry = new PackedOverlayColorDataV3(colorData);
         *                              packedColorEntries.Add(newColorEntry);
         *                              colorIndex = colorEntries.Count;
         *                              colorEntries.Add(colorData);
         *
         *                      }
         *
         *                      tempPackedOverlay.colorIdx = colorIndex;
         *
         *                      tempPackedSlotData.overlays[overlayIdx] = tempPackedOverlay;
         *              }
         *      }
         * }
         *
         * umaPackRecipe.fColors = packedColorEntries.ToArray();
         * return umaPackRecipe;
         * }
         */

        public static UMAPackRecipe PackRecipeV3(UMA.UMAData.UMARecipe umaRecipe)
        {
            UMAPackRecipe umaPackRecipe = new UMAPackRecipe();

            umaPackRecipe.version = 3;

            int slotCount = umaRecipe.slotDataList.Length;

            umaPackRecipe.slotsV3 = new PackedSlotDataV3[slotCount];
            if (UMAPackRecipe.RaceIsValid(umaRecipe.raceData))
            {
                umaPackRecipe.race = umaRecipe.raceData.raceName;
            }

            umaPackRecipe.packedDna = GetPackedDNA(umaRecipe);

            umaPackRecipe.sharedColorCount = 0;
            if (UMAPackRecipe.ArrayHasData(umaRecipe.sharedColors))
            {
                umaPackRecipe.sharedColorCount = umaRecipe.sharedColors.Length;
            }
            List <OverlayColorData>         colorEntries       = new List <OverlayColorData>(umaPackRecipe.sharedColorCount);
            List <PackedOverlayColorDataV3> packedColorEntries = new List <PackedOverlayColorDataV3>(umaPackRecipe.sharedColorCount);

            for (int i = 0; i < umaPackRecipe.sharedColorCount; i++)
            {
                colorEntries.Add(umaRecipe.sharedColors[i]);
                packedColorEntries.Add(new PackedOverlayColorDataV3(umaRecipe.sharedColors[i]));
            }

            for (int i = 0; i < slotCount; i++)
            {
                if (UMAPackRecipe.SlotIsValid(umaRecipe.slotDataList[i]) && !umaRecipe.slotDataList[i].dontSerialize)
                {
                    PackedSlotDataV3 tempPackedSlotData = new PackedSlotDataV3();
                    umaPackRecipe.slotsV3[i] = tempPackedSlotData;

                    tempPackedSlotData.id    = umaRecipe.slotDataList[i].asset.slotName;
                    tempPackedSlotData.scale = Mathf.FloorToInt(umaRecipe.slotDataList[i].overlayScale * 100);

                    bool copiedOverlays = false;
                    for (int i2 = 0; i2 < i; i2++)
                    {
                        if (UMAPackRecipe.SlotIsValid(umaRecipe.slotDataList[i2]) && UMAPackRecipe.SlotIsValid(umaPackRecipe.slotsV3[i2]))
                        {
                            if (umaRecipe.slotDataList[i].GetOverlayList() == umaRecipe.slotDataList[i2].GetOverlayList())
                            {
                                tempPackedSlotData.copyIdx = i2;
                                copiedOverlays             = true;
                                break;
                            }
                        }
                    }
                    if (copiedOverlays)
                    {
                        continue;
                    }

                    tempPackedSlotData.overlays = new PackedOverlayDataV3[umaRecipe.slotDataList[i].OverlayCount];

                    for (int overlayIdx = 0; overlayIdx < tempPackedSlotData.overlays.Length; overlayIdx++)
                    {
                        PackedOverlayDataV3 tempPackedOverlay = new PackedOverlayDataV3();

                        OverlayData overlayData = umaRecipe.slotDataList[i].GetOverlay(overlayIdx);
                        tempPackedOverlay.id      = overlayData.overlayName;
                        tempPackedOverlay.rect    = new int[4];
                        tempPackedOverlay.rect[0] = Mathf.FloorToInt(overlayData.rect.x);
                        tempPackedOverlay.rect[1] = Mathf.FloorToInt(overlayData.rect.y);
                        tempPackedOverlay.rect[2] = Mathf.FloorToInt(overlayData.rect.width);
                        tempPackedOverlay.rect[3] = Mathf.FloorToInt(overlayData.rect.height);

                                                #if (UNITY_STANDALONE || UNITY_IOS || UNITY_ANDROID || UNITY_PS4 || UNITY_XBOXONE) && !UNITY_2017_3_OR_NEWER //supported platforms for procedural materials
                        if (overlayData.isProcedural && (overlayData.proceduralData != null))
                        {
                            tempPackedOverlay.data = new PackedOverlaySubstanceData[overlayData.proceduralData.Length];
                            for (int dataIdx = 0; dataIdx < overlayData.proceduralData.Length; dataIdx++)
                            {
                                tempPackedOverlay.data[dataIdx] = new PackedOverlaySubstanceData(overlayData.proceduralData[dataIdx]);
                            }
                        }
                        #endif

                        OverlayColorData colorData = overlayData.colorData;
                        int colorIndex             = -1;
                        int cIndex = 0;
                        foreach (OverlayColorData cData in colorEntries)
                        {
                            if (cData.name != null && cData.name.Equals(colorData.name) && cData.Equals(colorData))
                            {
                                colorIndex = cIndex;
                                break;
                            }
                            cIndex++;
                        }

                        if (colorIndex < 0)
                        {
                            PackedOverlayColorDataV3 newColorEntry = new PackedOverlayColorDataV3(colorData);
                            packedColorEntries.Add(newColorEntry);
                            colorIndex = colorEntries.Count;
                            colorEntries.Add(colorData);
                        }

                        tempPackedOverlay.colorIdx = colorIndex;

                        tempPackedSlotData.overlays[overlayIdx] = tempPackedOverlay;
                    }
                }
            }

            umaPackRecipe.fColors = packedColorEntries.ToArray();
            return(umaPackRecipe);
        }
Beispiel #12
0
 /// <summary>
 /// Copies the colors from another overlay.
 /// </summary>
 /// <param name="overlay">Source overlay.</param>
 public void CopyColors(OverlayData overlay)
 {
     colorData = overlay.colorData.Duplicate();
 }
Beispiel #13
0
 /// <summary>
 /// Constructor for overlay using the given asset.
 /// </summary>
 /// <param name="asset">Asset.</param>
 public OverlayData(OverlayDataAsset asset)
 {
     this.asset     = asset;
     this.colorData = new OverlayColorData(asset.material.channels.Length);
     this.rect      = asset.rect;
 }
Beispiel #14
0
            /// <summary>
            /// Combine additional recipe with current data.
            /// </summary>
            /// <param name="recipe">Recipe.</param>
            /// <param name="additional">If set to <c>true</c> recipe will not be serialized.</param>
            public void Merge(UMARecipe recipe, bool additional)
            {
                if (recipe == null)
                {
                    return;
                }

                if ((recipe.raceData != null) && (recipe.raceData != raceData))
                {
                    Debug.LogWarning("Merging recipe with conflicting race data: " + recipe.raceData.name);
                }

                foreach (var dnaEntry in recipe.umaDna)
                {
                    var destDNA = GetOrCreateDna(dnaEntry.Key);
                    destDNA.Values = dnaEntry.Value.Values;
                }

                mergedSharedColors.Clear();
                if (sharedColors == null)
                {
                    sharedColors = new OverlayColorData[0];
                }
                if (recipe.sharedColors != null)
                {
                    for (int i = 0; i < sharedColors.Length; i++)
                    {
                        if ((sharedColors[i] != null) && sharedColors[i].HasName())
                        {
                            mergedSharedColors.Add(sharedColors[i].name, i);
                        }
                    }

                    for (int i = 0; i < recipe.sharedColors.Length; i++)
                    {
                        OverlayColorData sharedColor = recipe.sharedColors[i];
                        if (sharedColor.HasName())
                        {
                            int sharedIndex;
                            if (!mergedSharedColors.TryGetValue(sharedColor.name, out sharedIndex))
                            {
                                int index = sharedColors.Length;
                                mergedSharedColors.Add(sharedColor.name, index);
                                Array.Resize <OverlayColorData>(ref sharedColors, index + 1);
                                sharedColors[index] = sharedColor.Duplicate();
                            }
                        }
                    }
                }

                if (slotDataList == null)
                {
                    slotDataList = new SlotData[0];
                }
                if (recipe.slotDataList != null)
                {
                    for (int i = 0; i < recipe.slotDataList.Length; i++)
                    {
                        MergeSlot(recipe.slotDataList[i], additional);
                    }
                }
            }