Exemplo n.º 1
0
        public virtual void Awake()
        {
            activeGeneratorCoroutine = null;

            if (atlasResolution == 0)
            {
                atlasResolution = 256;
            }

            if (defaultOverlayAsset != null)
            {
                _defaultOverlayData = new OverlayData(defaultOverlayAsset);
            }

            if (!textureMerge)
            {
                Transform tempTextureMerger = Instantiate(textureMergePrefab, new Vector3(), Quaternion.identity) as Transform;
                textureMerge = tempTextureMerger.GetComponent("TextureMerge") as TextureMerge;
                textureMerge.transform.parent = transform;
                textureMerge.gameObject.SetActive(false);
            }

            //Garbage Collection hack
            var mb = (System.GC.GetTotalMemory(false) / (1024 * 1024));

            if (mb < 10)
            {
                byte[] data = new byte[10 * 1024 * 1024];
                data[0] = 0;
                data[10 * 1024 * 1024 - 1] = 0;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Create a Wardrobe Recipe from the slot (and optionally overlay)
        /// </summary>
        /// <param name="path"></param>
        /// <param name="sd"></param>
        /// <param name="od"></param>
        /// <param name="slotName"></param>
        /// <param name="addToGlobalLibrary"></param>
        public static UMAWardrobeRecipe CreateRecipe(string path, SlotDataAsset sd, OverlayDataAsset od, string slotName, bool addToGlobalLibrary)
        {
            // Generate an asset in memory
            UMAWardrobeRecipe asset = ScriptableObject.CreateInstance <CharacterSystem.UMAWardrobeRecipe>();

            UMAData.UMARecipe recipe = new UMAData.UMARecipe();
            recipe.ClearDna();
            SlotData mySlot = new SlotData(sd);

            if (od != null)
            {
                OverlayData myOverlay = new OverlayData(od);
                mySlot.AddOverlay(myOverlay);
            }
            recipe.SetSlot(0, mySlot);
            asset.Save(recipe, UMAContextBase.Instance);
            asset.DisplayValue = slotName;

            // Write the asset to disk
            AssetDatabase.CreateAsset(asset, path);
            AssetDatabase.SaveAssets();
            if (addToGlobalLibrary)
            {
                // Add it to the global libary
                UMAAssetIndexer.Instance.EvilAddAsset(typeof(CharacterSystem.UMAWardrobeRecipe), asset);
                EditorUtility.SetDirty(UMAAssetIndexer.Instance);
            }
            // Inform the asset database a file has changes
            AssetDatabase.Refresh();
            return(asset);
        }
        /// <summary>
        /// Instantiate a tinted overlay by name hash.
        /// </summary>
        /// <returns>The overlay.</returns>
        /// <param name="nameHash">Name hash.</param>
        /// <param name="color">Color.</param>
        public override OverlayData InstantiateOverlay(int nameHash, Color color)
        {
            OverlayData res = InstantiateOverlay(nameHash);

            res.colorData.color = color;
            return(res);
        }
	public override void AddOverlay(OverlayData overlay)
	{
		ValidateDictionary();
		var hash = UMASkeleton.StringToHash(overlay.overlayName);
		if (overlayDictionary.ContainsKey(hash))
		{
			for (int i = 0; i < overlayElementList.Length; i++)
			{
				if (overlayElementList[i].overlayName == overlay.overlayName)
				{
					overlayElementList[i] = overlay;
					break;
				}
			}
		}
		else
		{
			var list = new OverlayData[overlayElementList.Length + 1];
			for (int i = 0; i < overlayElementList.Length; i++)
			{
				list[i] = overlayElementList[i];
			}
			list[list.Length - 1] = overlay;
			overlayElementList = list;
		}
		overlayDictionary[hash] = overlay;
	}
Exemplo n.º 5
0
        public virtual void Awake()
        {
            activeGeneratorCoroutine = null;

            if (atlasResolution == 0)
            {
                atlasResolution = 256;
            }

            if (defaultOverlayAsset != null)
            {
                _defaultOverlayData = new OverlayData(defaultOverlayAsset);
            }

            if (!textureMerge)
            {
                if (Debug.isDebugBuild)
                {
                    Debug.LogError("No TextureMerge set!");
                }
            }

            //Garbage Collection hack
            var mb = (System.GC.GetTotalMemory(false) / (1024 * 1024));

            if (mb < 10)
            {
                byte[] data = new byte[10 * 1024 * 1024];
                data[0] = 0;
                data[10 * 1024 * 1024 - 1] = 0;
            }
        }
Exemplo n.º 6
0
        private void SelectNewOverlay(int index)
        {
            if (index < 0 || index >= overlayDataList.serializedProperty.arraySize)
            {
                currentOverlayProperty = null;
                return;
            }
            Debug.Log("Index is " + index);
            var element = overlayDataList.serializedProperty.GetArrayElementAtIndex(overlayDataList.index);

            if (element.objectReferenceValue == null)
            {
                currentOverlayProperty = null;
                return;
            }
            if (element != currentOverlayProperty)
            {
                currentOverlayProperty = element;
                OverlayDataAsset asset = currentOverlayProperty.objectReferenceValue as OverlayDataAsset;

                if (!AdditionalOverlays.ContainsKey(asset.GetInstanceID()))
                {
                    AdditionalOverlays.Add(asset.GetInstanceID(), new OverlayData(asset));
                }
                TempOverlay   = AdditionalOverlays[asset.GetInstanceID()];
                overlayEditor = new OverlayEditor(TempUMAData.umaRecipe, TempSlot, TempOverlay, baseOverlayProperty.objectReferenceValue as OverlayDataAsset);
            }
        }
Exemplo n.º 7
0
 /// <summary>
 /// Add an overlay to the slot.
 /// </summary>
 /// <param name="overlayData">Overlay.</param>
 public void AddOverlay(OverlayData overlayData)
 {
     if (overlayData)
     {
         overlayList.Add(overlayData);
     }
 }
        protected override IEnumerator workerMethod()
        {
            umaData.generatedMaterials.rendererCount = rendererCount;
            umaData.generatedMaterials.materials     = generatedMaterials;

            GenerateAtlasData();
            OptimizeAtlas();

            textureProcessCoroutine.Prepare(umaData, umaGenerator);
            yield return(textureProcessCoroutine);

            CleanBackUpTextures();
            UpdateUV();

            // HACK - is this the right place?
            SlotData[] slots = umaData.umaRecipe.slotDataList;
            for (int i = 0; i < slots.Length; i++)
            {
                var slot = slots[i];
                if (slot == null)
                {
                    continue;
                }

                for (int j = 1; j < slot.OverlayCount; j++)
                {
                    OverlayData overlay = slot.GetOverlay(j);
                    #if UNITY_STANDALONE || UNITY_IOS || UNITY_ANDROID || UNITY_PS4 || UNITY_XBOXONE //supported platforms for procedural materials
                    if ((overlay != null) && (overlay.isProcedural))
                    {
                        overlay.ReleaseProceduralTextures();
                    }
                    #endif
                }
            }

            if (updateMaterialList)
            {
                for (int j = 0; j < umaData.rendererCount; j++)
                {
                    var renderer      = umaData.GetRenderer(j);
                    var mats          = renderer.sharedMaterials;
                    var newMats       = new Material[mats.Length];
                    var atlasses      = umaData.generatedMaterials.materials;
                    int materialIndex = 0;
                    for (int i = 0; i < atlasses.Count; i++)
                    {
                        if (atlasses[i].renderer == j)
                        {
                            UMAUtils.DestroySceneObject(mats[materialIndex]);
                            newMats[materialIndex] = atlasses[i].material;
                            materialIndex++;
                        }
                    }
                    renderer.sharedMaterials = newMats;
                }
            }
        }
Exemplo n.º 9
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);
                }
            }
        }
        /// <summary>
        /// Instantiate a tinted overlay by name.
        /// </summary>
        /// <returns>The overlay.</returns>
        /// <param name="name">Name.</param>
        /// <param name="color">Color.</param>
        public override OverlayData InstantiateOverlay(string name, Color color)
        {
#if SUPER_LOGGING
            Debug.Log("Instantiating Overlay: " + name);
#endif
            OverlayData res = InstantiateOverlay(name);
            res.colorData.color = color;
            return(res);
        }
