System.Collections.Generic.List.ToArray()

Here are the examples of the csharp api System.Collections.Generic.List.ToArray() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

22147 Examples 7

19 Source : AssetBundleIndex.cs
with Apache License 2.0
from A7ocin

public string[] GetAllreplacedetBundleNames()
		{
			List<string> replacedetBundleNames = new List<string>();
			foreach (replacedetBundleIndexList ireplacedetList in bundlesIndex)
			{
				replacedetBundleNames.Add(ireplacedetList.replacedetBundleName);
			}
			return replacedetBundleNames.ToArray();
		}

19 Source : AssetBundleIndex.cs
with Apache License 2.0
from A7ocin

public string[] FindContainingreplacedetBundle(string replacedetNameOrFilename, string type = "")
		{
			List<string> replacedetFoundIn = new List<string>();
			for (int i = 0; i < bundlesIndex.Count; i++)
			{
				for (int ii = 0; ii < bundlesIndex[i].replacedetBundlereplacedets.Count; ii++)
				{
					if (replacedetNameOrFilename == bundlesIndex[i].replacedetBundlereplacedets[ii].replacedetName)
					{
						if (type == "" || (type != "" && (type == bundlesIndex[i].replacedetBundlereplacedets[ii].replacedetType || type == GetTypeWithoutreplacedembly(bundlesIndex[i].replacedetBundlereplacedets[ii].replacedetType))))
						{
							replacedetFoundIn.Add(bundlesIndex[i].replacedetBundleName);
						}

					}
				}
			}
			//if we didn't find it check the filename?
			if (replacedetFoundIn.Count == 0)
			{
				for (int i = 0; i < bundlesIndex.Count; i++)
				{
					for (int ii = 0; ii < bundlesIndex[i].replacedetBundlereplacedets.Count; ii++)
					{
						if (replacedetNameOrFilename == bundlesIndex[i].replacedetBundlereplacedets[ii].filename)
						{
							if (type == "" || (type != "" && (type == bundlesIndex[i].replacedetBundlereplacedets[ii].replacedetType || type == GetTypeWithoutreplacedembly(bundlesIndex[i].replacedetBundlereplacedets[ii].replacedetType))))
							{
								replacedetFoundIn.Add(bundlesIndex[i].replacedetBundleName);
							}

						}
					}
				}
			}
			return replacedetFoundIn.ToArray();
		}

19 Source : AssetBundleIndex.cs
with Apache License 2.0
from A7ocin

public string[] FindContainingreplacedetBundle(int? replacedetNameHash, string type = "")
		{
			List<string> replacedetFoundIn = new List<string>();
			for (int i = 0; i < bundlesIndex.Count; i++)
			{
				for (int ii = 0; ii < bundlesIndex[i].replacedetBundlereplacedets.Count; ii++)
				{
					if (replacedetNameHash == bundlesIndex[i].replacedetBundlereplacedets[ii].replacedetHash)
					{
						if (type == "" || (type != "" && (type == bundlesIndex[i].replacedetBundlereplacedets[ii].replacedetType || type == GetTypeWithoutreplacedembly(bundlesIndex[i].replacedetBundlereplacedets[ii].replacedetType))))
						{
							replacedetFoundIn.Add(bundlesIndex[i].replacedetBundleName);
						}

					}
				}
			}
			return replacedetFoundIn.ToArray();
		}

19 Source : AssetBundleIndex.cs
with Apache License 2.0
from A7ocin

public string[] GetAllreplacedetsOfTypeInBundle(string replacedetBundleName, string type)
		{
			List<string> foundreplacedets = new List<string>();
			foreach (replacedetBundleIndexList ireplacedetList in bundlesIndex)
			{
				if (ireplacedetList.replacedetBundleName == replacedetBundleName)
				{
					foreach (replacedetBundleIndexItem ireplacedet in ireplacedetList.replacedetBundlereplacedets)
					{
						if (type == "" || (type != "" && (type == ireplacedet.replacedetType || type == GetTypeWithoutreplacedembly(ireplacedet.replacedetType))))
						{
							foundreplacedets.Add(ireplacedet.replacedetName);
						}

					}
				}
			}
			return foundreplacedets.ToArray();
		}

19 Source : ExternalCommunicator.cs
with Apache License 2.0
from A7ocin

public void UpdateActions()
    {
        // TO MODIFY	--------------------------------------------
        sender.Send(Encoding.ASCII.GetBytes("STEPPING"));
        string a = Receive();
        AgentMessage agentMessage = JsonConvert.DeserializeObject<AgentMessage>(a);

        foreach (Brain brain in brains)
        {
            if (brain.brainType == BrainType.External)
            {
                string brainName = brain.gameObject.name;

                Dictionary<int, float[]> actionDict = new Dictionary<int, float[]>();
                for (int i = 0; i < current_agents[brainName].Count; i++)
                {
                    if (brain.brainParameters.actionSpaceType == StateType.continuous)
                    {
                        actionDict.Add(current_agents[brainName][i],
                            agentMessage.action[brainName].GetRange(i * brain.brainParameters.actionSize, brain.brainParameters.actionSize).ToArray());
                    }
                    else
                    {
                        actionDict.Add(current_agents[brainName][i],
                            agentMessage.action[brainName].GetRange(i, 1).ToArray());
                    }
                }
                storedActions[brainName] = actionDict;

                Dictionary<int, float[]> memoryDict = new Dictionary<int, float[]>();
                for (int i = 0; i < current_agents[brainName].Count; i++)
                {
                    memoryDict.Add(current_agents[brainName][i],
                        agentMessage.memory[brainName].GetRange(i * brain.brainParameters.memorySize, brain.brainParameters.memorySize).ToArray());
                }
                storedMemories[brainName] = memoryDict;

                Dictionary<int, float> valueDict = new Dictionary<int, float>();
                for (int i = 0; i < current_agents[brainName].Count; i++)
                {
                    valueDict.Add(current_agents[brainName][i],
                        agentMessage.value[brainName][i]);
                }
                storedValues[brainName] = valueDict;
            }

        }
    }

19 Source : DynamicDNAConverterBehaviourEditor.cs
with Apache License 2.0
from A7ocin

private void Init()
		{
			if (_skelModPropDrawer == null)
				_skelModPropDrawer = new SkeletonModifierPropertyDrawer();

			hashNames.Clear();
			hashes.Clear();
			SerializedProperty hashList = serializedObject.FindProperty("hashList");
			for (int i = 0; i < hashList.arraySize; i++)
			{
				hashNames.Add(hashList.GetArrayElementAtIndex(i).FindPropertyRelative("hashName").stringValue);
				hashes.Add(hashList.GetArrayElementAtIndex(i).FindPropertyRelative("hash").intValue);
			}
			if (minimalMode == false)
			{
				bonesInSkeleton = new List<string>(hashNames.ToArray());
			}
			else
			{
				bonesInSkeleton = new List<string>(umaData.skeleton.BoneNames);
			}
			bonesInSkeleton.Sort();
			UpdateDnaNames();
			initialized = true;
		}

19 Source : DynamicDNAConverterBehaviourEditor.cs
with Apache License 2.0
from A7ocin