Exemplo n.º 11
0
 public void SetOverlay(int index, OverlayData overlay)
 {
     if (index >= overlayList.Count)
     {
         overlayList.Capacity = index + 1;
         while (index >= overlayList.Count)
         {
             overlayList.Add(null);
         }
     }
     overlayList[index] = overlay;
 }
Exemplo n.º 12
0
        /// <summary>
        /// Attempts to find an equivalent overlay in the slot, based on the overlay rect and its assets properties.
        /// </summary>
        /// <param name="overlay"></param>
        /// <returns></returns>
        public OverlayData GetEquivalentUsedOverlay(OverlayData overlay)
        {
            foreach (OverlayData overlay2 in overlayList)
            {
                if (OverlayData.EquivalentAssetAndUse(overlay, overlay2))
                {
                    return(overlay2);
                }
            }

            return(null);
        }
Exemplo n.º 13
0
	private OverlayData[] GetOverlayDataArray(){
	
		int arrayCount = m_OverlayDataCount.intValue;
		OverlayData[] OverlayDataArray = new OverlayData[arrayCount];
		
		for(int i = 0; i < arrayCount; i++){
		
			OverlayDataArray[i] = m_Object.FindProperty(string.Format(kArrayData,i)).objectReferenceValue as OverlayData ;
			
		}
		return OverlayDataArray;
		
	}
Exemplo n.º 14
0
 public void CopyColors(OverlayData overlay)
 {
     if (overlay.useAdvancedMasks)
     {
         EnsureChannels(overlay.channelAdditiveMask.Length);
         for (int i = 0; i < overlay.channelAdditiveMask.Length; i++)
         {
             SetColor(i, overlay.GetColor(i));
             SetAdditive(i, overlay.GetAdditive(i));
         }
     }
     else
     {
         SetColor(0, overlay.color);
     }
 }
Exemplo n.º 15
0
 public void AddOverlay(string name, OverlayData overlay)
 {
     var list = new OverlayData[overlayElementList.Length + 1];
     for (int i = 0; i < overlayElementList.Length; i++)
     {
         if (overlayElementList[i].overlayName == name)
         {
             overlayElementList[i] = overlay;
             return;
         }
         list[i] = overlayElementList[i];
     }
     list[list.Length - 1] = overlay;
     overlayElementList = list;
     overlayDictionary.Add(name, overlay);
 }
Exemplo n.º 16
0
        public OverlayData Duplicate()
        {
            OverlayData tempOverlay = CreateInstance <OverlayData>();

            tempOverlay.overlayName = overlayName;
            tempOverlay.listID      = listID;
            tempOverlay.color       = color;
            tempOverlay.rect        = rect;
            tempOverlay.textureList = new Texture2D[textureList.Length];
            for (int i = 0; i < textureList.Length; i++)
            {
                tempOverlay.textureList[i] = textureList[i];
            }

            return(tempOverlay);
        }
Exemplo n.º 17
0
        /// <summary>
        /// Deep copy of the SlotData.
        /// </summary>
        public SlotData Copy()
        {
            var res = new SlotData(asset);

            int overlayCount = overlayList.Count;

            res.overlayList = new List <OverlayData>(overlayCount);
            for (int i = 0; i < overlayCount; i++)
            {
                OverlayData overlay = overlayList[i];
                if (overlay != null)
                {
                    res.overlayList.Add(overlay.Duplicate());
                }
            }

            return(res);
        }