public override void OnInspectorGUI()
		{
			serializedObject.Update();
			if (!initialized)
				this.Init();

			//Style for Tips
			var foldoutTipStyle = new GUIStyle(EditorStyles.foldout);
			foldoutTipStyle.fontStyle = FontStyle.Bold;
			//DISPLAY VALUE
			EditorGUILayout.PropertyField(serializedObject.FindProperty("DisplayValue"));
			//
			//=============DNA replacedET AND EDITOR============//
			SerializedProperty dnareplacedet = serializedObject.FindProperty("dnareplacedet");
			dnareplacedet.isExpanded = EditorGUILayout.Foldout(dnareplacedet.isExpanded, "Dynamic DNA", foldoutTipStyle);
			if (dnareplacedet.isExpanded)
			{
				GUIHelper.BeginVerticalPadded(3, new Color(0.75f, 0.875f, 1f, 0.3f));
				EditorGUI.indentLevel++;
				dnareplacedetInfoExpanded = EditorGUILayout.Foldout(dnareplacedetInfoExpanded, "INFO");
				if (dnareplacedetInfoExpanded)
					EditorGUILayout.HelpBox("The DynmicDNAreplacedet is the DNA this converter will apply to the skeleton. The DNA consists of names and replacedociated values. Often you display these names as 'sliders'. The values set by these sliders change an Avatar's body proportions by modifying its skeleton bones by the dna value, according to the 'DNA Converter Settings' you set in the 'DNA Converter Settings' section.", MessageType.Info);
				
				if(dnareplacedet.objectReferenceValue == null)
				{
					//show a tip that people need to create or replacedign a dna replacedet
					EditorGUILayout.HelpBox("Create or replacedign a DNA replacedet this converter will use", MessageType.Info);
				}
				EditorGUI.BeginChangeCheck();
				EditorGUILayout.PropertyField(dnareplacedet, new GUIContent("DNA replacedet", "A DynamireplacedADnareplacedet contains a list of names that define the 'DNA' that will be used to modify the Avatars Skeleton. Often displayed in the UI as 'sliders'"));
				if (EditorGUI.EndChangeCheck())
				{
					UpdateDnaNames();
					serializedObject.ApplyModifiedProperties();
					serializedObject.Update();//?
					if (minimalMode)
					{
						//force the Avatar to update its dna and dnaconverter dictionaries
						umaData.umaRecipe.ClearDna();
						umaData.umaRecipe.ClearDNAConverters();
					}
				}
				//If there is no dna replacedet replacedigned show a button to make one
				if (dnareplacedet.objectReferenceValue == null)
				{
					GUILayout.BeginHorizontal();
					GUILayout.Space(EditorGUI.indentLevel * 15);
					if (GUILayout.Button(new GUIContent("Create Dynamic DNA replacedet")))
					{
						var suggestedPath = replacedetDatabase.GetreplacedetPath(target);
						var suggestedName = target.name + "DNAreplacedet";
						var path = EditorUtility.SaveFilePanelInProject("Create a new Dynamic DNA replacedet", suggestedName, "replacedet", "some message", suggestedPath);
						if (path != "")
						{
							var newDnareplacedet = CustomreplacedetUtility.Createreplacedet<DynamireplacedADnareplacedet>(path, false);
							if (newDnareplacedet != null)
							{
								//set this replacedet as the used replacedet
								dnareplacedet.objectReferenceValue = newDnareplacedet;
								serializedObject.ApplyModifiedProperties();
								createDnareplacedetName = "";
							}
							UpdateDnaNames();
							if (minimalMode)
							{
								//force the Avatar to update its dna and dnaconverter dictionaries
								umaData.umaRecipe.ClearDna();
								umaData.umaRecipe.ClearDNAConverters();
							}
						}
					}
					GUILayout.EndHorizontal();
				}
				//Otherwise show the DNA replacedets Editor
				else
				{
					if (thisDUDA == null)
					{
						thisDUDA = Editor.CreateEditor((DynamireplacedADnareplacedet)dnareplacedet.objectReferenceValue, typeof(UMA.CharacterSystem.Editors.DynamireplacedADnareplacedetEditor));
					}
					else if (thisDUDA.target != (DynamireplacedADnareplacedet)dnareplacedet.objectReferenceValue)
					{
						thisDUDA = Editor.CreateEditor((DynamireplacedADnareplacedet)dnareplacedet.objectReferenceValue, typeof(UMA.CharacterSystem.Editors.DynamireplacedADnareplacedetEditor));
					}
					EditorGUI.BeginChangeCheck();
					thisDUDA.OnInspectorGUI();
					if (EditorGUI.EndChangeCheck())
					{
						UpdateDnaNames();
					}
				}
				EditorGUI.indentLevel--;
				GUIHelper.EndVerticalPadded(3);
			}
			serializedObject.ApplyModifiedProperties();
			//===========END DNA replacedET AND EDITOR============//
			//
			EditorGUILayout.Space();
			//
			//=============CONVERTER VALUES AND EDITOR=============//
			SerializedProperty hashList = serializedObject.FindProperty("hashList");
			SerializedProperty skeletonModifiers = serializedObject.FindProperty("skeletonModifiers");
			string converterTips = "";
			if (minimalMode)
			{
				converterTips = "Skeleton Modifiers control how the values of the DNA you set above are applied to the skeleton. So for example 'Upper Weight' affects the scale of the Spine, breast, belly and shoulder bones in different ways. The best way to edit these modifiers is to set the DNA slider you want to adjust in the game view, to either its minimum or maximum position. Then add or edit a skeleton modifier in the list below to use that value to modify the skeleton. The 'Value Modifiers' part of a Skeleton Modifier, takes the incoming value, modifies it by the settings and applies it to the bone. The Min and Max values are what that result will be 'clamped' to. Avoid changing the starting 'Value' as changes to this will persist even if the dna is not itself applied (if you want to do this use the starting pose below instead).";
			}
			else
			{
				converterTips = "Skeleton Modifiers control how the values of the DNA you set above are applied to the skeleton.  So for example 'Upper Weight' affects the scale of the Spine, breast, belly and shoulder bones in different ways. Add bones you wish to make available to modify in the 'BoneHashes' section. Then add or edit a skeleton modifier in the list below to use a given dna value to modify the skeleton. The 'Value Modifiers' part of a Skeleton Modifier, takes the incoming value, modifies it by the settings and applies it to the bone. The Min and Max values are what that result will be 'clamped' to. Avoid changing the starting 'Value' as changes to this will persist even if the dna is not itself applied (if you want to do this use the starting pose below instead).";
			}
			skeletonModifiersExpanded = EditorGUILayout.Foldout(skeletonModifiersExpanded, "DNA Converter Settings", foldoutTipStyle);
			if (skeletonModifiersExpanded)
			{
				GUIHelper.BeginVerticalPadded(3, new Color(0.75f, 0.875f, 1f, 0.3f));
				if (!minimalMode)
				{
					EditorGUILayout.HelpBox("TIP: Setting up your DNA Converter's Skeleton Modifiers is much easier if you use the 'DNA Converter Bahaviour Customizer' scene as it can automatically populate the list of available bones with the ones in the generated Avatar's skeleton.", MessageType.Info);
				}
				EditorGUI.indentLevel++;
				skeletonModifiersInfoExpanded = EditorGUILayout.Foldout(skeletonModifiersInfoExpanded, "INFO");
				if (skeletonModifiersInfoExpanded)
					EditorGUILayout.HelpBox(converterTips, MessageType.Info);
				if (!minimalMode)//in minimal mode we dont need to show these because we will have a skeleton that we can get the bonehash list from
				{
					int hashListCount = hashList.arraySize;
					hashList.isExpanded = EditorGUILayout.Foldout(hashList.isExpanded, new GUIContent("Bone Hashes", "These are the bones you have identified that the converter will work on. If you use the Dynamic DNA Customizer Scene these can be set automatically when you add Modifiers") );
					if (hashList.isExpanded)
					{
						EditorGUI.indentLevel++;
						extraBonesAddDelOptsExpanded = EditorGUILayout.Foldout(extraBonesAddDelOptsExpanded, "Add/Delete Bones Options");
						EditorGUI.indentLevel--;
						if (extraBonesAddDelOptsExpanded)
						{
							//make a drop area for importing bone hashes from another DynamicDnaConverter
							var dropArea = GUILayoutUtility.GetRect(0.0f, 60.0f, GUILayout.ExpandWidth(true));
							dropArea.xMin = dropArea.xMin + (EditorGUI.indentLevel * 15);
							GUI.Box(dropArea, "Drag DynamicDNAConverterBahaviours here to import their names");//cant click to pick unfortunately because this is a prefab
							var AddMethods = new GUIContent[dnaNamesAddOpts.Count];
							for (int i = 0; i < dnaNamesAddOpts.Count; i++)
								AddMethods[i] = new GUIContent(dnaNamesAddOpts[i]);
							Rect selectedAddMethodRect = dropArea;
							selectedAddMethodRect.yMin = dropArea.yMax - EditorGUIUtility.singleLineHeight - 5;
							selectedAddMethodRect.xMin = dropArea.xMin - ((EditorGUI.indentLevel * 10) - 10);
							selectedAddMethodRect.xMax = dropArea.xMax - ((EditorGUI.indentLevel * 10) + 10);
							selectedBonesAddMethod = EditorGUI.Popup(selectedAddMethodRect, new GUIContent("On Import", "Choose whether to 'Add' the bones to the current list, or 'Replace' them with the imported  ones"), selectedBonesAddMethod, AddMethods);

							ImportConverterDropArea(dropArea, selectedBonesAddMethod, AddDNAConverterHashes);

							EditorGUILayout.Space();

							//Clear all and Add Defaults Buttons
							Rect clearAndDefaultsRect = GUILayoutUtility.GetRect(0.0f, EditorGUIUtility.singleLineHeight, GUILayout.ExpandWidth(true));
							clearAndDefaultsRect.xMin = clearAndDefaultsRect.xMin + (EditorGUI.indentLevel * 15);
							var defaultsButRect = clearAndDefaultsRect;
							var clearButRect = clearAndDefaultsRect;
							defaultsButRect.width = clearAndDefaultsRect.width / 2;
							clearButRect.xMin = defaultsButRect.xMax;
							clearButRect.width = clearAndDefaultsRect.width / 2;
							if (GUI.Button(defaultsButRect, new GUIContent("Add Default Hashes", "Adds the default bone hashes as used by UMA Human Male DNA")))
							{
								AddDefaultBoneHashes();
								//once we add these we need to update the hashnames so the dropdown has the right stuff in
								hashList.serializedObject.ApplyModifiedProperties();
								serializedObject.Update();
								UpdateHashNames();
							}
							EditorGUI.BeginDisabledGroup(hashList.arraySize == 0);
							if (GUI.Button(clearButRect, new GUIContent("Clear All Bone Hashes", "Clears the current Bone Hashes. Cannot be undone.")))
							{
								bool proceed = true;
								//if there are any skeleton modifiers that are using these bone hashes warn the user that clearing this list will break them
								if (skeletonModifiers.arraySize > 0)
									proceed = EditorUtility.DisplayDialog("Really Clear All Bone Hashes?", "This will delete all the bone hashes in the list and make any skeleton modifiers you have added not work. Are you sure?", "Yes", "Cancel");
								if (proceed)
								{
									(target as DynamicDNAConverterBehaviour).hashList = new List<DynamicDNAConverterBehaviour.HashLisreplacedem>();
									hashList.serializedObject.ApplyModifiedProperties();
									serializedObject.Update();
									UpdateHashNames();
								}
							}
							EditorGUI.EndDisabledGroup();
							EditorGUILayout.Space();
						}
						//create an add field for adding new hashes
						EditorGUILayout.BeginHorizontal();
						//var buttonDisabled = newHashName == "";
						bool canAdd = true;
						bool notFoundInSkeleton = false;
						bool didAdd = false;
						EditorGUI.BeginChangeCheck();
						newHashName = EditorGUILayout.TextField(newHashName);
						if (EditorGUI.EndChangeCheck())
						{
							if (newHashName != "" && canAdd)
							{
								//buttonDisabled = false;
							}
						}
						if (newHashName != "")
						{
							for (int ni = 0; ni < hashList.arraySize; ni++)
							{
								if (hashList.GetArrayElementAtIndex(ni).FindPropertyRelative("hashName").stringValue == newHashName)
								{
									canAdd = false;
									//buttonDisabled = true;
								}
							}
							//if we have a skeleton available we can also check that the bone the user is trying to add exists
							if (umaData)
								if (umaData.skeleton != null)
								{
									if (umaData.skeleton.HasBone(UMAUtils.StringToHash(newHashName)) == false)
									{
										canAdd = false;
										//buttonDisabled = true;
										notFoundInSkeleton = true;
									}
								}
						}
						//Dont disable because it stops looking like what you want to do, just make it do nothing if nothing is entered
						/*if (buttonDisabled)
						{
							EditorGUI.BeginDisabledGroup(true);
						}*/

						if (GUILayout.Button("Add Bone Hash"))
						{
							if (canAdd)
							{
								var newHash = UMAUtils.StringToHash(newHashName);
								(target as DynamicDNAConverterBehaviour).hashList.Insert(0, new DynamicDNAConverterBehaviour.HashLisreplacedem(newHashName, newHash));
								hashList.serializedObject.ApplyModifiedProperties();
								serializedObject.Update();
								didAdd = true;
								UpdateHashNames();
								//reset the bloody text field!
								EditorGUIUtility.keyboardControl = 0;
							}
						}
						/*if (buttonDisabled)
						{
							EditorGUI.EndDisabledGroup();
						}*/
						EditorGUILayout.EndHorizontal();
						if (canAdd == false)
						{
							if (notFoundInSkeleton == true)
							{
								EditorGUILayout.HelpBox("That name was not found in the skeleton. (Standard Bone names start with a capital letter in CamelCase)", MessageType.Warning);
							}
							else
							{
								EditorGUILayout.HelpBox("That name is already in use.", MessageType.Warning);
							}
						}
						if (didAdd)
						{
							newHashName = "";
						}

						//THE ACTUAL BONE HASH LIST
						GUIHelper.BeginVerticalPadded(3, new Color(0.75f, 0.875f, 1f, 0.3f));
						EditorGUILayout.LabelField("Bone Hash List (" + hashListCount + ")", EditorStyles.helpBox);
						//Search Bone Hashes Controls
						if (hashList.arraySize > 0)
							boneHashFilter = EditorGUILayout.TextField("Search Bones", boneHashFilter);
						EditorGUI.indentLevel++;
						if (hashList.arraySize > 0)
						{
							for (int i = 0; i < hashList.arraySize; i++)
							{
								var thisHashEl = hashList.GetArrayElementAtIndex(i);
								//Search Bone Hashes Method
								if (boneHashFilter.Length >= 3)
								{
									if (thisHashEl.displayName.IndexOf(boneHashFilter, StringComparison.CurrentCultureIgnoreCase) == -1)
										continue;
								}
								EditorGUILayout.BeginHorizontal();
								thisHashEl.isExpanded = EditorGUILayout.Foldout(thisHashEl.isExpanded, thisHashEl.displayName);
								//DeleteButton
								Rect hDelButR = EditorGUILayout.GetControlRect(false);
								hDelButR.x = hDelButR.x + hDelButR.width - 100f;
								hDelButR.width = 100f;
								if (GUI.Button(hDelButR, "Delete"))
								{
									hashList.DeleteArrayElementAtIndex(i);
									continue;
								}
								EditorGUILayout.EndHorizontal();
								if (thisHashEl.isExpanded)
								{
									EditorGUI.indentLevel++;
									string origName = thisHashEl.FindPropertyRelative("hashName").stringValue;
									string newName = origName;
									EditorGUI.BeginChangeCheck();
									newName = EditorGUILayout.TextField("Hash Name", origName);
									if (EditorGUI.EndChangeCheck())
									{
										if (newName != origName && newName != "")
										{
											thisHashEl.FindPropertyRelative("hashName").stringValue = newName;
											int newHash = UMAUtils.StringToHash(newName);
											thisHashEl.FindPropertyRelative("hash").intValue = newHash;
											serializedObject.ApplyModifiedProperties();
										}
									}
									EditorGUI.BeginDisabledGroup(true);
									EditorGUILayout.IntField("Hash", thisHashEl.FindPropertyRelative("hash").intValue);
									EditorGUI.EndDisabledGroup();
									EditorGUI.indentLevel--;
								}
							}
							hashList.serializedObject.ApplyModifiedProperties();
							EditorGUILayout.Space();
						}	
						EditorGUI.indentLevel--;
						GUIHelper.EndVerticalPadded(3);
					}
				}
				//SKELETON MODIFIERS SECTION
				skeletonModifiers.isExpanded = EditorGUILayout.Foldout(skeletonModifiers.isExpanded, "Skeleton Modifiers");
				if (skeletonModifiers.isExpanded)
				{
					//If dnaNames is null or empty show a warning
					bool showDNANamesWarning = false;
					if (serializedObject.FindProperty("dnareplacedet").objectReferenceValue == null)
						showDNANamesWarning = true;
					else if((serializedObject.FindProperty("dnareplacedet").objectReferenceValue as DynamireplacedADnareplacedet).Names.Length == 0)
						showDNANamesWarning = true;
					if(showDNANamesWarning)
						EditorGUILayout.HelpBox("You need to have your DNA Names set up above in order for the Skeleton Modifiers to make any modifications", MessageType.Warning);
					//If bone hashes is empty show a warning
					if(hashList.arraySize == 0 && !minimalMode)
						EditorGUILayout.HelpBox("You need to add the bones you want the Skeleton Modifiers to be able to modify to the 'Bone Hashes' section above.", MessageType.Warning);

					EditorGUI.indentLevel++;
					extraSkelAddDelOptsExpanded = EditorGUILayout.Foldout(extraSkelAddDelOptsExpanded, "Add/Delete Modifier Options");
					EditorGUI.indentLevel--;
					if (extraSkelAddDelOptsExpanded)
					{
						//make a drop area for importing skeletonModifiers from another DynamicDnaConverter
						var dropArea = GUILayoutUtility.GetRect(0.0f, 60.0f, GUILayout.ExpandWidth(true));
						dropArea.xMin = dropArea.xMin + (EditorGUI.indentLevel * 15);
						GUI.Box(dropArea, "Drag DynamicDNAConverterBahaviours here to import their Skeleton Modifiers");//cant click to pick unfortunately because this is a prefab
						var AddMethods = new GUIContent[dnaNamesAddOpts.Count];
						for (int i = 0; i < dnaNamesAddOpts.Count; i++)
							AddMethods[i] = new GUIContent(dnaNamesAddOpts[i]);
						Rect selectedAddMethodRect = dropArea;
						selectedAddMethodRect.yMin = dropArea.yMax - EditorGUIUtility.singleLineHeight - 5;
						selectedAddMethodRect.xMin = dropArea.xMin - ((EditorGUI.indentLevel * 10) - 10);
						selectedAddMethodRect.xMax = dropArea.xMax - ((EditorGUI.indentLevel * 10) + 10);
						selectedModifiersAddMethod = EditorGUI.Popup(selectedAddMethodRect, new GUIContent("On Import", "Choose whether to 'Add' the modifiers to the current list, or 'Replace' the modifiers with the imported list"), selectedModifiersAddMethod, AddMethods);

						ImportConverterDropArea(dropArea, selectedModifiersAddMethod, AddDNAConverterModifiers);

						//Clear all button
						GUILayout.BeginHorizontal();
						GUILayout.Space(EditorGUI.indentLevel * 15);
						EditorGUI.BeginDisabledGroup(skeletonModifiers.arraySize == 0);
						if (GUILayout.Button("Clear All Modifiers"))
						{
							if (EditorUtility.DisplayDialog("Really Clear All Modifiers?", "This will delete all the skeleton modifiers in the list and cannot be undone. Are you sure?", "Yes", "Cancel"))
							{
								(target as DynamicDNAConverterBehaviour).skeletonModifiers = new List<DynamicDNAConverterBehaviour.SkeletonModifier>();
								skeletonModifiers.serializedObject.ApplyModifiedProperties();
								serializedObject.Update();
							}
						}
						EditorGUI.EndDisabledGroup();
						GUILayout.EndHorizontal();
						EditorGUILayout.Space();
					}


					//Add new Skeleton Modifier UI
					Rect addSkelButsR = EditorGUILayout.GetControlRect(false);
					var addSkelLabel = addSkelButsR;
					var addSkelBone = addSkelButsR;
					var addSkelProp = addSkelButsR;
					var addSkelAddBut = addSkelButsR;
					addSkelLabel.width = 100;
					addSkelAddBut.width = 70;
					addSkelBone.width = addSkelProp.width = (addSkelButsR.width - (addSkelLabel.width + (addSkelAddBut.width + 5))) / 2;
					addSkelBone.x = addSkelLabel.xMax;
					addSkelProp.x = addSkelBone.xMax;
					addSkelAddBut.x = addSkelProp.xMax + 5;
					EditorGUI.LabelField(addSkelLabel, new GUIContent("Add Modifier", "Add a modifier for the selected bone in the skeleton, that will modify its 'Position', 'Rotation' or 'Scale'"));
					EditorGUI.indentLevel--;
					List<string> thisBoneNames = new List<string>(0);
					//string[] boneNames = new string[0];
					/*if(minimalMode == false)
					{
						bonesInSkeleton = new List<string>( hashNames.ToArray());
					}
					else
					{
						bonesInSkeleton = new List<string>(umaData.skeleton.BoneNames);
					}
					bonesInSkeleton.Sort();*/
					//Array.Sort(boneNames);
					thisBoneNames = new List<string>(bonesInSkeleton);
					thisBoneNames.Insert(0, "Choose Bone");

					EditorGUI.BeginChangeCheck();
					selectedAddHash = EditorGUI.Popup(addSkelBone, selectedAddHash, thisBoneNames.ToArray());
					string[] propertyArray = new string[] { "Position", "Rotation", "Scale" };
					selectedAddProp = EditorGUI.Popup(addSkelProp, selectedAddProp, propertyArray);
					if (EditorGUI.EndChangeCheck())
					{
						if (selectedAddHash > 0)
						{
							addSkelBoneName = thisBoneNames[selectedAddHash];
							addSkelBoneHash = UMAUtils.StringToHash(addSkelBoneName);
						}
						else
						{
							addSkelBoneName = "";
							addSkelBoneHash = 0;
							canAddSkel = false;
						}
					}
					if (addSkelBoneName != "" && addSkelBoneHash != 0)
					{
						canAddSkel = true;
						alreadyExistedSkel = false;
						//we need to check if there is already a modifier for that bone for the selected property
						for (int i = 0; i < skeletonModifiers.arraySize; i++)
						{
							var thisSkelMod = skeletonModifiers.GetArrayElementAtIndex(i);
							if (thisSkelMod.FindPropertyRelative("property").enumValueIndex == selectedAddProp && thisSkelMod.FindPropertyRelative("hash").intValue == addSkelBoneHash)
							{
								canAddSkel = false;
								alreadyExistedSkel = true;
							}
						}
					}
					if (canAddSkel == false)
					{
						EditorGUI.BeginDisabledGroup(true);
					}
					if (GUI.Button(addSkelAddBut, "Add It!"))
					{
						if (minimalMode)
						{
							if (!hashes.Contains(addSkelBoneHash))
							{
								(target as DynamicDNAConverterBehaviour).hashList.Insert(0, new DynamicDNAConverterBehaviour.HashLisreplacedem(addSkelBoneName, addSkelBoneHash));
								hashList.serializedObject.ApplyModifiedProperties();
								serializedObject.Update();
								UpdateHashNames();
							}
						}
						(target as DynamicDNAConverterBehaviour).skeletonModifiers.Insert(0, new DynamicDNAConverterBehaviour.SkeletonModifier(addSkelBoneName, addSkelBoneHash, (DynamicDNAConverterBehaviour.SkeletonModifier.SkeletonPropType)selectedAddProp));
						skeletonModifiers.serializedObject.ApplyModifiedProperties();
						serializedObject.Update();
						addSkelBoneHash = 0;
						addSkelBoneName = "";
						selectedAddHash = 0;
						EditorGUIUtility.keyboardControl = 0;
					}
					if (canAddSkel == false)
					{
						EditorGUI.EndDisabledGroup();
					}
					if (alreadyExistedSkel == true)
					{
						EditorGUILayout.HelpBox("There was already a modifier for that bone with that property. You can serach the existing modifiers to find it.", MessageType.Warning);
					}
					EditorGUI.indentLevel++;
					//Search Filters Controls- dont show if we dont have any modifiers
					EditorGUILayout.Space();

					//THE ACTUAL MODIFIER LIST
					GUIHelper.BeginVerticalPadded(3, new Color(0.75f, 0.875f, 1f, 0.3f));
					EditorGUILayout.LabelField("Skeleton Modifiers (" + skeletonModifiers.arraySize + ")", EditorStyles.helpBox);
					if (skeletonModifiers.arraySize > 0)
					{
						Rect searchR = EditorGUILayout.GetControlRect();
						var searchL = searchR;
						var searchF = searchR;
						var searchTL = searchR;
						var searchTF = searchR;
						searchL.width = 130;
						searchF.width = (searchR.width / 3) * 2 - searchL.width;
						searchF.x = searchR.x + searchL.width;
						searchTL.width = 35;
						searchTL.x = searchF.xMax;
						searchTF.width = (searchR.width / 3) - searchTL.width + (EditorGUI.indentLevel * 15);
						searchTF.x = searchTL.xMax - (EditorGUI.indentLevel * 15);
						EditorGUI.LabelField(searchL, "Search Modifiers");
						EditorGUI.indentLevel--;
						skeletonModifiersFilter = EditorGUI.TextField(searchF, skeletonModifiersFilter);
						EditorGUI.LabelField(searchTL, "By");
						skeletonModifiersFilterType = EditorGUI.Popup(searchTF, skeletonModifiersFilterType, skeletonModifiersFilterTypeList);
						EditorGUI.indentLevel++;
					}
					EditorGUI.indentLevel++;
					for (int i = 0; i < skeletonModifiers.arraySize; i++)
					{
						var thisSkelEl = skeletonModifiers.GetArrayElementAtIndex(i);
						//Search Filters Method
						if (skeletonModifiersFilterTypeList[skeletonModifiersFilterType] != "DNA")
						{
							if (skeletonModifiersFilterType == 1 || skeletonModifiersFilterType == 2 || skeletonModifiersFilterType == 3)
							{
								string thisProperty = thisSkelEl.FindPropertyRelative("property").enumNames[thisSkelEl.FindPropertyRelative("property").enumValueIndex];
								if (skeletonModifiersFilterType == 1)//Position Modifiers
								{
									if (thisProperty.IndexOf("position", StringComparison.CurrentCultureIgnoreCase) == -1)
										continue;
								}
								else if (skeletonModifiersFilterType == 2)//Rotation Modifiers
								{
									if (thisProperty.IndexOf("rotation", StringComparison.CurrentCultureIgnoreCase) == -1)
										continue;
								}
								else if (skeletonModifiersFilterType == 3)//scale Modifiers
								{
									if (thisProperty.IndexOf("scale", StringComparison.CurrentCultureIgnoreCase) == -1)
										continue;
								}
							}
							else if (skeletonModifiersFilterType == 5)//Adjust Bones
							{
								if (thisSkelEl.displayName.IndexOf("adjust", StringComparison.CurrentCultureIgnoreCase) == -1)
									continue;
							}
							else if (skeletonModifiersFilterType == 6)//Non Adjust Bones
							{
								if (thisSkelEl.displayName.IndexOf("adjust", StringComparison.CurrentCultureIgnoreCase) > -1)
									continue;
							}
						}
						if (skeletonModifiersFilter.Length >= 3)
						{
							if (skeletonModifiersFilterTypeList[skeletonModifiersFilterType] != "DNA")
							{
								if (thisSkelEl.displayName.IndexOf(skeletonModifiersFilter, StringComparison.CurrentCultureIgnoreCase) == -1)
									continue;
							}
							else //Searches for Modifiers that use a given DNA Value- slow but super handy
							{
								string[] XYZ = new string[] { "X", "Y", "Z" };
								SerializedProperty mods;
								SerializedProperty thisMod;
								int modsi;
								bool _continue = true;
								foreach (string xyz in XYZ)
								{
									mods = thisSkelEl.FindPropertyRelative("values" + xyz).FindPropertyRelative("val").FindPropertyRelative("modifiers");
									for (int mi = 0; mi < mods.arraySize; mi++)
									{
										thisMod = mods.GetArrayElementAtIndex(mi);
										modsi = thisMod.FindPropertyRelative("modifier").enumValueIndex;
										if (modsi > 3)
										{
											if (thisMod.FindPropertyRelative("DNATypeName").stringValue.IndexOf(skeletonModifiersFilter, StringComparison.CurrentCultureIgnoreCase) > -1)
												_continue = false;
										}
									}
								}
								if (_continue)
								{
									continue;
								}
							}
						}
						Rect currentRect = EditorGUILayout.GetControlRect(false, _skelModPropDrawer.GetPropertyHeight(thisSkelEl, GUIContent.none));
						//Delete button
						Rect sDelButR = currentRect;
						sDelButR.x = sDelButR.x + sDelButR.width - 100f;
						sDelButR.width = 100f;
						sDelButR.height = EditorGUIUtility.singleLineHeight;
						if (GUI.Button(sDelButR, "Delete"))
						{
							skeletonModifiers.DeleteArrayElementAtIndex(i);
							continue;
						}
						Rect thisSkelRect = new Rect(currentRect.xMin, currentRect.yMin, currentRect.width, _skelModPropDrawer.GetPropertyHeight(thisSkelEl, GUIContent.none));
						_skelModPropDrawer.OnGUI(thisSkelRect, thisSkelEl, new GUIContent(thisSkelEl.displayName));
					}
					GUIHelper.EndVerticalPadded(3);
					EditorGUI.indentLevel--;
					//we want to discourage users from using the starting values to customise their models (if they have any modifiers set up
					if (skeletonModifiers.arraySize > 0)
					{
						_skelModPropDrawer.enableSkelModValueEditing = enableSkelModValueEditing = EditorGUILayout.ToggleLeft("Enable editing of starting Value (not reccommended)", enableSkelModValueEditing);
						//and make it easy to set the starting values back to the defaults
						GUILayout.BeginHorizontal();
						GUILayout.Space(EditorGUI.indentLevel * 15);
						if (GUILayout.Button("Reset All Starting Values to Default"))
						{
							for (int i = 0; i < skeletonModifiers.arraySize; i++)
							{
								var thisSkeModProp = skeletonModifiers.GetArrayElementAtIndex(i).FindPropertyRelative("property").enumNames[skeletonModifiers.GetArrayElementAtIndex(i).FindPropertyRelative("property").enumValueIndex];
								if (thisSkeModProp != "")
								{
									if (thisSkeModProp == "Position" || thisSkeModProp == "Rotation")
									{
										skeletonModifiers.GetArrayElementAtIndex(i).FindPropertyRelative("valuesX").FindPropertyRelative("val").FindPropertyRelative("value").floatValue = 0f;
										skeletonModifiers.GetArrayElementAtIndex(i).FindPropertyRelative("valuesY").FindPropertyRelative("val").FindPropertyRelative("value").floatValue = 0f;
										skeletonModifiers.GetArrayElementAtIndex(i).FindPropertyRelative("valuesZ").FindPropertyRelative("val").FindPropertyRelative("value").floatValue = 0f;
									}
									if (thisSkeModProp == "Scale")
									{
										skeletonModifiers.GetArrayElementAtIndex(i).FindPropertyRelative("valuesX").FindPropertyRelative("val").FindPropertyRelative("value").floatValue = 1f;
										skeletonModifiers.GetArrayElementAtIndex(i).FindPropertyRelative("valuesY").FindPropertyRelative("val").FindPropertyRelative("value").floatValue = 1f;
										skeletonModifiers.GetArrayElementAtIndex(i).FindPropertyRelative("valuesZ").FindPropertyRelative("val").FindPropertyRelative("value").floatValue = 1f;
									}
								}
							}
							skeletonModifiers.serializedObject.ApplyModifiedProperties();
						}
						GUILayout.EndHorizontal();
					}
					EditorGUILayout.Space();
				}
				EditorGUILayout.Space();
				serializedObject.FindProperty("overallModifiersEnabled").boolValue = EditorGUILayout.ToggleLeft("Enable Overall Modifiers", serializedObject.FindProperty("overallModifiersEnabled").boolValue);
				SerializedProperty overallModifiersEnabledProp = serializedObject.FindProperty("overallModifiersEnabled");
				bool overallModifiersEnabled = overallModifiersEnabledProp.boolValue;
				if (overallModifiersEnabled)
				{
					EditorGUI.BeginChangeCheck();
					EditorGUILayout.PropertyField(serializedObject.FindProperty("overallScale"));
					EditorGUILayout.PropertyField(serializedObject.FindProperty("tightenBounds"));
					EditorGUILayout.PropertyField(serializedObject.FindProperty("boundsAdjust"));
					//EditorGUILayout.PropertyField(serializedObject.FindProperty("heightModifiers"));
					EditorGUILayout.PropertyField(serializedObject.FindProperty("radiusAdjust"));
					EditorGUILayout.PropertyField(serializedObject.FindProperty("mreplacedModifiers"));
					if (EditorGUI.EndChangeCheck())
					{
						serializedObject.ApplyModifiedProperties();
					}
				}
				EditorGUI.indentLevel--;
				GUIHelper.EndVerticalPadded(3);
			}
			serializedObject.ApplyModifiedProperties();
			//===========END CONVERTER VALUES AND EDITOR============//
			//
			EditorGUILayout.Space();
			//
			//===========BONEPOSE replacedET AND EDITOR===========//
			startingPoseExpanded = EditorGUILayout.Foldout(startingPoseExpanded, "Starting Pose", foldoutTipStyle);
			if (startingPoseExpanded)
			{
				GUIHelper.BeginVerticalPadded(3, new Color(0.75f, 0.875f, 1f, 0.3f));
				EditorGUI.indentLevel++;
				startingPoseInfoExpanded = EditorGUILayout.Foldout(startingPoseInfoExpanded, "INFO");
				if (startingPoseInfoExpanded)
					EditorGUILayout.HelpBox("The 'Starting Pose'is the initial position/rotation/scale of all the bones in this Avatar's skeleton. Use this to completely transform the mesh of your character. You could (for example) transform standard UMA characters into a backwards compatible 'Short Squat Dwarf' or a 'Bobble- headded Toon'. Optionally, you can create an UMABonePose replacedet from an FBX model using the UMA > Pose Tools > Bone Pose Builder and add the resulting replacedet here. After you have added or created a UMABonePose replacedet, you can add and edit the position, rotation and scale settings for any bone in the active character's skeleton in the 'Bone Poses' section.'.", MessageType.Info);
				EditorGUI.BeginChangeCheck();
				EditorGUILayout.PropertyField(serializedObject.FindProperty("startingPose"), new GUIContent("Starting UMABonePose", "Define an replacedet that will set the starting bone poses of any Avatar using this converter"));
				if (EditorGUI.EndChangeCheck())
				{
					serializedObject.ApplyModifiedProperties();
					//If this gets set we need to back it up
					thisDDCC.BackupConverter();
				}
				//Draw the poses array from the replacedet if set or show controls to create a new replacedet.
				SerializedProperty bonePosereplacedet = serializedObject.FindProperty("startingPose");
				if (bonePosereplacedet.objectReferenceValue != null)
				{
					EditorGUILayout.PropertyField(serializedObject.FindProperty("startingPoseWeight"));
					if (thisUBP == null)
					{
						thisUBP = Editor.CreateEditor((UMA.PoseTools.UMABonePose)bonePosereplacedet.objectReferenceValue, typeof(UMA.PoseTools.UMABonePoseEditor));
						((UMA.PoseTools.UMABonePoseEditor)thisUBP).dynamicDNAConverterMode = true;
						if (umaData != null)
						{
							((UMA.PoseTools.UMABonePoseEditor)thisUBP).context = new UMA.PoseTools.UMABonePoseEditorContext();
							((UMA.PoseTools.UMABonePoseEditor)thisUBP).context.activeUMA = umaData;
						}
					}
					else if (thisUBP.target != (UMA.PoseTools.UMABonePose)bonePosereplacedet.objectReferenceValue)
					{
						thisUBP = Editor.CreateEditor((UMA.PoseTools.UMABonePose)bonePosereplacedet.objectReferenceValue, typeof(UMA.PoseTools.UMABonePoseEditor));
						((UMA.PoseTools.UMABonePoseEditor)thisUBP).dynamicDNAConverterMode = true;
						if (umaData != null)
						{
							((UMA.PoseTools.UMABonePoseEditor)thisUBP).context = new UMA.PoseTools.UMABonePoseEditorContext();
							((UMA.PoseTools.UMABonePoseEditor)thisUBP).context.activeUMA = umaData;
						}
					}
					EditorGUI.BeginChangeCheck();
					thisUBP.OnInspectorGUI();
					if (EditorGUI.EndChangeCheck())
					{
						//Currently we dont need to do anything here as the change is picked up by DynamicDNAConverterCustomizer an this triggers an UMA update
						//this may change though if we have a method in future for modifying the TPose
					}
				}
				else
				{
					if (thisDDCC != null)
					{
						var createPosereplacedetR = EditorGUILayout.GetControlRect(false);
						var createPosereplacedetRLabel = createPosereplacedetR;
						var createPosereplacedetRField = createPosereplacedetR;
						var createPosereplacedetRButton = createPosereplacedetR;
						createPosereplacedetRLabel.width = createPosereplacedetRLabel.width / 3 + 7;
						createPosereplacedetRButton.width = 70f;
						createPosereplacedetRField.width = ((createPosereplacedetRField.width / 3) * 2) - 82;
						createPosereplacedetRField.x = createPosereplacedetRLabel.xMax;
						createPosereplacedetRButton.x = createPosereplacedetRField.xMax + 5;
						EditorGUI.LabelField(createPosereplacedetRLabel, new GUIContent("New BonePose replacedet", "Create a new empty UMABonePose with the name of your choosing."));
						createBonePosereplacedetName = EditorGUI.TextField(createPosereplacedetRField, createBonePosereplacedetName);
						if (GUI.Button(createPosereplacedetRButton, "Create It"))//need to do the button enabled thing here
						{
							var newDnareplacedet = thisDDCC.CreatePosereplacedet("", createBonePosereplacedetName);
							if (newDnareplacedet != null)
							{
								//set this replacedet as the used replacedet
								bonePosereplacedet.objectReferenceValue = newDnareplacedet;
								serializedObject.ApplyModifiedProperties();
								createBonePosereplacedetName = "";
							}
						}
					}
					else
					{
						EditorGUILayout.HelpBox("Edit a character that uses this converter in the 'DynamicDna Converter Behaviour Customizer' scene and you can create a StartingPosereplacedet automatically here", MessageType.Info);
					}
				}
				if (minimalMode && umaData.skeleton != null && bonePosereplacedet.objectReferenceValue == null)
				{
					EditorGUILayout.Space();
					EditorGUILayout.LabelField("Create Poses from Current DNA state");
					EditorGUILayout.HelpBox("Create bone poses from Avatar's current dna modified state. Applies the pose and sets DNA values back to 0. Smaller margin of error equals greater accuracy but more poses to apply on DNA Update.", MessageType.Info);
					if (thisDDCC != null)
					{
						//[Range(0.000005f, 0.0005f)]
						EditorGUI.BeginChangeCheck();
						var thisAccuracy = EditorGUILayout.Slider(new GUIContent("Margin Of Error","The smaller the margin of error, the more accurate the Pose will be, but it will also have more bonePoses to apply when DNA is updated"), thisDDCC.bonePoseAccuracy * 1000, 0.5f, 0.005f);
						if (EditorGUI.EndChangeCheck())
						{
							thisDDCC.bonePoseAccuracy = thisAccuracy / 1000;
							GUI.changed = false;
						}
					}
					GUILayout.BeginHorizontal();
					GUILayout.Space(EditorGUI.indentLevel * 20);
					if (GUILayout.Button(/*createFromDnaButR, */"Create Poses"))
					{
						if (thisDDCC != null)
						{
							if (thisDDCC.CreateBonePosesFromCurrentDna(createBonePosereplacedetName))
							{
								serializedObject.Update();
							}
						}
					}
					GUILayout.EndHorizontal();

				}
				EditorGUI.indentLevel--;
				GUIHelper.EndVerticalPadded(3);
			}
			serializedObject.ApplyModifiedProperties();
			//=============END BONEPOSE replacedET AND EDITOR============//
			//
			EditorGUILayout.Space();

		}