Exemplo n.º 18
0
        private void SetupOverlay(UMAData.MaterialFragment source, int OverlayIndex, int textureType)
        {
            if (source.overlays[OverlayIndex] == null)
            {
                return;
            }
            if (source.overlays[OverlayIndex].textureList[textureType] == null)
            {
                return;
            }
            if (source.isNoTextures)
            {
                return;
            }

            Rect overlayRect;

            if (source.rects[OverlayIndex].width != 0)
            {
                overlayRect = new Rect(atlasRect.xMin + source.rects[OverlayIndex].x * resolutionScale.x, atlasRect.yMax - source.rects[OverlayIndex].y * resolutionScale.y - source.rects[OverlayIndex].height * resolutionScale.y, source.rects[OverlayIndex].width * resolutionScale.x, source.rects[OverlayIndex].height * resolutionScale.y);
            }
            else
            {
                overlayRect = atlasRect;
            }

            SetupMaterial(ref textureMergeRects[textureMergeRectCount], source, OverlayIndex, ref overlayRect, textureType);

            // for some reason, the overlayData is stored on the next textureMergeRect.
            // Check the generator. There must be a reason, but I just can't fathom it.
            if (source.overlayData[OverlayIndex + 1].instanceTransformed)
            {
                OverlayData od = source.overlayData[OverlayIndex + 1];
                textureMergeRects[textureMergeRectCount].transform = true;
                textureMergeRects[textureMergeRectCount].rotation  = od.Rotation;
                textureMergeRects[textureMergeRectCount].scale     = od.Scale;
            }
            else
            {
                textureMergeRects[textureMergeRectCount].transform = false;
            }
            textureMergeRectCount++;
        }
Exemplo n.º 19
0
            /// <summary>
            /// Are two overlay lists the same?
            /// </summary>
            /// <returns><c>true</c>, if lists match, <c>false</c> otherwise.</returns>
            /// <param name="list1">List1.</param>
            /// <param name="list2">List2.</param>
            public static bool OverlayListsMatch(List <OverlayData> list1, List <OverlayData> list2)
            {
                if ((list1 == null) || (list2 == null))
                {
                    return(false);
                }
                if ((list1.Count == 0) || (list1.Count != list2.Count))
                {
                    return(false);
                }

                for (int i = 0; i < list1.Count; i++)
                {
                    OverlayData overlay1 = list1[i];
                    if (!(overlay1))
                    {
                        continue;
                    }
                    bool found = false;
                    for (int j = 0; j < list2.Count; j++)
                    {
                        OverlayData overlay2 = list2[i];
                        if (!(overlay2))
                        {
                            continue;
                        }

                        if (OverlayData.Equivalent(overlay1, overlay2))
                        {
                            found = true;
                            break;
                        }
                    }
                    if (!found)
                    {
                        return(false);
                    }
                }

                return(true);
            }
Exemplo n.º 20
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());
                    }
                }
            }
        }
Exemplo n.º 21
0
 public void SetOverlay(int index, OverlayData overlay)
 {
     if (index >= overlayList.Count)
     {
         overlayList.Capacity = index + 1;
         while (index >= overlayList.Count)
         {
             overlayList.Add(null);
         }
     }
     overlayList[index] = overlay;
 }
Exemplo n.º 22
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);
        }
Exemplo n.º 23
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());
                    }
                }
            }
        }
Exemplo n.º 24
0
	public virtual void AddOverlay(OverlayData overlay)
	{
		throw new System.NotImplementedException();
	}
        protected override void Start()
        {
            if (generatedMaterialLookup == null)
            {
                generatedMaterialLookup = new Dictionary <GeneratedMaterialLookupKey, UMAData.GeneratedMaterial>(20);
            }
            else
            {
                generatedMaterialLookup.Clear();
            }
            backUpTexture = umaData.backUpTextures();
            umaData.CleanTextures();
            generatedMaterials = new List <UMAData.GeneratedMaterial>(20);
            atlassedMaterials.Clear();
            uniqueRenderers.Clear();

            SlotData[] slots = umaData.umaRecipe.slotDataList;

            for (int i = 0; i < slots.Length; i++)
            {
                SlotData slot = slots[i];
                if (slot == null)
                {
                    continue;
                }
                if (slot.Suppressed)
                {
                    continue;
                }

                //Keep a running list of unique RendererHashes from our slots
                //Null rendererAsset gets added, which is good, it is the default renderer.
                if (!uniqueRenderers.Contains(slot.rendererAsset))
                {
                    uniqueRenderers.Add(slot.rendererAsset);
                }

                // Let's only add the default overlay if the slot has meshData and NO overlays
                // This should be able to be removed if default overlay/textures are ever added to uma materials...
                if ((slot.asset.meshData != null) && (slot.OverlayCount == 0))
                {
                    if (umaGenerator.defaultOverlaydata != null)
                    {
                        slot.AddOverlay(umaGenerator.defaultOverlaydata);
                    }
                }

                OverlayData overlay0 = slot.GetOverlay(0);
                if ((slot.asset.material != null) && (overlay0 != null))
                {
                    GeneratedMaterialLookupKey lookupKey = new GeneratedMaterialLookupKey
                    {
                        overlayList   = slot.GetOverlayList(),
                        rendererAsset = slot.rendererAsset
                    };

                    UMAData.GeneratedMaterial generatedMaterial;
                    if (!generatedMaterialLookup.TryGetValue(lookupKey, out generatedMaterial))
                    {
                        generatedMaterial = FindOrCreateGeneratedMaterial(slot.asset.material, slot.rendererAsset);
                        generatedMaterialLookup.Add(lookupKey, generatedMaterial);
                    }

                    int validOverlayCount = 0;
                    for (int j = 0; j < slot.OverlayCount; j++)
                    {
                        var overlay = slot.GetOverlay(j);
                        if (overlay != null)
                        {
                            validOverlayCount++;
#if (UNITY_STANDALONE || UNITY_IOS || UNITY_ANDROID || UNITY_PS4 || UNITY_XBOXONE) && !UNITY_2017_3_OR_NEWER //supported platforms for procedural materials
                            if (overlay.isProcedural)
                            {
                                overlay.GenerateProceduralTextures();
                            }
#endif
                        }
                    }

                    UMAData.MaterialFragment tempMaterialDefinition = new UMAData.MaterialFragment();
                    tempMaterialDefinition.baseOverlay              = new UMAData.textureData();
                    tempMaterialDefinition.baseOverlay.textureList  = overlay0.textureArray;
                    tempMaterialDefinition.baseOverlay.alphaTexture = overlay0.alphaMask;
                    tempMaterialDefinition.baseOverlay.overlayType  = overlay0.overlayType;

                    tempMaterialDefinition.umaMaterial = slot.asset.material;
                    tempMaterialDefinition.baseColor   = overlay0.colorData.color;
                    tempMaterialDefinition.size        = overlay0.pixelCount;

                    tempMaterialDefinition.overlays               = new UMAData.textureData[validOverlayCount - 1];
                    tempMaterialDefinition.overlayColors          = new Color32[validOverlayCount - 1];
                    tempMaterialDefinition.rects                  = new Rect[validOverlayCount - 1];
                    tempMaterialDefinition.overlayData            = new OverlayData[validOverlayCount];
                    tempMaterialDefinition.channelMask            = new Color[validOverlayCount][];
                    tempMaterialDefinition.channelAdditiveMask    = new Color[validOverlayCount][];
                    tempMaterialDefinition.overlayData[0]         = slot.GetOverlay(0);
                    tempMaterialDefinition.channelMask[0]         = slot.GetOverlay(0).colorData.channelMask;
                    tempMaterialDefinition.channelAdditiveMask[0] = slot.GetOverlay(0).colorData.channelAdditiveMask;
                    tempMaterialDefinition.slotData               = slot;

                    int overlayID = 0;
                    for (int j = 1; j < slot.OverlayCount; j++)
                    {
                        OverlayData overlay = slot.GetOverlay(j);
                        if (overlay == null)
                        {
                            continue;
                        }

                        if (IsUVCoordinates(overlay.rect))
                        {
                            tempMaterialDefinition.rects[overlayID] = ScaleToBase(overlay.rect, overlay0.textureArray[0]);
                        }
                        else
                        {
                            tempMaterialDefinition.rects[overlayID] = overlay.rect;                             // JRRM: Convert here into base overlay coordinates?
                        }
                        tempMaterialDefinition.overlays[overlayID]              = new UMAData.textureData();
                        tempMaterialDefinition.overlays[overlayID].textureList  = overlay.textureArray;
                        tempMaterialDefinition.overlays[overlayID].alphaTexture = overlay.alphaMask;
                        tempMaterialDefinition.overlays[overlayID].overlayType  = overlay.overlayType;
                        tempMaterialDefinition.overlayColors[overlayID]         = overlay.colorData.color;

                        overlayID++;
                        tempMaterialDefinition.overlayData[overlayID]         = overlay;
                        tempMaterialDefinition.channelMask[overlayID]         = overlay.colorData.channelMask;
                        tempMaterialDefinition.channelAdditiveMask[overlayID] = overlay.colorData.channelAdditiveMask;
                    }

                    tempMaterialDefinition.overlayList  = lookupKey.overlayList;
                    tempMaterialDefinition.isRectShared = false;
                    for (int j = 0; j < generatedMaterial.materialFragments.Count; j++)
                    {
                        if (tempMaterialDefinition.overlayList == generatedMaterial.materialFragments[j].overlayList)
                        {
                            tempMaterialDefinition.isRectShared = true;
                            tempMaterialDefinition.rectFragment = generatedMaterial.materialFragments[j];
                            break;
                        }
                    }
                    generatedMaterial.materialFragments.Add(tempMaterialDefinition);
                }
            }

            //****************************************************
            //* Set parameters based on shader parameter mapping
            //****************************************************
            for (int i = 0; i < generatedMaterials.Count; i++)
            {
                UMAData.GeneratedMaterial ugm = generatedMaterials[i];
                if (ugm.umaMaterial.shaderParms != null)
                {
                    for (int j = 0; j < ugm.umaMaterial.shaderParms.Length; j++)
                    {
                        UMAMaterial.ShaderParms parm = ugm.umaMaterial.shaderParms[j];
                        if (ugm.material.HasProperty(parm.ParameterName))
                        {
                            foreach (OverlayColorData ocd in umaData.umaRecipe.sharedColors)
                            {
                                if (ocd.name == parm.ColorName)
                                {
                                    ugm.material.SetColor(parm.ParameterName, ocd.color);
                                    break;
                                }
                            }
                        }
                    }
                }
            }
            packTexture = new MaxRectsBinPack(umaGenerator.atlasResolution, umaGenerator.atlasResolution, false);
        }
 public abstract void AddOverlay(OverlayData overlay);