19 Source : UMAPackedRecipeBase.cs
with Apache License 2.0
from A7ocin

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].replacedet.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 //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;
		}

19 Source : UMAPhysicsAvatar.cs
with Apache License 2.0
from A7ocin

public void UpdateClothColliders()
		{
			if (_umaData) 
			{
				foreach (Renderer renderer in _umaData.GetRenderers()) 
				{
					Cloth cloth = renderer.GetComponent<Cloth> ();
					if (cloth) 
					{
                        cloth.sphereColliders = SphereColliders.ToArray();
                        cloth.capsuleColliders = CapsuleColliders.ToArray();
                        if ((cloth.capsuleColliders.Length + cloth.sphereColliders.Length) > 10)
                            Debug.LogWarning("Cloth Collider count is high. You might experience strange behavior with the cloth simulation.");
					}
				}
			}
		}

19 Source : CodeGenTemplate.cs
with Apache License 2.0
from A7ocin

public static CodeGenTemplate[] ParseTemplates(string sourceDir, string pageTemplate)
		{
			List<CodeGenTemplate> res = new List<CodeGenTemplate>();
			foreach (var line in pageTemplate.Split('\r', '\n'))
			{
				if (line.StartsWith("//#TEMPLATE "))
				{
					var parsedLine = line.Split(' ');
					if (parsedLine.Length >= 3)
					{
						var filename = Path.Combine(sourceDir, parsedLine[2]);
						var tag = parsedLine.Length > 3 ? parsedLine[3] : "";
						if (!File.Exists(filename))
						{
							Debug.LogError("File not found: " + filename);
						}
						res.Add(new CodeGenTemplate() { Format = FileUtils.ReadAllText(filename), sb = new StringBuilder(), Name = parsedLine[1], Tag = tag });
					}
				}
			}
			return res.ToArray();
		}

19 Source : UMABonePoseEditor.cs
with Apache License 2.0
from A7ocin