Exemplo n.º 27
0
            /// <summary>
            /// Combine additional slot with current data.
            /// </summary>
            /// <param name="slot">Slot.</param>
            /// <param name="additional">If set to <c>true</c> slot will not be serialized.</param>
            public void MergeSlot(SlotData slot, bool additional)
            {
                if ((slot == null) || (slot.asset == null))
                {
                    return;
                }

                int overlayCount = 0;

                for (int i = 0; i < slotDataList.Length; i++)
                {
                    if (slotDataList[i] == null)
                    {
                        continue;
                    }
                    if (slot.asset == slotDataList[i].asset)
                    {
                        SlotData originalSlot = slotDataList[i];
                        overlayCount = slot.OverlayCount;
                        for (int j = 0; j < overlayCount; j++)
                        {
                            OverlayData overlay         = slot.GetOverlay(j);
                            OverlayData originalOverlay = originalSlot.GetEquivalentOverlay(overlay);
                            if (originalOverlay != null)
                            {
                                //								originalOverlay.CopyColors(overlay);
                            }
                            else
                            {
                                OverlayData overlayCopy = overlay.Duplicate();
                                if (overlayCopy.colorData.HasName())
                                {
                                    int sharedIndex;
                                    if (mergedSharedColors.TryGetValue(overlayCopy.colorData.name, out sharedIndex))
                                    {
                                        overlayCopy.colorData = sharedColors[sharedIndex];
                                    }
                                }
                                originalSlot.AddOverlay(overlayCopy);
                            }
                        }
                        return;
                    }
                }

                int insertIndex = slotDataList.Length;

                System.Array.Resize <SlotData>(ref slotDataList, slotDataList.Length + 1);
                if (additional)
                {
                    additionalSlotCount += 1;
                }
                else
                {
                    for (int i = 0; i < additionalSlotCount; i++)
                    {
                        slotDataList[insertIndex] = slotDataList[insertIndex - 1];
                        insertIndex--;
                    }
                }

                SlotData slotCopy = slot.Copy();

                overlayCount = slotCopy.OverlayCount;
                for (int j = 0; j < overlayCount; j++)
                {
                    OverlayData overlay = slotCopy.GetOverlay(j);
                    if (overlay.colorData.HasName())
                    {
                        int sharedIndex;
                        if (mergedSharedColors.TryGetValue(overlay.colorData.name, out sharedIndex))
                        {
                            overlay.colorData = sharedColors[sharedIndex];
                        }
                    }
                }
                slotDataList[insertIndex] = slotCopy;
                MergeMatchingOverlays();
            }