public override void OnInspectorGUI()
        {
            serializedObject.Update();
			SerializedProperty poses = serializedObject.FindProperty("poses");

			if (doBoneAdd)
			{
				int addedIndex = poses.arraySize;
				poses.InsertArrayElementAtIndex(addedIndex);
				var pose = poses.GetArrayElementAtIndex(addedIndex);
				SerializedProperty bone = pose.FindPropertyRelative("bone");
				bone.stringValue = addBoneName;
				SerializedProperty hash = pose.FindPropertyRelative("hash");
				hash.intValue = UMASkeleton.StringToHash(addBoneName);
				SerializedProperty position = pose.FindPropertyRelative("position");
				position.vector3Value = Vector3.zero;
				SerializedProperty rotation = pose.FindPropertyRelative("rotation");
				rotation.quaternionValue = Quaternion.idenreplacedy;
				SerializedProperty scale = pose.FindPropertyRelative("scale");
				scale.vector3Value = Vector3.one;

				activeBoneIndex = BAD_INDEX;
				editBoneIndex = BAD_INDEX;
				mirrorBoneIndex = BAD_INDEX;
				addBoneIndex = 0;
				addBoneName = "";
				doBoneAdd = false;
			}
			if (doBoneRemove)
			{
				poses.DeleteArrayElementAtIndex(removeBoneIndex - 1);

				activeBoneIndex = BAD_INDEX;
				editBoneIndex = BAD_INDEX;
				mirrorBoneIndex = BAD_INDEX;
				removeBoneIndex = 0;
				doBoneRemove = false;
			}

			// HACK
			if (!dynamicDNAConverterMode)
			{
				sourceUMA = EditorGUILayout.ObjectField("Source UMA", sourceUMA, typeof(UMAData), true) as UMAData;
				if (sourceUMA != null)
				{
					if (context == null)
					{
						context = new UMABonePoseEditorContext();
					}
					if (context.activeUMA != sourceUMA)
					{
						context.activeUMA = sourceUMA;
					}
				}
			}

			// Weight of pose on preview model
			if (haveValidContext && !dynamicDNAConverterMode)
			{
				EditorGUILayout.BeginHorizontal();
				GUILayout.Space(addRemovePadding);
				EditorGUI.BeginDisabledGroup(haveEditTarget);
				previewWeight = EditorGUILayout.Slider(previewGUIContent, previewWeight, 0f, 1f);
				EditorGUI.EndDisabledGroup();
				GUILayout.Space(addRemovePadding);
				EditorGUILayout.EndHorizontal();
			}

			GUILayout.Space(EditorGUIUtility.singleLineHeight / 2f);

//			string controlName = GUI.GetNameOfFocusedControl();
//			if ((controlName != null) && (controlName.Length > 0))
//				Debug.Log(controlName);

			// These can get corrupted by undo, so just rebuild them
			string[] removeBoneOptions = new string[targetPose.poses.Length + 1];
			removeBoneOptions[0] = " ";
			for (int i = 0; i < targetPose.poses.Length; i++)
			{
				removeBoneOptions[i + 1] = targetPose.poses[i].bone;
			}
			string[] addBoneOptions = new string[1];
			if (haveValidContext)
			{
				List<string> addList = new List<string>(context.boneList);
				addList.Insert(0, " ");
				for (int i = 0; i < targetPose.poses.Length; i++)
				{
					addList.Remove(targetPose.poses[i].bone);
				}

				addBoneOptions = addList.ToArray();
			}

			// List of existing bones
			poses.isExpanded = EditorGUILayout.Foldout(poses.isExpanded, "Pose Bones ("+poses.arraySize+")");
			if (poses.isExpanded)
			{
				for (int i = 0; i < poses.arraySize; i++)
				{
					SerializedProperty pose = poses.GetArrayElementAtIndex(i);
					drawBoneIndex = i;
					PoseBoneDrawer(pose);
				}
			}

			GUILayout.Space(EditorGUIUtility.singleLineHeight);

			// Controls for adding a new bone
			EditorGUILayout.BeginHorizontal();
			GUILayout.Space(addRemovePadding);
			if (haveValidContext)
			{
				EditorGUI.BeginDisabledGroup(addBoneIndex < 1);
				if (GUILayout.Button(addBoneGUIContent, GUILayout.Width(90f)))
				{
					addBoneName = addBoneOptions[addBoneIndex];
					doBoneAdd = true;
				}
				EditorGUI.EndDisabledGroup();

				EditorGUILayout.BeginVertical();
				GUILayout.Space(buttonVerticalOffset);
				addBoneIndex = EditorGUILayout.Popup(addBoneIndex, addBoneOptions);
				EditorGUILayout.EndVertical();
			}
			else
			{
				EditorGUI.BeginDisabledGroup(addBoneName.Length < minBoneNameLength);
				if (GUILayout.Button(addBoneGUIContent, GUILayout.Width(90f)))
				{
					doBoneAdd = true;
				}
				EditorGUI.EndDisabledGroup();

				EditorGUILayout.BeginVertical();
				GUILayout.Space(buttonVerticalOffset);
				addBoneName = EditorGUILayout.TextField(addBoneName);
				EditorGUILayout.EndVertical();
			}
			GUILayout.Space(addRemovePadding);
			EditorGUILayout.EndHorizontal();

			// Controls for removing existing bone
			EditorGUILayout.BeginHorizontal();
			GUILayout.Space(addRemovePadding);
			EditorGUI.BeginDisabledGroup(removeBoneIndex < 1);
			if (GUILayout.Button(removeBoneGUIContent, GUILayout.Width(90f)))
			{
				doBoneRemove = true;
			}
			EditorGUI.EndDisabledGroup();
			EditorGUILayout.BeginVertical();
			GUILayout.Space(buttonVerticalOffset);
			removeBoneIndex = EditorGUILayout.Popup(removeBoneIndex, removeBoneOptions);
			EditorGUILayout.EndVertical();
			GUILayout.Space(addRemovePadding);
			EditorGUILayout.EndHorizontal();

            serializedObject.ApplyModifiedProperties();
        }

19 Source : DynamicUMADna.cs
with Apache License 2.0
from A7ocin

void ValidateValues(string[] requiredNames)
        {
            List<float> newValues = new List<float>(requiredNames.Length);
            for (int i = 0; i < requiredNames.Length; i++)
            {
                bool valueFound = false;
				var currentNames = _names.Length > 0 ? _names : new string[0];
				for (int ii = 0; ii < currentNames.Length; ii++)
                {
                    if (currentNames[ii] == requiredNames[i])
                    {
                        newValues.Insert(i, Values[ii]);
                        valueFound = true;
                        break;
                    }
                }
                if (valueFound == false)
                {
                    newValues.Insert(i, 0.5f);
                }
            }
            _names = requiredNames;
            _values = newValues.ToArray();
        }

19 Source : FsmUtil.cs
with GNU General Public License v3.0
from a2659802

public static void InsertAction(PlayMakerFSM fsm, string stateName, FsmStateAction action, int index)
        {
            foreach (FsmState t in fsm.FsmStates)
            {
                if (t.Name != stateName) continue;
                List<FsmStateAction> actions = t.Actions.ToList();

                actions.Insert(index, action);

                t.Actions = actions.ToArray();
                
                action.Init(t);
            }
        }

19 Source : FsmUtil.cs
with GNU General Public License v3.0
from a2659802

public static void AddTransition(PlayMakerFSM fsm, string stateName, string eventName, string toState)
        {
            foreach (FsmState t in fsm.FsmStates)
            {
                if (t.Name != stateName) continue;
                List<FsmTransition> transitions = t.Transitions.ToList();
                transitions.Add(new FsmTransition
                {
                    FsmEvent = new FsmEvent(eventName),
                    ToState = toState
                });
                t.Transitions = transitions.ToArray();
            }
        }

19 Source : SerialBusManager.cs
with GNU General Public License v3.0
from a4004

private static string[] GetDeviceNames(string[] comPorts)
        {
            List<string> names = new List<string>();

            foreach (string port in comPorts)
                names.Add(GetDeviceName(port));

            return names.ToArray();
        }

19 Source : DynamicDnaConverterCustomizerEditor.cs
with Apache License 2.0
from A7ocin

public override void OnInspectorGUI()
        {
            thisDDCC = target as DynamicDNAConverterCustomizer;
            serializedObject.Update();
            EditorGUILayout.PropertyField(serializedObject.FindProperty("dynamicDnaConverterPrefab"));
            EditorGUILayout.PropertyField(serializedObject.FindProperty("TposeAnimatorController"));
            EditorGUILayout.PropertyField(serializedObject.FindProperty("AposeAnimatorController"));
            EditorGUILayout.PropertyField(serializedObject.FindProperty("MovementAnimatorController"));
            if (Application.isPlaying)
            {
                EditorGUILayout.BeginHorizontal();
                if (serializedObject.FindProperty("TposeAnimatorController").objectReferenceValue != null)
                {
                    if (GUILayout.Button("Set T-Pose"))
                    {
                        thisDDCC.SetTPoseAni();
                    }
                }
                if (serializedObject.FindProperty("AposeAnimatorController").objectReferenceValue != null)
                {
                    if (GUILayout.Button("Set A-Pose"))
                    {
                        thisDDCC.SetAPoseAni();
                    }
                }
                if (serializedObject.FindProperty("MovementAnimatorController").objectReferenceValue != null)
                {
                    if (GUILayout.Button("Animate UMA"))
                    {
                        thisDDCC.SetMovementAni();
                    }
                }
                EditorGUILayout.EndHorizontal();
            }
            EditorGUILayout.Space();
            EditorGUILayout.PropertyField(serializedObject.FindProperty("targetUMA"));
            EditorGUILayout.PropertyField(serializedObject.FindProperty("guideUMA"));
            if(serializedObject.FindProperty("guideUMA").objectReferenceValue != null && Application.isPlaying)
            {
                EditorGUILayout.BeginHorizontal();
                if (GUILayout.Button("Align Guide To Target"))
                {
                    thisDDCC.AlignGuideToTarget();
                }
                if (GUILayout.Button("Import Guide DNA Values"))
                {
                    thisDDCC.ImportGuideDNAValues();
                }
                EditorGUILayout.EndHorizontal();
            }
            if (Application.isPlaying)
            {
                SerializedProperty availableConvertersProp = serializedObject.FindProperty("availableConverters");
                SerializedProperty selectedConverterProp = serializedObject.FindProperty("selectedConverter");
                List<string> availableConvertersPopup = new List<string>();
                availableConvertersPopup.Add("None Selected");
                int selectedConverterIndex = 0;
                int newSelectedConverterIndex = 0;
                for (int i = 0; i < availableConvertersProp.arraySize; i++)
                {
                    availableConvertersPopup.Add(availableConvertersProp.GetArrayElementAtIndex(i).objectReferenceValue.name);
                    if (selectedConverterProp.objectReferenceValue != null)
                        if (availableConvertersProp.GetArrayElementAtIndex(i).objectReferenceValue.name == selectedConverterProp.objectReferenceValue.name)
                        {
                            selectedConverterIndex = i + 1;
                        }
                }
                EditorGUILayout.Space();
                EditorGUI.BeginChangeCheck();
                newSelectedConverterIndex = EditorGUILayout.Popup("Target UMA Converter", selectedConverterIndex, availableConvertersPopup.ToArray());
                if (EditorGUI.EndChangeCheck())
                {
                    if (newSelectedConverterIndex != selectedConverterIndex)
                    {
                        if (newSelectedConverterIndex == 0)
                        {
                            selectedConverterProp.objectReferenceValue = null;
                        }
                        else
                        {
                            selectedConverterProp.objectReferenceValue = availableConvertersProp.GetArrayElementAtIndex(newSelectedConverterIndex - 1).objectReferenceValue;
                        }
                        serializedObject.ApplyModifiedProperties();
                        thisDDCC.BackupConverter();
                    }
                }
            }
            if (serializedObject.FindProperty("selectedConverter").objectReferenceValue != null)
            {
				thisDDCC.StartListeningForUndo();
                GUIHelper.BeginVerticalPadded(10, new Color(0.75f, 0.875f, 1f));
                EditorGUILayout.LabelField("Import Settings from another Converter", EditorStyles.boldLabel);
                var ImportFromConverterR = EditorGUILayout.GetControlRect(false);
                var ImportFromConverterLabelR = ImportFromConverterR;
                var ImportFromConverterFieldR = ImportFromConverterR;
                var ImportFromConverterButR = ImportFromConverterR;
                ImportFromConverterLabelR.width = 140;
                ImportFromConverterButR.width = 70;
                ImportFromConverterFieldR.width = ImportFromConverterFieldR.width - ImportFromConverterLabelR.width - ImportFromConverterButR.width;
                ImportFromConverterFieldR.x = ImportFromConverterLabelR.xMax;
                ImportFromConverterButR.x = ImportFromConverterFieldR.xMax + 5;
                EditorGUI.LabelField(ImportFromConverterLabelR, "Import from Converter");
                EditorGUI.ObjectField(ImportFromConverterFieldR, serializedObject.FindProperty("converterToImport"), GUIContent.none);
                if (serializedObject.FindProperty("converterToImport").objectReferenceValue == null)
                    EditorGUI.BeginDisabledGroup(true);
                if(GUI.Button(ImportFromConverterButR, "Import"))
                {
                    if (thisDDCC.ImportConverterValues())
                    {
                        serializedObject.FindProperty("converterToImport").objectReferenceValue = null;
                    }
                }
                if (serializedObject.FindProperty("converterToImport").objectReferenceValue == null)
                    EditorGUI.EndDisabledGroup();
                GUIHelper.EndVerticalPadded(10);
                //
                Editor thisSDCB;
                if(SDCBs.TryGetValue((DynamicDNAConverterBehaviour)serializedObject.FindProperty("selectedConverter").objectReferenceValue, out thisSDCB))
                {
                    ((DynamicDNAConverterBehaviourEditor)thisSDCB).initialized = true;
                }
                else
                {
                    thisSDCB = Editor.CreateEditor((DynamicDNAConverterBehaviour)serializedObject.FindProperty("selectedConverter").objectReferenceValue, typeof(DynamicDNAConverterBehaviourEditor));
                    SDCBs.Add((DynamicDNAConverterBehaviour)serializedObject.FindProperty("selectedConverter").objectReferenceValue, thisSDCB);
                }
                ((DynamicDNAConverterBehaviourEditor)thisSDCB).minimalMode = true;
                ((DynamicDNAConverterBehaviourEditor)thisSDCB).thisDDCC = thisDDCC;
                ((DynamicDNAConverterBehaviourEditor)thisSDCB).umaData = thisDDCC.targetUMA.umaData;
                GUIHelper.BeginVerticalPadded(10, new Color(0.75f, 0.875f, 1f));
                EditorGUILayout.LabelField("Edit Values", EditorStyles.boldLabel);
                EditorGUI.BeginChangeCheck();
                thisSDCB.OnInspectorGUI();
                if (EditorGUI.EndChangeCheck())
                {
                    thisDDCC.UpdateUMA();
                }
                GUIHelper.EndVerticalPadded(10);
                GUIHelper.BeginVerticalPadded(10, new Color(0.75f, 0.875f, 1f));
                EditorGUILayout.LabelField("Save Values", EditorStyles.boldLabel);
                Rect thisR = EditorGUILayout.GetControlRect(false);
                var thisButReset = thisR;
                var thisButSave = thisR;
                var thisButSaveNew = thisR;
                thisButReset.width = thisButSave.width = thisButSaveNew.width = (thisR.width / 3) - 2;
                thisButSave.x = thisButReset.xMax + 5;
                thisButSaveNew.x = thisButSave.xMax + 5;
                if (GUI.Button(thisButReset, new GUIContent("Reset", "Undo your changes to the currently selected converter")))
                {
                    thisDDCC.RestoreBackupVersion(serializedObject.FindProperty("selectedConverter").objectReferenceValue.name);
                }
                if (GUI.Button(thisButSave, new GUIContent("Save", "Save your changes to the currently selected converter")))
                {
                    thisDDCC.SaveChanges();
                }
                if (GUI.Button(thisButSaveNew, new GUIContent("Save as New", "Save your changes to a new converter instance")))
                {
                    thisDDCC.SaveChangesAsNew();
                }
                GUIHelper.EndVerticalPadded(10);
			}
			else
			{
				thisDDCC.StopListeningForUndo();
			}
			serializedObject.ApplyModifiedProperties();
        }

19 Source : DynamicRaceLibrary.cs
with Apache License 2.0
from A7ocin

override public void AddRace(RaceData race)
		{
			if (race == null)
				return;
			race.UpdateDictionary();
			try
			{
				base.AddRace(race);
			}
			catch
			{
				//if there is an error it will be because RaceElementList contained an empty refrence
				List<RaceData> newRaceElementList = new List<RaceData>();
				for (int i = 0; i < raceElementList.Length; i++)
				{
					if (raceElementList[i] != null)
					{
						raceElementList[i].UpdateDictionary();
						newRaceElementList.Add(raceElementList[i]);
					}
				}
				raceElementList = newRaceElementList.ToArray();
				base.AddRace(race);
			}
		}

19 Source : pUMATextRecipe.cs
with Apache License 2.0
from A7ocin

public UMADnaBase[] GetAllDna()
			{
				List<UMADnaBase> unpackedDna = UMAPackedRecipeBase.UnPackDNA(packedDna);
				return unpackedDna.ToArray();
			}

19 Source : UMAAssetIndexer.cs
with Apache License 2.0
from A7ocin

public void AddType(System.Type sType)
        {
            string QualifiedName = sType.replacedemblyQualifiedName;
            if (IsAdditionalIndexedType(QualifiedName)) return;

            List<System.Type> newTypes = new List<System.Type>();
            newTypes.AddRange(Types);
            newTypes.Add(sType);
            Types = newTypes.ToArray();
            TypeToLookup.Add(sType, sType);
            IndexedTypeNames.Add(sType.replacedemblyQualifiedName);
            BuildStringTypes();
        }