Exemplo n.º 28
0
 public void CopyColors(OverlayData overlay)
 {
     if (overlay.useAdvancedMasks)
     {
         EnsureChannels(overlay.channelAdditiveMask.Length);
         for (int i = 0; i < overlay.channelAdditiveMask.Length; i++)
         {
             SetColor(i, overlay.GetColor(i));
             SetAdditive(i, overlay.GetAdditive(i));
         }
     }
     else
     {
         SetColor(0, overlay.color);
     }
 }
Exemplo n.º 29
0
	private void AddOverlayData(OverlayData overlayElement){
		m_OverlayDataCount.intValue ++;
		SetOverlayData(m_OverlayDataCount.intValue - 1, overlayElement);
	}	
        protected override void Start()
        {
            if (generatedMaterialLookup == null)
            {
                generatedMaterialLookup = new Dictionary <List <OverlayData>, UMAData.GeneratedMaterial>(20);
            }
            else
            {
                generatedMaterialLookup.Clear();
            }
            backUpTexture = umaData.backUpTextures();
            umaData.CleanTextures();
            generatedMaterials = new List <UMAData.GeneratedMaterial>(20);
            atlassedMaterials.Clear();
            rendererCount = 0;

            SlotData[] slots = umaData.umaRecipe.slotDataList;

            for (int i = 0; i < slots.Length; i++)
            {
                var slot = slots[i];
                if (slot == null)
                {
                    continue;
                }

                if ((slot.asset.material != null) && (slot.GetOverlay(0) != null))
                {
                    if (!slot.asset.material.RequireSeperateRenderer)
                    {
                        // At least one slot that doesn't require a seperate renderer, so we reserve renderer 0 for those.
                        rendererCount = 1;
                        break;
                    }
                }
            }

            for (int i = 0; i < slots.Length; i++)
            {
                SlotData slot = slots[i];
                if (slot == null)
                {
                    continue;
                }

                // Let's only add the default overlay if the slot has overlays and NO meshData
                if ((slot.asset.meshData != null) && (slot.OverlayCount == 0))
                {
                    if (umaGenerator.defaultOverlaydata != null)
                    {
                        slot.AddOverlay(umaGenerator.defaultOverlaydata);
                    }
                }

                OverlayData overlay0 = slot.GetOverlay(0);
                if ((slot.asset.material != null) && (overlay0 != null))
                {
                    List <OverlayData>        overlayList = slot.GetOverlayList();
                    UMAData.GeneratedMaterial generatedMaterial;
                    if (!generatedMaterialLookup.TryGetValue(overlayList, out generatedMaterial))
                    {
                        generatedMaterial = FindOrCreateGeneratedMaterial(slot.asset.material);
                        generatedMaterialLookup.Add(overlayList, generatedMaterial);
                    }

                    int validOverlayCount = 0;
                    for (int j = 0; j < slot.OverlayCount; j++)
                    {
                        var overlay = slot.GetOverlay(j);
                        if (overlay != null)
                        {
                            validOverlayCount++;
                            #if UNITY_STANDALONE || UNITY_IOS || UNITY_ANDROID || UNITY_PS4 || UNITY_XBOXONE //supported platforms for procedural materials
                            if (overlay.isProcedural)
                            {
                                overlay.GenerateProceduralTextures();
                            }
                            #endif
                        }
                    }

                    UMAData.MaterialFragment tempMaterialDefinition = new UMAData.MaterialFragment();
                    tempMaterialDefinition.baseOverlay              = new UMAData.textureData();
                    tempMaterialDefinition.baseOverlay.textureList  = overlay0.textureArray;
                    tempMaterialDefinition.baseOverlay.alphaTexture = overlay0.alphaMask;
                    tempMaterialDefinition.baseOverlay.overlayType  = overlay0.overlayType;

                    tempMaterialDefinition.umaMaterial = slot.asset.material;
                    tempMaterialDefinition.baseColor   = overlay0.colorData.color;
                    tempMaterialDefinition.size        = overlay0.pixelCount;

                    tempMaterialDefinition.overlays               = new UMAData.textureData[validOverlayCount - 1];
                    tempMaterialDefinition.overlayColors          = new Color32[validOverlayCount - 1];
                    tempMaterialDefinition.rects                  = new Rect[validOverlayCount - 1];
                    tempMaterialDefinition.overlayData            = new OverlayData[validOverlayCount];
                    tempMaterialDefinition.channelMask            = new Color[validOverlayCount][];
                    tempMaterialDefinition.channelAdditiveMask    = new Color[validOverlayCount][];
                    tempMaterialDefinition.overlayData[0]         = slot.GetOverlay(0);
                    tempMaterialDefinition.channelMask[0]         = slot.GetOverlay(0).colorData.channelMask;
                    tempMaterialDefinition.channelAdditiveMask[0] = slot.GetOverlay(0).colorData.channelAdditiveMask;
                    tempMaterialDefinition.slotData               = slot;

                    int overlayID = 0;
                    for (int j = 1; j < slot.OverlayCount; j++)
                    {
                        OverlayData overlay = slot.GetOverlay(j);
                        if (overlay == null)
                        {
                            continue;
                        }

                        tempMaterialDefinition.rects[overlayID]                 = overlay.rect;
                        tempMaterialDefinition.overlays[overlayID]              = new UMAData.textureData();
                        tempMaterialDefinition.overlays[overlayID].textureList  = overlay.textureArray;
                        tempMaterialDefinition.overlays[overlayID].alphaTexture = overlay.alphaMask;
                        tempMaterialDefinition.overlays[overlayID].overlayType  = overlay.overlayType;
                        tempMaterialDefinition.overlayColors[overlayID]         = overlay.colorData.color;

                        overlayID++;
                        tempMaterialDefinition.overlayData[overlayID]         = overlay;
                        tempMaterialDefinition.channelMask[overlayID]         = overlay.colorData.channelMask;
                        tempMaterialDefinition.channelAdditiveMask[overlayID] = overlay.colorData.channelAdditiveMask;
                    }

                    tempMaterialDefinition.overlayList  = overlayList;
                    tempMaterialDefinition.isRectShared = false;
                    for (int j = 0; j < generatedMaterial.materialFragments.Count; j++)
                    {
                        if (tempMaterialDefinition.overlayList == generatedMaterial.materialFragments[j].overlayList)
                        {
                            tempMaterialDefinition.isRectShared = true;
                            tempMaterialDefinition.rectFragment = generatedMaterial.materialFragments[j];
                            break;
                        }
                    }
                    generatedMaterial.materialFragments.Add(tempMaterialDefinition);
                }
            }

            packTexture = new MaxRectsBinPack(umaGenerator.atlasResolution, umaGenerator.atlasResolution, false);
        }
Exemplo n.º 31
0
 public void AddOverlay(OverlayData overlayData)
 {
     overlayList.Add(overlayData);
 }
Exemplo n.º 32
0
	private void SetOverlayData (int index,OverlayData overlayElement){
		m_Object.FindProperty(string.Format(kArrayData,index)).objectReferenceValue = overlayElement;
		isDirty = true;
	}