19 Source : UMAAssetIndexer.cs
with Apache License 2.0
from A7ocin

public void RemoveType(System.Type sType)
        {
            string QualifiedName = sType.replacedemblyQualifiedName;
            if (!IsAdditionalIndexedType(QualifiedName)) return;

            TypeToLookup.Remove(sType);

            List<System.Type> newTypes = new List<System.Type>();
            newTypes.AddRange(Types);
            newTypes.Remove(sType);
            Types = newTypes.ToArray();
            TypeLookup.Remove(sType);
            IndexedTypeNames.Remove(sType.replacedemblyQualifiedName);
            BuildStringTypes();
        }

19 Source : UMAMaterialInspector.cs
with Apache License 2.0
from A7ocin

private static string[] FindTexProperties( Shader shader)
        {
            int count = ShaderUtil.GetPropertyCount(shader);
            if (count <= 0)
                return null;

            List<string> texProperties = new List<string>();
            texProperties.Add("Select");
            for (int i = 0; i < count; i++)
            {
                if (ShaderUtil.GetPropertyType(shader, i) == ShaderUtil.ShaderPropertyType.TexEnv)
                    texProperties.Add(ShaderUtil.GetPropertyName(shader, i));
            }

            return texProperties.ToArray();
        }

19 Source : SkinnedMeshCombiner.cs
with Apache License 2.0
from A7ocin

public static void CombineMeshes(UMAMeshData target, CombineInstance[] sources, UMAData.BlendShapeSettings blendShapeSettings = null)
		{
			if (blendShapeSettings == null)
				blendShapeSettings = new UMAData.BlendShapeSettings();
            
			int vertexCount = 0;
			int bindPoseCount = 0;
			int transformHierarchyCount = 0;
			int blendShapeCount = 0;

			MeshComponents meshComponents = MeshComponents.none;
			int subMeshCount = FindTargetSubMeshCount(sources);
			var subMeshTriangleLength = new int[subMeshCount];
			replacedyzeSources(sources, subMeshTriangleLength, ref vertexCount, ref bindPoseCount, ref transformHierarchyCount, ref meshComponents, ref blendShapeCount);

			int[][] submeshTriangles = new int[subMeshCount][];
			for (int i = 0; i < subMeshTriangleLength.Length; i++)
			{
				submeshTriangles[i] = target.GetSubmeshBuffer(subMeshTriangleLength[i], i);
				subMeshTriangleLength[i] = 0;
			}

			bool has_normals = (meshComponents & MeshComponents.has_normals) != MeshComponents.none;
			bool has_tangents = (meshComponents & MeshComponents.has_tangents) != MeshComponents.none;
			bool has_uv = (meshComponents & MeshComponents.has_uv) != MeshComponents.none;
			bool has_uv2 = (meshComponents & MeshComponents.has_uv2) != MeshComponents.none;
			bool has_uv3 = (meshComponents & MeshComponents.has_uv3) != MeshComponents.none;
			bool has_uv4 = (meshComponents & MeshComponents.has_uv4) != MeshComponents.none;
			bool has_colors32 = (meshComponents & MeshComponents.has_colors32) != MeshComponents.none;
			bool has_blendShapes = (meshComponents & MeshComponents.has_blendShapes) != MeshComponents.none;
			if (blendShapeSettings.ignoreBlendShapes)
				has_blendShapes = false;
			bool has_clothSkinning = (meshComponents & MeshComponents.has_clothSkinning) != MeshComponents.none;

			Vector3[] vertices = EnsureArrayLength(target.vertices, vertexCount);
			BoneWeight[] boneWeights = EnsureArrayLength(target.unityBoneWeights, vertexCount);
			Vector3[] normals = has_normals ? EnsureArrayLength(target.normals, vertexCount) : null;
			Vector4[] tangents = has_tangents ? EnsureArrayLength(target.tangents, vertexCount) : null;
			Vector2[] uv = has_uv ? EnsureArrayLength(target.uv, vertexCount) : null;
			Vector2[] uv2 = has_uv2 ? EnsureArrayLength(target.uv2, vertexCount) : null;
			Vector2[] uv3 = has_uv3 ? EnsureArrayLength(target.uv3, vertexCount) : null;
			Vector2[] uv4 = has_uv4 ? EnsureArrayLength(target.uv4, vertexCount) : null;
			Color32[] colors32 = has_colors32 ? EnsureArrayLength(target.colors32, vertexCount) : null;
			UMABlendShape[] blendShapes = has_blendShapes ? new UMABlendShape[blendShapeCount] : null;
			UMATransform[] umaTransforms = EnsureArrayLength(target.umaBones, transformHierarchyCount);
			ClothSkinningCoefficient[] clothSkinning = has_clothSkinning ? EnsureArrayLength(target.clothSkinning, vertexCount) : null;
			Dictionary<Vector3, int> clothVertices = has_clothSkinning ? new Dictionary<Vector3, int>(vertexCount) : null;
			Dictionary<Vector3, int> localClothVertices = has_clothSkinning ? new Dictionary<Vector3, int>(vertexCount) : null;

			int boneCount = 0;
			foreach (var source in sources)
			{
				MergeSortedTransforms(umaTransforms, ref boneCount, source.meshData.umaBones);
			}
			int vertexIndex = 0;

			if (bonesCollection == null)
				bonesCollection = new Dictionary<int, BoneIndexEntry>(boneCount);
			else
				bonesCollection.Clear();
			if (bindPoses == null)
				bindPoses = new List<Matrix4x4>(bindPoseCount);
			else
				bindPoses.Clear();
			if (bonesList == null)
				bonesList = new List<int>(boneCount);
			else
				bonesList.Clear();

			int blendShapeIndex = 0;

			foreach (var source in sources)
			{
				int sourceVertexCount = source.meshData.vertices.Length;
				BuildBoneWeights(source.meshData.boneWeights, 0, boneWeights, vertexIndex, sourceVertexCount, source.meshData.boneNameHashes, source.meshData.bindPoses, bonesCollection, bindPoses, bonesList);

				Array.Copy(source.meshData.vertices, 0, vertices, vertexIndex, sourceVertexCount);

				if (has_normals)
				{
					if (source.meshData.normals != null && source.meshData.normals.Length > 0)
					{
						Array.Copy(source.meshData.normals, 0, normals, vertexIndex, sourceVertexCount);
					}
					else
					{
						FillArray(tangents, vertexIndex, sourceVertexCount, Vector3.zero);
					}
				}
				if (has_tangents)
				{
					if (source.meshData.tangents != null && source.meshData.tangents.Length > 0)
					{
						Array.Copy(source.meshData.tangents, 0, tangents, vertexIndex, sourceVertexCount);
					}
					else
					{
						FillArray(tangents, vertexIndex, sourceVertexCount, Vector4.zero);
					}
				}
				if (has_uv)
				{
					if (source.meshData.uv != null && source.meshData.uv.Length >= sourceVertexCount)
					{
						Array.Copy(source.meshData.uv, 0, uv, vertexIndex, sourceVertexCount);
					}
					else
					{
						FillArray(uv, vertexIndex, sourceVertexCount, Vector4.zero);
					}
				}
				if (has_uv2)
				{
					if (source.meshData.uv2 != null && source.meshData.uv2.Length >= sourceVertexCount)
					{
						Array.Copy(source.meshData.uv2, 0, uv2, vertexIndex, sourceVertexCount);
					}
					else
					{
						FillArray(uv2, vertexIndex, sourceVertexCount, Vector4.zero);
					}
				}
				if (has_uv3)
				{
					if (source.meshData.uv3 != null && source.meshData.uv3.Length >= sourceVertexCount)
					{
						Array.Copy(source.meshData.uv3, 0, uv3, vertexIndex, sourceVertexCount);
					}
					else
					{
						FillArray(uv3, vertexIndex, sourceVertexCount, Vector4.zero);
					}
				}
				if (has_uv4)
				{
					if (source.meshData.uv4 != null && source.meshData.uv4.Length >= sourceVertexCount)
					{
						Array.Copy(source.meshData.uv4, 0, uv4, vertexIndex, sourceVertexCount);
					}
					else
					{
						FillArray(uv4, vertexIndex, sourceVertexCount, Vector4.zero);
					}
				}

				if (has_colors32)
				{
					if (source.meshData.colors32 != null && source.meshData.colors32.Length > 0)
					{
						Array.Copy(source.meshData.colors32, 0, colors32, vertexIndex, sourceVertexCount);
					}
					else
					{
						Color32 white32 = Color.white;
						FillArray(colors32, vertexIndex, sourceVertexCount, white32);
					}
				}

				if (has_blendShapes) 
				{
					if (source.meshData.blendShapes != null && source.meshData.blendShapes.Length > 0) 
					{
						for (int shapeIndex = 0; shapeIndex < source.meshData.blendShapes.Length; shapeIndex++)
						{
                            #region BlendShape Baking
                            if(blendShapeSettings.bakeBlendShapes != null || blendShapeSettings.bakeBlendShapes.Count == 0)
                            {
                                // If there are names in the bakeBlendShape dictionary and we find them in the meshData blendshape list, then lets bake them instead of adding them.
                                UMABlendShape currentShape = source.meshData.blendShapes[shapeIndex];
                                if( blendShapeSettings.bakeBlendShapes.ContainsKey(currentShape.shapeName))
                                {
                                    float weight = blendShapeSettings.bakeBlendShapes[currentShape.shapeName] * 100.0f;
									if (weight <= 0f) continue; // Baking in nothing, so skip it entirely

                                    // Let's find the frame this weight is in
                                    int frameIndex;
									int prevIndex;
                                    for (frameIndex = 0; frameIndex < currentShape.frames.Length; frameIndex++)
                                    {
                                        if (currentShape.frames[frameIndex].frameWeight >= weight)
                                            break;
                                    }

									// Let's calculate the weight for the frame we're in
									float frameWeight = 1f;
									float prevWeight = 0f;
									bool doLerp = false;
									// Weight is higher than the last frame, shape is over 100%
									if (frameIndex >= currentShape.frames.Length)
									{
										frameIndex = currentShape.frames.Length - 1;
										frameWeight = (weight / currentShape.frames[frameIndex].frameWeight);
									}
									else if (frameIndex > 0)
									{
										doLerp = true;
										prevWeight = currentShape.frames[frameIndex - 1].frameWeight;
										frameWeight = ((weight - prevWeight) / (currentShape.frames[frameIndex].frameWeight - prevWeight));
										prevWeight = 1f - frameWeight;
									}
									else
									{
										frameWeight = (weight / currentShape.frames[frameIndex].frameWeight);
									}
									prevIndex = frameIndex - 1;

                                    // The blend shape frames lerp between the deltas of two adjacent frames.
									int vertIndex = vertexIndex;
									for (int bakeIndex = 0; bakeIndex < currentShape.frames[frameIndex].deltaVertices.Length; bakeIndex++, vertIndex++)
                                    {
                                        // Add the current frame's deltas
										vertices[vertIndex] += currentShape.frames[frameIndex].deltaVertices[bakeIndex] * frameWeight;
                                        // Add in the previous frame's deltas
										if (doLerp)
											vertices[vertIndex] += currentShape.frames[prevIndex].deltaVertices[bakeIndex] * prevWeight;
                                    }

                                    if (has_normals)
                                    {
										vertIndex = vertexIndex;
										for (int bakeIndex = 0; bakeIndex < currentShape.frames[frameIndex].deltaNormals.Length; bakeIndex++, vertIndex++)
                                        {
											normals[vertIndex] += currentShape.frames[frameIndex].deltaNormals[bakeIndex] * frameWeight;
											if (doLerp)
												normals[vertIndex] += currentShape.frames[prevIndex].deltaNormals[bakeIndex] * prevWeight;
                                        }
                                    }

                                    if (has_tangents)
                                    {
										vertIndex = vertexIndex;
										for (int bakeIndex = 0; bakeIndex < currentShape.frames[frameIndex].deltaTangents.Length; bakeIndex++, vertIndex++)
                                        {
											tangents[vertIndex] += (Vector4)currentShape.frames[frameIndex].deltaTangents[bakeIndex] * frameWeight;
											if (doLerp)
												tangents[vertIndex] += (Vector4)currentShape.frames[prevIndex].deltaTangents[bakeIndex] * prevWeight;    
                                        }
                                    }
                                    continue; // If we bake then don't perform the rest of this interation of the loop.
                                }                                
                            }
                            #endregion

							bool nameAlreadyExists = false;
							int i = 0;
							//Probably this would be better with a dictionary
							for (i = 0; i < blendShapeIndex; i++) 
							{
								if (blendShapes[i].shapeName == source.meshData.blendShapes[shapeIndex].shapeName) 
								{
									nameAlreadyExists = true;
									break;
								}
							}

							if (nameAlreadyExists)//Lets add the vertices data to the existing blendShape
							{ 
								if (blendShapes[i].frames.Length != source.meshData.blendShapes[shapeIndex].frames.Length) 
								{
									Debug.LogError("SkinnedMeshCombiner: mesh blendShape frame counts don't match!");
									break;
								}
								for (int frameIndex = 0; frameIndex < source.meshData.blendShapes[shapeIndex].frames.Length; frameIndex++) {
									Array.Copy(source.meshData.blendShapes[shapeIndex].frames[frameIndex].deltaVertices, 0, blendShapes[i].frames[frameIndex].deltaVertices, vertexIndex, sourceVertexCount);
									Array.Copy(source.meshData.blendShapes[shapeIndex].frames[frameIndex].deltaNormals, 0, blendShapes[i].frames[frameIndex].deltaNormals, vertexIndex, sourceVertexCount);
									Array.Copy(source.meshData.blendShapes[shapeIndex].frames[frameIndex].deltaTangents, 0, blendShapes[i].frames[frameIndex].deltaTangents, vertexIndex, sourceVertexCount);
								}
							} 
							else
							{
								blendShapes[blendShapeIndex] = new UMABlendShape();
								blendShapes[blendShapeIndex].shapeName = source.meshData.blendShapes[shapeIndex].shapeName;
								blendShapes[blendShapeIndex].frames = new UMABlendFrame[source.meshData.blendShapes[shapeIndex].frames.Length];

								for (int frameIndex = 0; frameIndex < source.meshData.blendShapes[shapeIndex].frames.Length; frameIndex++) {
									blendShapes[blendShapeIndex].frames[frameIndex] = new UMABlendFrame(vertexCount); 
									blendShapes[blendShapeIndex].frames[frameIndex].frameWeight = source.meshData.blendShapes[shapeIndex].frames[frameIndex].frameWeight;
									Array.Copy(source.meshData.blendShapes[shapeIndex].frames[frameIndex].deltaVertices, 0, blendShapes[blendShapeIndex].frames[frameIndex].deltaVertices, vertexIndex, sourceVertexCount);
									Array.Copy(source.meshData.blendShapes[shapeIndex].frames[frameIndex].deltaNormals, 0, blendShapes[blendShapeIndex].frames[frameIndex].deltaNormals, vertexIndex, sourceVertexCount);
									Array.Copy(source.meshData.blendShapes[shapeIndex].frames[frameIndex].deltaTangents, 0, blendShapes[blendShapeIndex].frames[frameIndex].deltaTangents, vertexIndex, sourceVertexCount);
								}
								blendShapeIndex++;
							}
						}
					}
				}
				if (has_clothSkinning)
				{
					localClothVertices.Clear();
					if (source.meshData.clothSkinningSerialized != null && source.meshData.clothSkinningSerialized.Length > 0)
					{
						for (int i = 0; i < source.meshData.vertexCount; i++)
						{
							var vertice = source.meshData.vertices[i];
							if (!localClothVertices.ContainsKey(vertice))
							{
								int localCount = localClothVertices.Count;
								localClothVertices.Add(vertice, localCount);
								if (!clothVertices.ContainsKey(vertice))
								{
									ConvertData(ref source.meshData.clothSkinningSerialized[localCount], ref clothSkinning[clothVertices.Count]);
									clothVertices.Add(vertice, clothVertices.Count);
								}
								else
								{
									ConvertData(ref source.meshData.clothSkinningSerialized[localCount], ref clothSkinning[clothVertices[vertice]]);
								}
							}
						}
					}
					else
					{
						for (int i = 0; i < source.meshData.vertexCount; i++)
						{
							var vertice = source.meshData.vertices[i];
							if (!clothVertices.ContainsKey(vertice))
							{
								clothSkinning[clothVertices.Count].maxDistance = 0;
								clothSkinning[clothVertices.Count].collisionSphereDistance = float.MaxValue;
								clothVertices.Add(vertice, clothVertices.Count);
								localClothVertices.Add(vertice, clothVertices.Count);
							}
						}
					}
				}

				for (int i = 0; i < source.meshData.subMeshCount; i++)
				{
					if (source.targetSubmeshIndices[i] >= 0)
					{
						int[] subTriangles = source.meshData.submeshes[i].triangles;
						int triangleLength = subTriangles.Length;
						int destMesh = source.targetSubmeshIndices[i];

						if (source.triangleMask == null)
						{
							CopyIntArrayAdd(subTriangles, 0, submeshTriangles[destMesh], subMeshTriangleLength[destMesh], triangleLength, vertexIndex);
							subMeshTriangleLength[destMesh] += triangleLength;
						}
						else
						{
							MaskedCopyIntArrayAdd(subTriangles, 0, submeshTriangles[destMesh], subMeshTriangleLength[destMesh], triangleLength, vertexIndex, source.triangleMask[i] );
							subMeshTriangleLength[destMesh] += (triangleLength - (UMAUtils.GetCardinality(source.triangleMask[i])*3));
						}
					}
				}

				vertexIndex += sourceVertexCount;
			}

			if (vertexCount != vertexIndex)
			{
				Debug.LogError("Combined vertices size didn't match precomputed value!");
			}

			// fill in new values.
			target.vertexCount = vertexCount;
			target.vertices = vertices;
			target.unityBoneWeights = boneWeights;
			target.bindPoses = bindPoses.ToArray();
			target.normals = normals;
			target.tangents = tangents;
			target.uv = uv;
			target.uv2 = uv2;
			target.uv3 = uv3;
			target.uv4 = uv4;
			target.colors32 = colors32;

			if (has_blendShapes) 
				target.blendShapes = blendShapes;

			if (has_clothSkinning)
			{
				Array.Resize(ref clothSkinning, clothVertices.Count);
			}
			target.clothSkinning = clothSkinning;

			target.subMeshCount = subMeshCount;
			target.submeshes = new SubMeshTriangles[subMeshCount];
			target.umaBones = umaTransforms;
			target.umaBoneCount = boneCount;
			for (int i = 0; i < subMeshCount; i++)
			{
				target.submeshes[i].triangles = submeshTriangles[i];
			}
			target.boneNameHashes = bonesList.ToArray();
		}

19 Source : UMABonePose.cs
with Apache License 2.0
from A7ocin

static public Transform[] GetTransformsInPrefab(Transform prefab)
		{
			List<Transform> transforms = new List<Transform>();

			RecurseTransformsInPrefab(prefab, transforms);

			return transforms.ToArray();
		}

19 Source : UMAData.cs
with Apache License 2.0
from A7ocin

public UMADnaBase[] GetAllDna()
			{
				if ((raceData == null) || (slotDataList == null))
				{
					return new UMADnaBase[0];
				}
				return dnaValues.ToArray();
			}

19 Source : UMAData.cs
with Apache License 2.0
from A7ocin

public Texture[] backUpTextures()
		{
			List<Texture> textureList = new List<Texture>();

			for (int atlasIndex = 0; atlasIndex < generatedMaterials.materials.Count; atlasIndex++)
			{
				if (generatedMaterials.materials[atlasIndex] != null && generatedMaterials.materials[atlasIndex].resultingAtlasList != null)
				{
					for (int textureIndex = 0; textureIndex < generatedMaterials.materials[atlasIndex].resultingAtlasList.Length; textureIndex++)
					{

						if (generatedMaterials.materials[atlasIndex].resultingAtlasList[textureIndex] != null)
						{
							Texture tempTexture = generatedMaterials.materials[atlasIndex].resultingAtlasList[textureIndex];
							textureList.Add(tempTexture);
							generatedMaterials.materials[atlasIndex].resultingAtlasList[textureIndex] = null;
						}
					}
				}
			}

			return textureList.ToArray();
		}

19 Source : UmaTPose.cs
with Apache License 2.0
from A7ocin

public void ReadFromTransform(Animator rootAnimator)
	    {
	        var boneInfoList = new List<SkeletonBone>();
	        AddRecursively(boneInfoList, rootAnimator.transform);
	        boneInfo = boneInfoList.ToArray();
	        var humanInfoList = new List<HumanBone>();
	        ExtractHumanInfo(rootAnimator, humanInfoList);
	        humanInfo = humanInfoList.ToArray();
	        Serialize();
	    }

19 Source : UMACrowd.cs
with Apache License 2.0
from A7ocin

void DefineSlots()
		{
			Color skinColor = new Color(1, 1, 1, 1);
			float skinTone;

			skinTone = Random.Range(0.1f, 0.6f);
			skinColor = new Color(skinTone + Random.Range(0.35f, 0.4f), skinTone + Random.Range(0.25f, 0.4f), skinTone + Random.Range(0.35f, 0.4f), 1);

			Color HairColor = new Color(Random.Range(0.1f, 0.9f), Random.Range(0.1f, 0.9f), Random.Range(0.1f, 0.9f), 1);

			if (umaData.umaRecipe.raceData.raceName == "HumanMale")
			{
				int randomResult = 0;
				//Male Avatar

				umaData.umaRecipe.slotDataList = new SlotData[15];

				umaData.umaRecipe.slotDataList[0] = umaContext.InstantiateSlot("MaleEyes");
				umaData.umaRecipe.slotDataList[0].AddOverlay(umaContext.InstantiateOverlay("EyeOverlay"));
				umaData.umaRecipe.slotDataList[0].AddOverlay(umaContext.InstantiateOverlay("EyeOverlayAdjust", new Color(Random.Range(0.1f, 0.9f), Random.Range(0.1f, 0.9f), Random.Range(0.1f, 0.9f), 1)));

				randomResult = Random.Range(0, 2);
				if (randomResult == 0)
				{
					umaData.umaRecipe.slotDataList[1] = umaContext.InstantiateSlot("MaleFace");

					randomResult = Random.Range(0, 2);

					if (randomResult == 0)
					{
						umaData.umaRecipe.slotDataList[1].AddOverlay(umaContext.InstantiateOverlay("MaleHead01", skinColor));
					}
					else if (randomResult == 1)
					{
						umaData.umaRecipe.slotDataList[1].AddOverlay(umaContext.InstantiateOverlay("MaleHead02", skinColor));
					}
				}
				else if (randomResult == 1)
				{
					umaData.umaRecipe.slotDataList[1] = umaContext.InstantiateSlot("MaleHead_Head");

					randomResult = Random.Range(0, 2);
					if (randomResult == 0)
					{
						umaData.umaRecipe.slotDataList[1].AddOverlay(umaContext.InstantiateOverlay("MaleHead01", skinColor));
					}
					else if (randomResult == 1)
					{
						umaData.umaRecipe.slotDataList[1].AddOverlay(umaContext.InstantiateOverlay("MaleHead02", skinColor));
					}

					umaData.umaRecipe.slotDataList[7] = umaContext.InstantiateSlot("MaleHead_Eyes", umaData.umaRecipe.slotDataList[1].GetOverlayList());
					umaData.umaRecipe.slotDataList[9] = umaContext.InstantiateSlot("MaleHead_Mouth", umaData.umaRecipe.slotDataList[1].GetOverlayList());

					randomResult = Random.Range(0, 2);
					if (randomResult == 0)
					{
						umaData.umaRecipe.slotDataList[10] = umaContext.InstantiateSlot("MaleHead_PigNose", umaData.umaRecipe.slotDataList[1].GetOverlayList());
						umaData.umaRecipe.slotDataList[1].AddOverlay(umaContext.InstantiateOverlay("MaleHead_PigNose", skinColor));
					}
					else if (randomResult == 1)
					{
						umaData.umaRecipe.slotDataList[10] = umaContext.InstantiateSlot("MaleHead_Nose", umaData.umaRecipe.slotDataList[1].GetOverlayList());
					}

					randomResult = Random.Range(0, 2);
					if (randomResult == 0)
					{
						umaData.umaRecipe.slotDataList[8] = umaContext.InstantiateSlot("MaleHead_ElvenEars");
						umaData.umaRecipe.slotDataList[8].AddOverlay(umaContext.InstantiateOverlay("ElvenEars", skinColor));
					}
					else if (randomResult == 1)
					{
						umaData.umaRecipe.slotDataList[8] = umaContext.InstantiateSlot("MaleHead_Ears", umaData.umaRecipe.slotDataList[1].GetOverlayList());
					}
				}


				randomResult = Random.Range(0, 3);
				if (randomResult == 0)
				{
					umaData.umaRecipe.slotDataList[1].AddOverlay(umaContext.InstantiateOverlay("MaleHair01", HairColor * 0.25f));
				}
				else if (randomResult == 1)
				{
					umaData.umaRecipe.slotDataList[1].AddOverlay(umaContext.InstantiateOverlay("MaleHair02", HairColor * 0.25f));
				}
				else
				{

				}


				randomResult = Random.Range(0, 4);
				if (randomResult == 0)
				{
					umaData.umaRecipe.slotDataList[1].AddOverlay(umaContext.InstantiateOverlay("MaleBeard01", HairColor * 0.15f));
				}
				else if (randomResult == 1)
				{
					umaData.umaRecipe.slotDataList[1].AddOverlay(umaContext.InstantiateOverlay("MaleBeard02", HairColor * 0.15f));
				}
				else if (randomResult == 2)
				{
					umaData.umaRecipe.slotDataList[1].AddOverlay(umaContext.InstantiateOverlay("MaleBeard03", HairColor * 0.15f));
				}
				else
				{

				}



				//Extra beard composition
				randomResult = Random.Range(0, 4);
				if (randomResult == 0)
				{
					umaData.umaRecipe.slotDataList[1].AddOverlay(umaContext.InstantiateOverlay("MaleBeard01", HairColor * 0.15f));
				}
				else if (randomResult == 1)
				{
					umaData.umaRecipe.slotDataList[1].AddOverlay(umaContext.InstantiateOverlay("MaleBeard02", HairColor * 0.15f));
				}
				else if (randomResult == 2)
				{
					umaData.umaRecipe.slotDataList[1].AddOverlay(umaContext.InstantiateOverlay("MaleBeard03", HairColor * 0.15f));
				}
				else
				{

				}

				randomResult = Random.Range(0, 2);
				if (randomResult == 0)
				{
					umaData.umaRecipe.slotDataList[1].AddOverlay(umaContext.InstantiateOverlay("MaleEyebrow01", HairColor * 0.05f));
				}
				else
				{
					umaData.umaRecipe.slotDataList[1].AddOverlay(umaContext.InstantiateOverlay("MaleEyebrow02", HairColor * 0.05f));
				}

				umaData.umaRecipe.slotDataList[2] = umaContext.InstantiateSlot("MaleTorso");

				randomResult = Random.Range(0, 2);
				if (randomResult == 0)
				{
					umaData.umaRecipe.slotDataList[2].AddOverlay(umaContext.InstantiateOverlay("MaleBody01", skinColor));
				}
				else
				{
					umaData.umaRecipe.slotDataList[2].AddOverlay(umaContext.InstantiateOverlay("MaleBody02", skinColor));
				}


				randomResult = Random.Range(0, 2);
				if (randomResult == 0)
				{
					umaData.umaRecipe.slotDataList[2].AddOverlay(umaContext.InstantiateOverlay("MaleShirt01", new Color(Random.Range(0.1f, 0.9f), Random.Range(0.1f, 0.9f), Random.Range(0.1f, 0.9f), 1)));
				}

				umaData.umaRecipe.slotDataList[3] = umaContext.InstantiateSlot("MaleHands", umaData.umaRecipe.slotDataList[2].GetOverlayList());

				umaData.umaRecipe.slotDataList[4] = umaContext.InstantiateSlot("MaleInnerMouth");
				umaData.umaRecipe.slotDataList[4].AddOverlay(umaContext.InstantiateOverlay("InnerMouth"));


				randomResult = Random.Range(0, 2);
				if (randomResult == 0)
				{
					umaData.umaRecipe.slotDataList[5] = umaContext.InstantiateSlot("MaleLegs", umaData.umaRecipe.slotDataList[2].GetOverlayList());
					umaData.umaRecipe.slotDataList[2].AddOverlay(umaContext.InstantiateOverlay("MaleUnderwear01", new Color(Random.Range(0.1f, 0.9f), Random.Range(0.1f, 0.9f), Random.Range(0.1f, 0.9f), 1)));
				}
				else
				{
					umaData.umaRecipe.slotDataList[5] = umaContext.InstantiateSlot("MaleJeans01");
					umaData.umaRecipe.slotDataList[5].AddOverlay(umaContext.InstantiateOverlay("MaleJeans01", new Color(Random.Range(0.1f, 0.9f), Random.Range(0.1f, 0.9f), Random.Range(0.1f, 0.9f), 1)));
				}

				umaData.umaRecipe.slotDataList[6] = umaContext.InstantiateSlot("MaleFeet", umaData.umaRecipe.slotDataList[2].GetOverlayList());
			}
			else if (umaData.umaRecipe.raceData.raceName == "HumanFemale")
			{
				int randomResult = 0;
				//Female Avatar

				//Example of dynamic list
				List<SlotData> tempSlotList = new List<SlotData>();

				tempSlotList.Add(umaContext.InstantiateSlot("FemaleEyes"));
				tempSlotList[tempSlotList.Count - 1].AddOverlay(umaContext.InstantiateOverlay("EyeOverlay"));
				tempSlotList[tempSlotList.Count - 1].AddOverlay(umaContext.InstantiateOverlay("EyeOverlayAdjust", new Color(Random.Range(0.1f, 0.9f), Random.Range(0.1f, 0.9f), Random.Range(0.1f, 0.9f), 1)));

				int headIndex = 0;

				randomResult = Random.Range(0, 2);
				if (randomResult == 0)
				{

					tempSlotList.Add(umaContext.InstantiateSlot("FemaleFace"));
					headIndex = tempSlotList.Count - 1;
					tempSlotList[headIndex].AddOverlay(umaContext.InstantiateOverlay("FemaleHead01", skinColor));
					tempSlotList[headIndex].AddOverlay(umaContext.InstantiateOverlay("FemaleEyebrow01", new Color(0.125f, 0.065f, 0.065f, 1.0f)));

					randomResult = Random.Range(0, 2);
					if (randomResult == 0)
					{
						tempSlotList[headIndex].AddOverlay(umaContext.InstantiateOverlay("FemaleLipstick01", new Color(skinColor.r + Random.Range(0.0f, 0.3f), skinColor.g, skinColor.b + Random.Range(0.0f, 0.2f), 1)));
					}
				}
				else if (randomResult == 1)
				{
					tempSlotList.Add(umaContext.InstantiateSlot("FemaleHead_Head"));
					headIndex = tempSlotList.Count - 1;
					tempSlotList[headIndex].AddOverlay(umaContext.InstantiateOverlay("FemaleHead01", skinColor));
					tempSlotList[headIndex].AddOverlay(umaContext.InstantiateOverlay("FemaleEyebrow01", new Color(0.125f, 0.065f, 0.065f, 1.0f)));

					tempSlotList.Add(umaContext.InstantiateSlot("FemaleHead_Eyes", tempSlotList[headIndex].GetOverlayList()));
					tempSlotList.Add(umaContext.InstantiateSlot("FemaleHead_Mouth", tempSlotList[headIndex].GetOverlayList()));
					tempSlotList.Add(umaContext.InstantiateSlot("FemaleHead_Nose", tempSlotList[headIndex].GetOverlayList()));


					randomResult = Random.Range(0, 2);
					if (randomResult == 0)
					{
						tempSlotList.Add(umaContext.InstantiateSlot("FemaleHead_ElvenEars"));
						tempSlotList[tempSlotList.Count - 1].AddOverlay(umaContext.InstantiateOverlay("ElvenEars", skinColor));
					}
					else if (randomResult == 1)
					{
						tempSlotList.Add(umaContext.InstantiateSlot("FemaleHead_Ears", tempSlotList[headIndex].GetOverlayList()));
					}

					randomResult = Random.Range(0, 2);
					if (randomResult == 0)
					{
						tempSlotList[headIndex].AddOverlay(umaContext.InstantiateOverlay("FemaleLipstick01", new Color(skinColor.r + Random.Range(0.0f, 0.3f), skinColor.g, skinColor.b + Random.Range(0.0f, 0.2f), 1)));
					}
				}

				tempSlotList.Add(umaContext.InstantiateSlot("FemaleEyelash"));
				tempSlotList[tempSlotList.Count - 1].AddOverlay(umaContext.InstantiateOverlay("FemaleEyelash", Color.black));

				tempSlotList.Add(umaContext.InstantiateSlot("FemaleTorso"));
				int bodyIndex = tempSlotList.Count - 1;
				randomResult = Random.Range(0, 2);
				if (randomResult == 0)
				{
					tempSlotList[bodyIndex].AddOverlay(umaContext.InstantiateOverlay("FemaleBody01", skinColor));
				} if (randomResult == 1)
				{
					tempSlotList[bodyIndex].AddOverlay(umaContext.InstantiateOverlay("FemaleBody02", skinColor));
				}

				tempSlotList[bodyIndex].AddOverlay(umaContext.InstantiateOverlay("FemaleUnderwear01", new Color(Random.Range(0.1f, 0.9f), Random.Range(0.1f, 0.9f), Random.Range(0.1f, 0.9f), 1)));

				randomResult = Random.Range(0, 4);
				if (randomResult == 0)
				{
					tempSlotList[bodyIndex].AddOverlay(umaContext.InstantiateOverlay("FemaleShirt01", new Color(Random.Range(0.1f, 0.9f), Random.Range(0.1f, 0.9f), Random.Range(0.1f, 0.9f), 1)));
				}
				else if (randomResult == 1)
				{
					tempSlotList[bodyIndex].AddOverlay(umaContext.InstantiateOverlay("FemaleShirt02", new Color(Random.Range(0.1f, 0.9f), Random.Range(0.1f, 0.9f), Random.Range(0.1f, 0.9f), 1)));
				}
				else if (randomResult == 2)
				{
					tempSlotList.Add(umaContext.InstantiateSlot("FemaleTshirt01"));
					tempSlotList[tempSlotList.Count - 1].AddOverlay(umaContext.InstantiateOverlay("FemaleTshirt01", new Color(Random.Range(0.1f, 0.9f), Random.Range(0.1f, 0.9f), Random.Range(0.1f, 0.9f), 1)));
				}
				else
				{

				}

				tempSlotList.Add(umaContext.InstantiateSlot("FemaleHands", tempSlotList[bodyIndex].GetOverlayList()));

				tempSlotList.Add(umaContext.InstantiateSlot("FemaleInnerMouth"));
				tempSlotList[tempSlotList.Count - 1].AddOverlay(umaContext.InstantiateOverlay("InnerMouth"));

				tempSlotList.Add(umaContext.InstantiateSlot("FemaleFeet", tempSlotList[bodyIndex].GetOverlayList()));


				randomResult = Random.Range(0, 2);

				if (randomResult == 0)
				{
					tempSlotList.Add(umaContext.InstantiateSlot("FemaleLegs", tempSlotList[bodyIndex].GetOverlayList()));
				}
				else if (randomResult == 1)
				{
					tempSlotList.Add(umaContext.InstantiateSlot("FemaleLegs", tempSlotList[bodyIndex].GetOverlayList()));
					tempSlotList[bodyIndex].AddOverlay(umaContext.InstantiateOverlay("FemaleJeans01", new Color(Random.Range(0.1f, 0.9f), Random.Range(0.1f, 0.9f), Random.Range(0.1f, 0.9f), 1)));
				}

				randomResult = Random.Range(0, 3);
				if (randomResult == 0)
				{
					tempSlotList.Add(umaContext.InstantiateSlot("FemaleShortHair01", tempSlotList[headIndex].GetOverlayList()));
					tempSlotList[headIndex].AddOverlay(umaContext.InstantiateOverlay("FemaleShortHair01", HairColor));
				}
				else if (randomResult == 1)
				{
					tempSlotList.Add(umaContext.InstantiateSlot("FemaleLongHair01", tempSlotList[headIndex].GetOverlayList()));
					tempSlotList[headIndex].AddOverlay(umaContext.InstantiateOverlay("FemaleLongHair01", HairColor));
				}
				else
				{
					tempSlotList.Add(umaContext.InstantiateSlot("FemaleLongHair01", tempSlotList[headIndex].GetOverlayList()));
					tempSlotList[headIndex].AddOverlay(umaContext.InstantiateOverlay("FemaleLongHair01", HairColor));

					tempSlotList.Add(umaContext.InstantiateSlot("FemaleLongHair01_Module"));
					tempSlotList[tempSlotList.Count - 1].AddOverlay(umaContext.InstantiateOverlay("FemaleLongHair01_Module", HairColor));
				}

				umaData.SetSlots(tempSlotList.ToArray());
			}
		}

19 Source : BTCChinaAPI.cs
with MIT License
from aabiryukov

private string GetHMACSHA1Hash(NameValueCollection parameters)
        {
            var keyValues = new List<string>();
            foreach (string key in parameters)
            {
                keyValues.Add(key + "=" + parameters[key]);
            }
            string input = String.Join("&", keyValues.ToArray());
            //signature string for hash is NOT JSON-compatible
            //watch out for API changes on the website.
            input = input.Replace("\"", "");
            input = input.Replace("true", "1");
            input = input.Replace("false", "");
            input = input.Replace("null", "");

            //Console.WriteLine(input);

	        using (var hmacsha1 = new HMACSHA1(Encoding.ASCII.GetBytes(secretKey)))
	        {
		        byte[] hashData;
		        using (var stream = new MemoryStream(Encoding.ASCII.GetBytes(input)))
		        {
			        hashData = hmacsha1.ComputeHash(stream);
		        }

		        // Format as hexadecimal string.
		        var hashBuilder = new StringBuilder();
		        foreach (byte data in hashData)
		        {
			        hashBuilder.Append(data.ToString("x2", CultureInfo.InvariantCulture));
		        }
		        return hashBuilder.ToString();
	        }
        }

19 Source : UMADefaultMeshCombiner.cs
with Apache License 2.0
from A7ocin

public override void UpdateUMAMesh(bool updatedAtlas, UMAData umaData, int atlasResolution)
		{
			this.umaData = umaData;
			this.atlasResolution = atlasResolution;

			combinedMeshList = new List<SkinnedMeshCombiner.CombineInstance>(umaData.umaRecipe.slotDataList.Length);
			combinedMaterialList = new List<Material>();

			EnsureUMADataSetup(umaData);
			umaData.skeleton.BeginSkeletonUpdate();

			for (currentRendererIndex = 0; currentRendererIndex < umaData.generatedMaterials.rendererCount; currentRendererIndex++)
			{
				//Move umaMesh creation to with in the renderer loops
				//May want to make sure to set all it's buffers to null instead of creating a new UMAMeshData
				UMAMeshData umaMesh = new UMAMeshData();
				umaMesh.ClaimSharedBuffers();

				umaMesh.subMeshCount = 0;
				umaMesh.vertexCount = 0;

				combinedMeshList.Clear();
				combinedMaterialList.Clear();
				clothProperties = null;

				BuildCombineInstances();

				if (combinedMeshList.Count == 1)
				{
					// fast track
					var tempMesh = SkinnedMeshCombiner.ShallowInstanceMesh(combinedMeshList[0].meshData);
					tempMesh.ApplyDataToUnityMesh(renderers[currentRendererIndex], umaData.skeleton);
				}
				else
				{
					SkinnedMeshCombiner.CombineMeshes(umaMesh, combinedMeshList.ToArray(), umaData.blendShapeSettings );

					if (updatedAtlas)
					{
						RecalculateUV(umaMesh);
					}

					umaMesh.ApplyDataToUnityMesh(renderers[currentRendererIndex], umaData.skeleton);
				}
				var cloth = renderers[currentRendererIndex].GetComponent<Cloth>();
				if (clothProperties != null)
				{
					if (cloth != null)
					{
						clothProperties.ApplyValues(cloth);
					}
				}
				else
				{
					UMAUtils.DestroySceneObject(cloth);
				}

				var materials = combinedMaterialList.ToArray();
				renderers[currentRendererIndex].sharedMaterials = materials;
				umaMesh.ReleaseSharedBuffers();
			}

			umaData.umaRecipe.ClearDNAConverters();
			for (int i = 0; i < umaData.umaRecipe.slotDataList.Length; i++)
			{
				SlotData slotData = umaData.umaRecipe.slotDataList[i];
				if (slotData != null)
				{
					umaData.umaRecipe.AddDNAUpdater(slotData.replacedet.slotDNA);
				}
			}

			umaData.firstBake = false;
		}

19 Source : UMAExpressionSet.cs
with Apache License 2.0
from A7ocin

private void ValidateBoneHashes()
        {
            if (boneHashes == null)
            {
                List<int> boneHashList = new List<int>();
                foreach (PosePair pair in posePairs)
                {
                    if (pair.primary != null)
                    {
                        foreach (UMABonePose.PoseBone bone in pair.primary.poses)
                        {
                            if (!boneHashList.Contains(bone.hash))
                            {
                                boneHashList.Add(bone.hash);
                            }
                        }
                    }
                    if (pair.inverse != null)
                    {
                        foreach (UMABonePose.PoseBone bone in pair.inverse.poses)
                        {
                            if (!boneHashList.Contains(bone.hash))
                            {
                                boneHashList.Add(bone.hash);
                            }
                        }
                    }
                }

                boneHashes = boneHashList.ToArray();
            }
        }

19 Source : UMAGeneratorBase.cs
with Apache License 2.0
from A7ocin

private static void SkeletonModifier(UMAData umaData, ref SkeletonBone[] bones, HumanBone[] human)
		{
			int missingBoneCount = 0;
			newBones.Clear();

			while (!umaData.skeleton.HasBone(UMAUtils.StringToHash(bones[missingBoneCount].name)))
			{
				missingBoneCount++;
			}
			if (missingBoneCount > 0)
			{
				// force the two root transforms, reuse old bones entries to ensure any humanoid identifiers stay intact
				var realRootBone = umaData.transform;
				var newBone = bones[missingBoneCount - 2];
				newBone.position = realRootBone.localPosition;
				newBone.rotation = realRootBone.localRotation;
				newBone.scale = realRootBone.localScale;
				//				Debug.Log(newBone.name + "<-"+realRootBone.name);
				newBone.name = realRootBone.name;
				newBones.Add(newBone);

				var rootBoneTransform = umaData.umaRoot.transform;
				newBone = bones[missingBoneCount - 1];
				newBone.position = rootBoneTransform.localPosition;
				newBone.rotation = rootBoneTransform.localRotation;
				newBone.scale = rootBoneTransform.localScale;
				//				Debug.Log(newBone.name + "<-" + rootBoneTransform.name);
				newBone.name = rootBoneTransform.name;
				newBones.Add(newBone);
			}

			for (var i = missingBoneCount; i < bones.Length; i++)
			{
				var skeletonbone = bones[i];
				int boneHash = UMAUtils.StringToHash(skeletonbone.name);
				GameObject boneGO = umaData.skeleton.GetBoneGameObject(boneHash);
				if (boneGO != null)
				{
					skeletonbone.position = boneGO.transform.localPosition;
					skeletonbone.scale = boneGO.transform.localScale;
					skeletonbone.rotation = umaData.skeleton.GetTPoseCorrectedRotation(boneHash, skeletonbone.rotation);
					newBones.Add(skeletonbone);
				}
			}
			bones = newBones.ToArray();
		}

19 Source : UMAMeshData.cs
with Apache License 2.0
from A7ocin

public void UpdateBones(Transform rootBone, Transform[] bones)
		{
			rootBone = FindRoot(rootBone, bones);
			
			var requiredBones = new Dictionary<Transform, UMATransform>();
			foreach (var bone in bones)
			{
				if (requiredBones.ContainsKey(bone)) continue;
				var boneIterator = bone.parent;
				var boneIteratorChild = bone;
				var boneHash = UMAUtils.StringToHash(boneIterator.name);
				var childHash = UMAUtils.StringToHash(boneIteratorChild.name);
				while (boneIteratorChild != rootBone)
				{
					requiredBones.Add(boneIteratorChild, new UMATransform(boneIteratorChild, childHash, boneHash));
					if (requiredBones.ContainsKey(boneIterator)) break;
					boneIteratorChild = boneIterator;
					boneIterator = boneIterator.parent;
					childHash = boneHash;
					boneHash = UMAUtils.StringToHash(boneIterator.name);
				}
			}

			var sortedBones = new List<UMATransform>(requiredBones.Values);
			sortedBones.Sort(UMATransform.TransformComparer);
			umaBones = sortedBones.ToArray();
			umaBoneCount = umaBones.Length;

			rootBoneHash = UMAUtils.StringToHash(rootBone.name);
			ComputeBoneNameHashes(bones);
			this.rootBone = rootBone;
			this.bones = bones;
		}

19 Source : UMAMeshData.cs
with Apache License 2.0
from A7ocin

internal void ReSortUMABones()
		{
			var newList = new List<UMATransform>(umaBones);
			newList.Sort(UMATransform.TransformComparer);
			umaBones = newList.ToArray();
		}

19 Source : UMARecipeBase.cs
with Apache License 2.0
from A7ocin

public static Type[] GetRecipeFormats()
		{
			if (recipeFormats == null)
			{
				var formats = new List<Type>(20);
				var replacedemblies = AppDomain.CurrentDomain.Getreplacedemblies();
				foreach (var replacedembly in replacedemblies)
				{
					var types = replacedembly.GetTypes();
					for (int i = 0; i < types.Length; i++)
					{
						var type = types[i];
						if (type.IsSubclreplacedOf(typeof(UMARecipeBase)) && !type.IsAbstract)
						{
							formats.Add(type);
						}
					}
				}
				recipeFormats = formats.ToArray();
			}
			return recipeFormats;
		}

19 Source : HighlightedInlineBuilder.cs
with MIT License
from Abdesol

public RichText ToRichText()
		{
			return new RichText(text, stateChangeOffsets.ToArray(), stateChanges.Select(FreezableHelper.GetFrozenClone).ToArray());
		}

19 Source : DocumentPrinter.cs
with MIT License
from Abdesol

public static RichText ConvertTextDoreplacedentToRichText(IDoreplacedent doreplacedent, IHighlighter highlighter)
		{
			if (doreplacedent == null)
				throw new ArgumentNullException("doreplacedent");
			var texts = new List<RichText>();
			for (int lineNumber = 1; lineNumber <= doreplacedent.LineCount; lineNumber++) {
				var line = doreplacedent.GetLineByNumber(lineNumber);
				if (lineNumber > 1)
					texts.Add(line.PreviousLine.DelimiterLength == 2 ? "\r\n" : "\n");
				if (highlighter != null) {
					HighlightedLine highlightedLine = highlighter.HighlightLine(lineNumber);
					texts.Add(highlightedLine.ToRichText());
				} else {
					texts.Add(doreplacedent.GetText(line));
				}
			}
			return RichText.Concat(texts.ToArray());
		}

19 Source : TextRangeProvider.cs
with MIT License
from Abdesol

public double[] GetBoundingRectangles()
		{
			Log("{0}.GetBoundingRectangles()", ID);
			var textView = textArea.TextView;
			var source = PresentationSource.FromVisual(this.textArea);
			var result = new List<double>();
			foreach (var rect in BackgroundGeometryBuilder.GetRectsForSegment(textView, segment)) {
				var tl = textView.PointToScreen(rect.TopLeft);
				var br = textView.PointToScreen(rect.BottomRight);
				result.Add(tl.X);
				result.Add(tl.Y);
				result.Add(br.X - tl.X);
				result.Add(br.Y - tl.Y);
			}
			return result.ToArray();
		}

19 Source : Shape.cs
with Microsoft Public License
from abfo

public string[] GetMetadataNames()
        {
            if ((_metadata != null) && (_metadata.Keys.Count > 0))
            {
                List<string> names = new List<string>(_metadata.Keys.Count);
                foreach (string key in _metadata.Keys)
                {
                    names.Add(key);
                }
                return names.ToArray();
            }
            else
            {
                return null;
            }
        }

19 Source : MixedRealityInputActionsProfile.cs
with Apache License 2.0
from abist-co-ltd

public MixedRealityInputAction[] LoadMixedRealityToolKitDefaults()
        {
            var defaultActions = new List<MixedRealityInputAction>();
            bool exists = false;

            for (uint i = 0; i < defaultInputActions.Length; i++)
            {
                defaultActions.Add(new MixedRealityInputAction(i, defaultInputActions[i], defaultInputActionsAxis[i]));
            }

            for (int i = 0; i < inputActions.Length; i++)
            {
                if (defaultActions.Contains(inputActions[i]))
                {
                    exists = true;
                }

                if (!exists)
                {
                    defaultActions.Add(inputActions[i]);
                }

                exists = false;
            }

            return inputActions = defaultActions.ToArray();
        }

19 Source : ProcessExtensions.cs
with Apache License 2.0
from abist-co-ltd

public static async Task<ProcessResult> StartProcessAsync(this Process process, ProcessStartInfo startInfo, bool showDebug = false, CancellationToken cancellationToken = default)
        {
            Debug.replacedert(!startInfo.UseShellExecute, "Process Start Info must not use shell execution.");
            Debug.replacedert(startInfo.RedirectStandardOutput, "Process Start Info must redirect standard output.");
            Debug.replacedert(startInfo.RedirectStandardError, "Process Start Info must redirect standard errors.");

            process.StartInfo = startInfo;
            process.EnableRaisingEvents = true;

            var processResult = new TaskCompletionSource<ProcessResult>();
            var errorCodeResult = new TaskCompletionSource<string[]>();
            var errorList = new List<string>();
            var outputCodeResult = new TaskCompletionSource<string[]>();
            var outputList = new List<string>();

            process.Exited += OnProcessExited;
            process.ErrorDataReceived += OnErrorDataReceived;
            process.OutputDataReceived += OnOutputDataReceived;

            async void OnProcessExited(object sender, EventArgs args)
            {
                processResult.TrySetResult(new ProcessResult(process.ExitCode, await errorCodeResult.Task, await outputCodeResult.Task));
                process.Close();
                process.Dispose();
            }

            void OnErrorDataReceived(object sender, DataReceivedEventArgs args)
            {
                if (args.Data != null)
                {
                    errorList.Add(args.Data);

                    if (!showDebug)
                    {
                        return;
                    }

                    UnityEngine.Debug.LogError(args.Data);
                }
                else
                {
                    errorCodeResult.TrySetResult(errorList.ToArray());
                }
            }

            void OnOutputDataReceived(object sender, DataReceivedEventArgs args)
            {
                if (args.Data != null)
                {
                    outputList.Add(args.Data);

                    if (!showDebug)
                    {
                        return;
                    }

                    UnityEngine.Debug.Log(args.Data);
                }
                else
                {
                    outputCodeResult.TrySetResult(outputList.ToArray());
                }
            }

            if (!process.Start())
            {
                if (showDebug)
                {
                    UnityEngine.Debug.LogError("Failed to start process!");
                }

                processResult.TrySetResult(new ProcessResult(process.ExitCode, new[] { "Failed to start process!" }, null));
            }
            else
            {
                process.BeginOutputReadLine();
                process.BeginErrorReadLine();
                CancellationWatcher(process);
            }

            async void CancellationWatcher(Process _process)
            {
                await Task.Run(() =>
                {
                    try
                    {
                        while (!_process.HasExited)
                        {
                            if (cancellationToken.IsCancellationRequested)
                            {
                                _process.Kill();
                            }
                        }
                    }
                    catch
                    {
                        // ignored
                    }
                });
            }

            return await processResult.Task;
        }

19 Source : MixedRealityGesturesProfileInspector.cs
with Apache License 2.0
from abist-co-ltd

private void UpdateGestureLabels()
        {
            var allGestureTypeNames = Enum.GetNames(typeof(GestureInputType));

            var tempIds = new List<int>();
            var tempContent = new List<GUIContent>();

            for (int i = 0; i < allGestureTypeNames.Length; i++)
            {
                if (allGestureTypeNames[i].Equals("None") ||
                    thisProfile.Gestures.All(mapping => !allGestureTypeNames[i].Equals(mapping.GestureType.ToString())))
                {
                    tempContent.Add(new GUIContent(allGestureTypeNames[i]));
                    tempIds.Add(i);
                }
            }

            allGestureIds = tempIds.ToArray();
            allGestureLabels = tempContent.ToArray();
        }

19 Source : PhysicsLayerAttributeDrawer.cs
with Apache License 2.0
from abist-co-ltd

public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            var guiContents = new List<GUIContent>();
            var layerIds = new List<int>();

            for (int i = 0; i < EditorLayerExtensions.TagManagerLayers.arraySize; i++)
            {
                var layer = EditorLayerExtensions.TagManagerLayers.GetArrayElementAtIndex(i);

                if (!string.IsNullOrWhiteSpace(layer.stringValue))
                {
                    guiContents.Add(new GUIContent($"{i}: {layer.stringValue}"));
                    layerIds.Add(i);
                }
            }

            property.intValue = EditorGUI.IntPopup(position, label, property.intValue, guiContents.ToArray(), layerIds.ToArray());
        }

19 Source : TypeReferencePropertyDrawer.cs
with Apache License 2.0
from abist-co-ltd

private static Type[] FindTypesByName(string typeName, SystemTypeAttribute filter)
        {
            List<Type> types = new List<Type>();
            foreach (Type t in GetFilteredTypes(filter))
            {
                if (t.Name.Equals(typeName))
                {
                    types.Add(t);
                }
            }
            return types.ToArray();
        }

19 Source : MixedRealityProjectConfiguratorWindow.cs
with Apache License 2.0
from abist-co-ltd

private void PromptForAudioSpatializer()
        {
            string selectedSpatializer = MixedRealityProjectConfigurator.SelectedSpatializer;
            List<string> spatializers = new List<string>
            {
                None
            };
            spatializers.AddRange(SpatializerUtilities.InstalledSpatializers);
            RenderDropDown(MRConfig.AudioSpatializer, "Audio spatializer:", spatializers.ToArray(), ref selectedSpatializer);
            MixedRealityProjectConfigurator.SelectedSpatializer = selectedSpatializer;
        }

19 Source : BaseInputDeviceManager.cs
with Apache License 2.0
from abist-co-ltd

protected virtual IMixedRealityPointer[] RequestPointers(SupportedControllerType controllerType, Handedness controllingHand)
        {
            using (RequestPointersPerfMarker.Auto())
            {
                var returnPointers = new List<IMixedRealityPointer>();

                CleanActivePointers();

                for (int i = 0; i < pointerConfigurations.Length; i++)
                {
                    var option = pointerConfigurations[i].profile;
                    if (option.ControllerType.HasFlag(controllerType) && option.Handedness.HasFlag(controllingHand))
                    {
                        IMixedRealityPointer requestedPointer = null;

                        if (EnablePointerCache)
                        {
                            var pointerCache = pointerConfigurations[i].cache;
                            while (pointerCache.Count > 0)
                            {
                                var p = pointerCache.Pop();
                                var pointerComponent = p as MonoBehaviour;
                                if (!UnityObjectExtensions.IsNull(pointerComponent))
                                {
                                    pointerComponent.gameObject.SetActive(true);

                                    // We got pointer from cache, continue to next pointer option to review
                                    requestedPointer = p;
                                    break;
                                }
                            }
                        }

                        if (requestedPointer == null)
                        {
                            // We couldn't obtain a pointer from our cache, resort to creating a new one
                            requestedPointer = CreatePointer(in option);
                        }

                        if (requestedPointer != null)
                        {
                            // Track pointer for recycling
                            activePointersToConfig.Add(requestedPointer, (uint)i);

                            returnPointers.Add(requestedPointer);
                        }
                    }
                }

                return returnPointers.Count == 0 ? null : returnPointers.ToArray();
            }
        }

19 Source : BaseBoundarySystem.cs
with Apache License 2.0
from abist-co-ltd

public GameObject GetTrackedAreaVisualization()
        {
            if (!Application.isPlaying) { return null; }

            if (currentTrackedAreaObject != null)
            {
                return currentTrackedAreaObject;
            }

            MixedRealityBoundaryVisualizationProfile profile = ConfigurationProfile as MixedRealityBoundaryVisualizationProfile;
            if (profile == null) { return null; }

            if (Bounds.Length == 0)
            {
                // If we do not have boundary edges, we cannot render them.
                return null;
            }

            // Get the line vertices
            List<Vector3> lineVertices = new List<Vector3>();
            for (int i = 0; i < Bounds.Length; i++)
            {
                lineVertices.Add(new Vector3(Bounds[i].PointA.x, 0f, Bounds[i].PointA.y));
            }
            // Add the first vertex again to ensure the loop closes.
            lineVertices.Add(lineVertices[0]);

            // We use an empty object and attach a line renderer.
            currentTrackedAreaObject = new GameObject("Tracked Area")
            {
                layer = ignoreRaycastLayerValue
            };
            currentTrackedAreaObject.AddComponent<LineRenderer>();
            currentTrackedAreaObject.transform.Translate(new Vector3(
                MixedRealityPlayspace.Position.x,
                boundaryObjectRenderOffset,
                MixedRealityPlayspace.Position.z));
            currentPlayAreaObject.layer = TrackedAreaPhysicsLayer;

            // Configure the renderer properties.
            float lineWidth = 0.01f;
            LineRenderer lineRenderer = currentTrackedAreaObject.GetComponent<LineRenderer>();
            lineRenderer.sharedMaterial = profile.TrackedAreaMaterial;
            lineRenderer.useWorldSpace = false;
            lineRenderer.startWidth = lineWidth;
            lineRenderer.endWidth = lineWidth;
            lineRenderer.positionCount = lineVertices.Count;
            lineRenderer.SetPositions(lineVertices.ToArray());

            currentTrackedAreaObject.transform.parent = BoundaryVisualizationParent.transform;

            return currentTrackedAreaObject;
        }

19 Source : BaseBoundarySystem.cs
with Apache License 2.0
from abist-co-ltd

private void CalculateBoundaryBounds()
        {
            // Reset the bounds
            Bounds = System.Array.Empty<Edge>();
            FloorHeight = null;
            RectangularBounds = null;

            // Get the boundary geometry.
            var boundaryGeometry = GetBoundaryGeometry();

            if (boundaryGeometry != null && boundaryGeometry.Count > 0)
            {
                // Get the boundary geometry.
                var boundaryEdges = new List<Edge>(0);

                // FloorHeight starts out as null. Use a suitably high value for the floor to ensure
                // that we do not accidentally set it too low.
                float floorHeight = float.MaxValue;

                for (int i = 0; i < boundaryGeometry.Count; i++)
                {
                    Vector3 pointA = boundaryGeometry[i];
                    Vector3 pointB = boundaryGeometry[(i + 1) % boundaryGeometry.Count];
                    boundaryEdges.Add(new Edge(pointA, pointB));

                    floorHeight = Mathf.Min(floorHeight, boundaryGeometry[i].y);
                }

                FloorHeight = floorHeight;
                Bounds = boundaryEdges.ToArray();
                CreateInscribedBounds();
            }
            else
            {
                Debug.LogWarning("Failed to calculate boundary bounds.");
            }
        }

19 Source : BaseDataProviderAccessCoreSystem.cs
with Apache License 2.0
from abist-co-ltd

private bool RegisterDataProviderInternal<T>(
            bool retryWithRegistrar,
            Type concreteType,
            SupportedPlatforms supportedPlatforms = (SupportedPlatforms)(-1),
            params object[] args) where T : IMixedRealityDataProvider
        {
#if !UNITY_EDITOR
            if (!Application.platform.IsPlatformSupported(supportedPlatforms))
#else
            if (!EditorUserBuildSettings.activeBuildTarget.IsPlatformSupported(supportedPlatforms))
#endif
            {
                return false;
            }

            if (concreteType == null)
            {
                Debug.LogError($"Unable to register {typeof(T).Name} service with a null concrete type.");
                return false;
            }

            if (!typeof(IMixedRealityDataProvider).IsreplacedignableFrom(concreteType))
            {
                Debug.LogError($"Unable to register the {concreteType.Name} data provider. It does not implement {typeof(IMixedRealityDataProvider)}.");
                return false;
            }

            T dataProviderInstance;

            try
            {
                dataProviderInstance = (T)Activator.CreateInstance(concreteType, args);
            }
            catch (Exception e)
            {
                if (retryWithRegistrar && (e is MissingMethodException))
                {
                    Debug.LogWarning($"Failed to find an appropriate constructor for the {concreteType.Name} data provider. Adding the Registrar instance and re-attempting registration.");
#pragma warning disable 0618
                    List<object> updatedArgs = new List<object>();
                    updatedArgs.Add(Registrar);
                    if (args != null)
                    {
                        updatedArgs.AddRange(args);
                    }
                    return RegisterDataProviderInternal<T>(
                        false, // Do NOT retry, we have already added the configured IMIxedRealityServiceRegistrar
                        concreteType,
                        supportedPlatforms,
                        updatedArgs.ToArray());
#pragma warning restore 0618
                }

                Debug.LogError($"Failed to register the {concreteType.Name} data provider: {e.GetType()} - {e.Message}");

                // Failures to create the concrete type generally surface as nested exceptions - just logging
                // the top level exception itself may not be helpful. If there is a nested exception (for example,
                // null reference in the constructor of the object itself), it's helpful to also surface those here.
                if (e.InnerException != null)
                {
                    Debug.LogError("Underlying exception information: " + e.InnerException);
                }
                return false;
            }

            return RegisterDataProvider(dataProviderInstance);
        }

19 Source : EditorProjectUtilities.cs
with Apache License 2.0
from abist-co-ltd

private static void ApplyARFoundationUWPCompileFix()
        {
#if !UNITY_2019_1_OR_NEWER
            bool reloadLocked = EditorreplacedemblyReloadManager.LockReloadreplacedemblies;
            if (reloadLocked)
            {
                EditorreplacedemblyReloadManager.LockReloadreplacedemblies = false;
            }

            DirectoryInfo packageCache = FileUtilities.GetPackageCache();

            if (packageCache.Exists)
            {
                string uwpPlatformName = "WSA";

                FileInfo arFoundation = GetPackageCachereplacedemblyDefinitionFile(
                    packageCache,
                    "com.unity.xr.arfoundation@*",
                    "Unity.XR.ARFoundation.asmdef");
                if (arFoundation != null)
                {
                    bool changed = false;

                    replacedemblyDefinition asmDef = replacedemblyDefinition.Load(arFoundation.FullName);

                    if (asmDef.IncludePlatforms.Contains(uwpPlatformName))
                    {
                        Debug.Log($"Removing Universal Windows Platform from the {arFoundation.FullName} included platforms list.");
                        List<string> list = new List<string>(asmDef.IncludePlatforms);
                        list.Remove(uwpPlatformName);
                        asmDef.IncludePlatforms = list.ToArray();
                        changed = true;
                    }
                    else if (!asmDef.ExcludePlatforms.Contains(uwpPlatformName))
                    {
                        Debug.Log($"Adding Universal Windows Platform to the {arFoundation.FullName} excluded platforms list.");
                        List<string> list = new List<string>(asmDef.ExcludePlatforms);
                        list.Add(uwpPlatformName);
                        asmDef.ExcludePlatforms = list.ToArray();
                        changed = true;
                    }

                    if (changed)
                    {
                        asmDef.Save(arFoundation.FullName);
                    }
                }

                FileInfo arSubsystems = GetPackageCachereplacedemblyDefinitionFile(
                    packageCache,
                    "com.unity.xr.arsubsystems@*",
                    "Unity.XR.ARSubsystems.asmdef");
                if (arSubsystems != null)
                {
                    bool changed = false;

                    replacedemblyDefinition asmDef = replacedemblyDefinition.Load(arSubsystems.FullName);

                    if (asmDef.IncludePlatforms.Contains(uwpPlatformName))
                    {
                        Debug.Log($"Removing Universal Windows Platform from the {arSubsystems.FullName} included platforms list.");
                        List<string> list = new List<string>(asmDef.IncludePlatforms);
                        list.Remove(uwpPlatformName);
                        asmDef.IncludePlatforms = list.ToArray();
                        changed = true;
                    }
                    else if (!asmDef.ExcludePlatforms.Contains(uwpPlatformName))
                    {
                        Debug.Log($"Adding Universal Windows Platform to the {arSubsystems.FullName} excluded platforms list.");
                        List<string> list = new List<string>(asmDef.ExcludePlatforms);
                        list.Add(uwpPlatformName);
                        asmDef.ExcludePlatforms = list.ToArray();
                        changed = true;
                    }

                    if (changed)
                    {
                        asmDef.Save(arSubsystems.FullName);
                    }
                }
            }

            if (reloadLocked)
            {
                EditorreplacedemblyReloadManager.LockReloadreplacedemblies = true;
            }

#endif // !UNITY_2019_OR_NEWER
        }

19 Source : LeapMotionConfigurationChecker.cs
with Apache License 2.0
from abist-co-ltd

private static void AddAndUpdateAsmDefs()
        {
            string leapCoreAsmDefPath = Path.Combine(Application.dataPath, pathDifference, "LeapMotion", "LeapMotion.asmdef");

            // If the asmdef has already been created then do not create another one
            if (!File.Exists(leapCoreAsmDefPath))
            {
                // Create the asmdef that will be placed in the Leap Core replacedets when they are imported
                // A new asmdef needs to be created in order to reference it in the MRTK/Providers/LeapMotion/Microsoft.MixedReality.Toolkit.Providers.LeapMotion.asmdef file
                replacedemblyDefinition leapAsmDef = new replacedemblyDefinition
                {
                    Name = "LeapMotion",
                    AllowUnsafeCode = true,
                    References = new string[] { },
                    IncludePlatforms = new string[] { "Editor", "WindowsStandalone32", "WindowsStandalone64"}
                };

                leapAsmDef.Save(leapCoreAsmDefPath);

                // Get the MRTK/Providers/LeapMotion/Microsoft.MixedReality.Toolkit.Providers.LeapMotion.asmdef
                FileInfo[] leapDataProviderAsmDefFile = FileUtilities.FindFilesInreplacedets("Microsoft.MixedReality.Toolkit.Providers.LeapMotion.asmdef");

                // Add the newly created LeapMotion.asmdef to the references of the leap data provider asmdef
                replacedemblyDefinition leapDataProviderAsmDef = replacedemblyDefinition.Load(leapDataProviderAsmDefFile[0].FullName);

                List<string> references = leapDataProviderAsmDef.References.ToList();
                
                if (!references.Contains("LeapMotion"))
                {
                    references.Add("LeapMotion");
                }

                leapDataProviderAsmDef.References = references.ToArray();

                leapDataProviderAsmDef.Save(leapDataProviderAsmDefFile[0].FullName);
            }
        }

See More Examples