private void AddBonesRecursive(Transform transform) { var hash = UMAUtils.StringToHash(transform.name); var parentHash = transform.parent != null?UMAUtils.StringToHash(transform.parent.name) : 0; BoneData data = new BoneData() { parentBoneNameHash = parentHash, boneNameHash = hash, accessedFrame = frame, boneTransform = transform, umaTransform = new UMATransform(transform, hash, parentHash) }; boneHashData.Add(hash, data); boneHashDataBackup.Add(data); for (int i = 0; i < transform.childCount; i++) { var child = transform.GetChild(i); AddBonesRecursive(child); } }
public static int StringToHash(string name) { return(UMAUtils.StringToHash(name)); }
/// <summary> /// Generates a temporary item of type T. It then adds a new DownloadingAssetItem to downloadingItems that contains a refrence to this created temp asset and the name of the asset that it should be replaced by once the given assetbundle has completed downloading. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="requiredAssetName"></param> /// <param name="containingBundle"></param> /// <returns></returns> public T AddDownloadItem <T>(string requiredAssetName, int?requiredAssetNameHash, string containingBundle, Delegate callback = null) where T : UnityEngine.Object { T thisTempAsset = null; if (downloadingItems.Find(item => item.requiredAssetName == requiredAssetName) == null) { if (requiredAssetNameHash == null) { requiredAssetNameHash = UMAUtils.StringToHash(requiredAssetName); } if (typeof(T) == typeof(RaceData)) { thisTempAsset = ScriptableObject.Instantiate(DynamicAssetLoader.Instance.placeholderRace) as T; (thisTempAsset as RaceData).raceName = requiredAssetName; (thisTempAsset as RaceData).name = requiredAssetName; } else if (typeof(T) == typeof(SlotDataAsset)) { thisTempAsset = ScriptableObject.Instantiate(DynamicAssetLoader.Instance.placeholderSlot) as T; (thisTempAsset as SlotDataAsset).name = requiredAssetName; (thisTempAsset as SlotDataAsset).slotName = requiredAssetName; //also needs the name hash (thisTempAsset as SlotDataAsset).nameHash = (int)requiredAssetNameHash; //we can safely force because we just set this above } else if (typeof(T) == typeof(OverlayDataAsset)) { thisTempAsset = ScriptableObject.Instantiate(DynamicAssetLoader.Instance.placeholderOverlay) as T; (thisTempAsset as OverlayDataAsset).name = requiredAssetName; (thisTempAsset as OverlayDataAsset).overlayName = requiredAssetName; (thisTempAsset as OverlayDataAsset).nameHash = (int)requiredAssetNameHash; } else if (typeof(T) == typeof(UMATextRecipe)) { if (AssetBundleManager.AssetBundleIndexObject.IsAssetWardrobeRecipe(containingBundle, requiredAssetName)) { thisTempAsset = ScriptableObject.Instantiate(DynamicAssetLoader.Instance.placeholderWardrobeRecipe) as T; (thisTempAsset as UMATextRecipe).recipeType = "Wardrobe"; (thisTempAsset as UMATextRecipe).wardrobeSlot = AssetBundleManager.AssetBundleIndexObject.AssetWardrobeSlot(containingBundle, requiredAssetName); (thisTempAsset as UMATextRecipe).Hides = AssetBundleManager.AssetBundleIndexObject.AssetWardrobeHides(containingBundle, requiredAssetName); (thisTempAsset as UMATextRecipe).compatibleRaces = AssetBundleManager.AssetBundleIndexObject.AssetWardrobeCompatibleWith(containingBundle, requiredAssetName); } else { thisTempAsset = ScriptableObject.Instantiate(DynamicAssetLoader.Instance.placeholderRace.baseRaceRecipe) as T; } thisTempAsset.name = requiredAssetName; } else if (typeof(T) == typeof(UMAWardrobeRecipe)) { thisTempAsset = ScriptableObject.Instantiate(DynamicAssetLoader.Instance.placeholderWardrobeRecipe) as T; (thisTempAsset as UMAWardrobeRecipe).recipeType = "Wardrobe"; (thisTempAsset as UMAWardrobeRecipe).wardrobeSlot = AssetBundleManager.AssetBundleIndexObject.AssetWardrobeSlot(containingBundle, requiredAssetName); (thisTempAsset as UMAWardrobeRecipe).Hides = AssetBundleManager.AssetBundleIndexObject.AssetWardrobeHides(containingBundle, requiredAssetName); (thisTempAsset as UMAWardrobeRecipe).compatibleRaces = AssetBundleManager.AssetBundleIndexObject.AssetWardrobeCompatibleWith(containingBundle, requiredAssetName); thisTempAsset.name = requiredAssetName; } else if (typeof(T) == typeof(UMAWardrobeCollection)) { thisTempAsset = ScriptableObject.CreateInstance(typeof(T)) as T; (thisTempAsset as UMAWardrobeCollection).recipeType = "WardrobeCollection"; (thisTempAsset as UMAWardrobeCollection).wardrobeSlot = AssetBundleManager.AssetBundleIndexObject.AssetWardrobeCollectionSlot(containingBundle, requiredAssetName); (thisTempAsset as UMAWardrobeCollection).compatibleRaces = AssetBundleManager.AssetBundleIndexObject.AssetWardrobeCollectionCompatibleWith(containingBundle, requiredAssetName); thisTempAsset.name = requiredAssetName; } else if (typeof(T) == typeof(RuntimeAnimatorController)) //Possibly can be removed- just here because we may need to do something else with animators... { thisTempAsset = (T)Activator.CreateInstance(typeof(T)); (thisTempAsset as RuntimeAnimatorController).name = requiredAssetName; } else { //Need to check for ScriptableObjects here because they require different instantiation if (typeof(ScriptableObject).IsAssignableFrom(typeof(T))) { thisTempAsset = ScriptableObject.CreateInstance(typeof(T)) as T; } else { thisTempAsset = (T)Activator.CreateInstance(typeof(T)); } thisTempAsset.name = requiredAssetName; } var thisDlItem = new DownloadingAssetItem(requiredAssetName, thisTempAsset, containingBundle, callback); downloadingItems.Add(thisDlItem); } else { DownloadingAssetItem dlItem = null; if (downloadingItems.Find(item => item.requiredAssetName == requiredAssetName) != null) { dlItem = downloadingItems.Find(item => item.requiredAssetName == requiredAssetName); } if (dlItem != null) { Debug.LogWarning("DownloadingAssetsList already had entry for " + requiredAssetName + " as type " + dlItem.tempAsset.GetType().ToString() + " new request wanted it as type " + typeof(T) + " and its callback was " + dlItem.dynamicCallback[0].Method.Name); if (callback != null) { if (!dlItem.dynamicCallback.Contains(callback)) { dlItem.dynamicCallback.Add(callback); } } thisTempAsset = dlItem.tempAsset as T; } else { Debug.LogWarning("Could not get TempAsset for " + requiredAssetName); } } return(thisTempAsset); }
/// <summary> /// Generates a temporary item of type T. It then adds a new DownloadingAssetItem to downloadingItems that contains a refrence to this created temp asset and the name of the asset that it should be replaced by once the given assetbundle has completed downloading. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="requiredAssetName"></param> /// <param name="containingBundle"></param> /// <returns></returns> public T AddDownloadItem <T>(string requiredAssetName, int?requiredAssetNameHash, string containingBundle, Delegate callback = null) where T : UnityEngine.Object { T thisTempAsset = null; if (downloadingItems.Find(item => item.requiredAssetName == requiredAssetName) == null) { if (requiredAssetNameHash == null) { requiredAssetNameHash = UMAUtils.StringToHash(requiredAssetName); } thisTempAsset = GetTempAsset <T>(); if (typeof(T) == typeof(RaceData)) { (thisTempAsset as RaceData).raceName = requiredAssetName; (thisTempAsset as RaceData).raceName = requiredAssetName; (thisTempAsset as RaceData).name = requiredAssetName; } else if (typeof(T) == typeof(SlotDataAsset)) { (thisTempAsset as SlotDataAsset).name = requiredAssetName; (thisTempAsset as SlotDataAsset).slotName = requiredAssetName; (thisTempAsset as SlotDataAsset).nameHash = (int)requiredAssetNameHash; //we can safely force because we just set this above } else if (typeof(T) == typeof(OverlayDataAsset)) { (thisTempAsset as OverlayDataAsset).name = requiredAssetName; (thisTempAsset as OverlayDataAsset).overlayName = requiredAssetName; (thisTempAsset as OverlayDataAsset).nameHash = (int)requiredAssetNameHash; } else if (typeof(T) == typeof(UMATextRecipe)) { //now that wardrobeRecipes have their own type, we can assume an UMATextRecipe is a full character recipe thisTempAsset.name = requiredAssetName; } else if (typeof(T) == typeof(UMAWardrobeRecipe)) { (thisTempAsset as UMAWardrobeRecipe).recipeType = "Wardrobe"; (thisTempAsset as UMAWardrobeRecipe).wardrobeSlot = AssetBundleManager.AssetBundleIndexObject.AssetWardrobeSlot(containingBundle, requiredAssetName); (thisTempAsset as UMAWardrobeRecipe).Hides = AssetBundleManager.AssetBundleIndexObject.AssetWardrobeHides(containingBundle, requiredAssetName); (thisTempAsset as UMAWardrobeRecipe).compatibleRaces = AssetBundleManager.AssetBundleIndexObject.AssetWardrobeCompatibleWith(containingBundle, requiredAssetName); thisTempAsset.name = requiredAssetName; } else if (typeof(T) == typeof(UMAWardrobeCollection)) { (thisTempAsset as UMAWardrobeCollection).recipeType = "WardrobeCollection"; (thisTempAsset as UMAWardrobeCollection).wardrobeSlot = AssetBundleManager.AssetBundleIndexObject.AssetWardrobeCollectionSlot(containingBundle, requiredAssetName); (thisTempAsset as UMAWardrobeCollection).compatibleRaces = AssetBundleManager.AssetBundleIndexObject.AssetWardrobeCollectionCompatibleWith(containingBundle, requiredAssetName); thisTempAsset.name = requiredAssetName; } else if (typeof(T) == typeof(RuntimeAnimatorController)) { (thisTempAsset as RuntimeAnimatorController).name = requiredAssetName; } else { thisTempAsset.name = requiredAssetName; } var thisDlItem = new DownloadingAssetItem(requiredAssetName, thisTempAsset, containingBundle, callback); downloadingItems.Add(thisDlItem); } else { DownloadingAssetItem dlItem = null; if (downloadingItems.Find(item => item.requiredAssetName == requiredAssetName) != null) { dlItem = downloadingItems.Find(item => item.requiredAssetName == requiredAssetName); } if (dlItem != null) { //Debug.LogWarning("DownloadingAssetsList already had entry for " + requiredAssetName + " as type " + dlItem.tempAsset.GetType().ToString() + " new request wanted it as type " + typeof(T) + " and its callback was " + dlItem.dynamicCallback[0].Method.Name); if (callback != null) { if (!dlItem.dynamicCallback.Contains(callback)) { dlItem.dynamicCallback.Add(callback); } } thisTempAsset = dlItem.tempAsset as T; } else { Debug.LogWarning("Could not get TempAsset for " + requiredAssetName); } } return(thisTempAsset); }
public void OnAfterDeserialize() { nameHash = UMAUtils.StringToHash(overlayName); }
public virtual int GetTypeNameHash() { return(UMAUtils.StringToHash(GetType().Name)); }
public void Initialize() { gameObject.name = "GeometrySelector"; if (_sharedMesh == null) { if (Debug.isDebugBuild) { Debug.LogWarning("GeometrySelector: Initializing with no mesh!"); } return; } if (meshAsset != null) { UMAMeshData meshData = meshAsset.asset.meshData; /* Todo: figure out how to get the races root bone orientation * Transform root = meshData.rootBone; * if (root == null) * { * SkeletonTools.RecursiveFindBone(meshData.bones[0],"Global"); * } */ if (meshData.rootBoneHash == UMAUtils.StringToHash("Global")) { gameObject.transform.localRotation = Quaternion.Euler(-90f, 0f, 0f); } } gameObject.transform.hideFlags = HideFlags.NotEditable | HideFlags.HideInInspector; if (selectedTriangles == null) { selectedTriangles = new BitArray(_sharedMesh.triangles.Length / 3); } if (!gameObject.GetComponent <MeshFilter>()) { MeshFilter meshFilter = gameObject.AddComponent <MeshFilter>(); meshFilter.mesh = _sharedMesh; meshFilter.hideFlags = HideFlags.HideInInspector; } if (!gameObject.GetComponent <MeshRenderer>()) { _meshRenderer = gameObject.AddComponent <MeshRenderer>(); _meshRenderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off; _meshRenderer.receiveShadows = false; _meshRenderer.hideFlags = HideFlags.HideInInspector; } if (!gameObject.GetComponent <MeshCollider>()) { _meshCollider = gameObject.AddComponent <MeshCollider>(); _meshCollider.convex = false; _meshCollider.sharedMesh = _sharedMesh; _meshCollider.hideFlags = HideFlags.HideInInspector; } if (GraphicsSettings.renderPipelineAsset == null) { _Shader = Shader.Find("Standard"); } else { //Expand this to find shaders that work with other SRPs in the future. _Shader = Shader.Find("Unlit/Color"); } if (_Materials == null && _Shader != null) { _Materials = new Material[2]; //Selected _Materials[1] = new Material(_Shader); _Materials[1].name = "Selected"; _Materials[1].color = Color.red; //UnSelected _Materials[0] = new Material(_Shader); _Materials[0].name = "UnSelected"; _Materials[0].color = Color.gray; _sharedMesh.subMeshCount = 2; _meshRenderer.sharedMaterials = _Materials; _meshRenderer.sharedMaterials[0].hideFlags = HideFlags.HideInInspector; _meshRenderer.sharedMaterials[1].hideFlags = HideFlags.HideInInspector; } }
/// <summary> /// Apply the modifiers using the given dna (determined by the typehash) /// </summary> /// <param name="umaData"></param> /// <param name="skeleton"></param> /// <param name="dnaTypeHash"></param> public override void ApplyDNA(UMAData umaData, UMASkeleton skeleton, int dnaTypeHash) { var umaDna = umaData.GetDna(dnaTypeHash); var masterWeightCalc = masterWeight.GetWeight(umaDna); if (masterWeightCalc == 0f) { return; } for (int i = 0; i < _skeletonModifiers.Count; i++) { _skeletonModifiers[i].umaDNA = umaDna; var thisHash = (_skeletonModifiers[i].hash != 0) ? _skeletonModifiers[i].hash : UMAUtils.StringToHash(_skeletonModifiers[i].hashName); //check skeleton has the bone we want to change if (!skeleton.HasBone(thisHash)) { //Debug.LogWarning("You were trying to apply skeleton modifications to a bone that didn't exist (" + _skeletonModifiers[i].hashName + ") on " + umaData.gameObject.name); continue; } //With these ValueX.x is the calculated value and ValueX.y is min and ValueX.z is max var thisValueX = _skeletonModifiers[i].CalculateValueX(umaDna); var thisValueY = _skeletonModifiers[i].CalculateValueY(umaDna); var thisValueZ = _skeletonModifiers[i].CalculateValueZ(umaDna); if (_skeletonModifiers[i].property == SkeletonModifier.SkeletonPropType.Position) { skeleton.SetPositionRelative(thisHash, new Vector3( Mathf.Clamp(thisValueX.x, thisValueX.y, thisValueX.z), Mathf.Clamp(thisValueY.x, thisValueY.y, thisValueY.z), Mathf.Clamp(thisValueZ.x, thisValueZ.y, thisValueZ.z)), masterWeightCalc); } else if (_skeletonModifiers[i].property == SkeletonModifier.SkeletonPropType.Rotation) { skeleton.SetRotationRelative(thisHash, Quaternion.Euler(new Vector3( Mathf.Clamp(thisValueX.x, thisValueX.y, thisValueX.z), Mathf.Clamp(thisValueY.x, thisValueY.y, thisValueY.z), Mathf.Clamp(thisValueZ.x, thisValueZ.y, thisValueZ.z))), masterWeightCalc); } else if (_skeletonModifiers[i].property == SkeletonModifier.SkeletonPropType.Scale) { //If there are two sets of skeletonModifiers and both are at 50% it needs to apply them both but the result should be cumulative //so we need to work out the difference this one is making, weight that and add it to the current scale of the bone var scale = new Vector3( Mathf.Clamp(thisValueX.x, thisValueX.y, thisValueX.z), Mathf.Clamp(thisValueY.x, thisValueY.y, thisValueY.z), Mathf.Clamp(thisValueZ.x, thisValueZ.y, thisValueZ.z)); //we cant use val.value here because the initial values always need to be applied var defaultVal = SkeletonModifier.skelAddDefaults[SkeletonModifier.SkeletonPropType.Scale].x; var scaleDiff = new Vector3(scale.x - defaultVal, scale.y - defaultVal, scale.z - defaultVal); var weightedScaleDiff = scaleDiff * masterWeightCalc; var fullScale = skeleton.GetScale(_skeletonModifiers[i].hash) + weightedScaleDiff; skeleton.SetScale(thisHash, fullScale); } } }
public override void Prepare() { if (builtHashes) { return; } headAdjustHash = UMAUtils.StringToHash("HeadAdjust"); neckAdjustHash = UMAUtils.StringToHash("NeckAdjust"); leftOuterBreastHash = UMAUtils.StringToHash("LeftOuterBreast"); rightOuterBreastHash = UMAUtils.StringToHash("RightOuterBreast"); leftEyeHash = UMAUtils.StringToHash("LeftEye"); rightEyeHash = UMAUtils.StringToHash("RightEye"); leftEyeAdjustHash = UMAUtils.StringToHash("LeftEyeAdjust"); rightEyeAdjustHash = UMAUtils.StringToHash("RightEyeAdjust"); spine1AdjustHash = UMAUtils.StringToHash("Spine1Adjust"); spineAdjustHash = UMAUtils.StringToHash("SpineAdjust"); lowerBackBellyHash = UMAUtils.StringToHash("LowerBackBelly"); lowerBackAdjustHash = UMAUtils.StringToHash("LowerBackAdjust"); leftTrapeziusHash = UMAUtils.StringToHash("LeftTrapezius"); rightTrapeziusHash = UMAUtils.StringToHash("RightTrapezius"); leftArmAdjustHash = UMAUtils.StringToHash("LeftArmAdjust"); rightArmAdjustHash = UMAUtils.StringToHash("RightArmAdjust"); leftForeArmAdjustHash = UMAUtils.StringToHash("LeftForeArmAdjust"); rightForeArmAdjustHash = UMAUtils.StringToHash("RightForeArmAdjust"); leftForeArmTwistAdjustHash = UMAUtils.StringToHash("LeftForeArmTwistAdjust"); rightForeArmTwistAdjustHash = UMAUtils.StringToHash("RightForeArmTwistAdjust"); leftShoulderAdjustHash = UMAUtils.StringToHash("LeftShoulderAdjust"); rightShoulderAdjustHash = UMAUtils.StringToHash("RightShoulderAdjust"); leftUpLegAdjustHash = UMAUtils.StringToHash("LeftUpLegAdjust"); rightUpLegAdjustHash = UMAUtils.StringToHash("RightUpLegAdjust"); leftLegAdjustHash = UMAUtils.StringToHash("LeftLegAdjust"); rightLegAdjustHash = UMAUtils.StringToHash("RightLegAdjust"); leftGluteusHash = UMAUtils.StringToHash("LeftGluteus"); rightGluteusHash = UMAUtils.StringToHash("RightGluteus"); leftEarAdjustHash = UMAUtils.StringToHash("LeftEarAdjust"); rightEarAdjustHash = UMAUtils.StringToHash("RightEarAdjust"); noseBaseAdjustHash = UMAUtils.StringToHash("NoseBaseAdjust"); noseMiddleAdjustHash = UMAUtils.StringToHash("NoseMiddleAdjust"); leftNoseAdjustHash = UMAUtils.StringToHash("LeftNoseAdjust"); rightNoseAdjustHash = UMAUtils.StringToHash("RightNoseAdjust"); upperLipsAdjustHash = UMAUtils.StringToHash("UpperLipsAdjust"); mandibleAdjustHash = UMAUtils.StringToHash("MandibleAdjust"); leftLowMaxilarAdjustHash = UMAUtils.StringToHash("LeftLowMaxilarAdjust"); rightLowMaxilarAdjustHash = UMAUtils.StringToHash("RightLowMaxilarAdjust"); leftCheekAdjustHash = UMAUtils.StringToHash("LeftCheekAdjust"); rightCheekAdjustHash = UMAUtils.StringToHash("RightCheekAdjust"); leftLowCheekAdjustHash = UMAUtils.StringToHash("LeftLowCheekAdjust"); rightLowCheekAdjustHash = UMAUtils.StringToHash("RightLowCheekAdjust"); noseTopAdjustHash = UMAUtils.StringToHash("NoseTopAdjust"); leftEyebrowLowAdjustHash = UMAUtils.StringToHash("LeftEyebrowLowAdjust"); rightEyebrowLowAdjustHash = UMAUtils.StringToHash("RightEyebrowLowAdjust"); leftEyebrowMiddleAdjustHash = UMAUtils.StringToHash("LeftEyebrowMiddleAdjust"); rightEyebrowMiddleAdjustHash = UMAUtils.StringToHash("RightEyebrowMiddleAdjust"); leftEyebrowUpAdjustHash = UMAUtils.StringToHash("LeftEyebrowUpAdjust"); rightEyebrowUpAdjustHash = UMAUtils.StringToHash("RightEyebrowUpAdjust"); lipsSuperiorAdjustHash = UMAUtils.StringToHash("LipsSuperiorAdjust"); lipsInferiorAdjustHash = UMAUtils.StringToHash("LipsInferiorAdjust"); leftLipsSuperiorMiddleAdjustHash = UMAUtils.StringToHash("LeftLipsSuperiorMiddleAdjust"); rightLipsSuperiorMiddleAdjustHash = UMAUtils.StringToHash("RightLipsSuperiorMiddleAdjust"); leftLipsInferiorAdjustHash = UMAUtils.StringToHash("LeftLipsInferiorAdjust"); rightLipsInferiorAdjustHash = UMAUtils.StringToHash("RightLipsInferiorAdjust"); leftLipsAdjustHash = UMAUtils.StringToHash("LeftLipsAdjust"); rightLipsAdjustHash = UMAUtils.StringToHash("RightLipsAdjust"); globalHash = UMAUtils.StringToHash("Global"); positionHash = UMAUtils.StringToHash("Position"); lowerBackHash = UMAUtils.StringToHash("LowerBack"); headHash = UMAUtils.StringToHash("Head"); leftArmHash = UMAUtils.StringToHash("LeftArm"); rightArmHash = UMAUtils.StringToHash("RightArm"); leftForeArmHash = UMAUtils.StringToHash("LeftForeArm"); rightForeArmHash = UMAUtils.StringToHash("RightForeArm"); leftHandHash = UMAUtils.StringToHash("LeftHand"); rightHandHash = UMAUtils.StringToHash("RightHand"); leftFootHash = UMAUtils.StringToHash("LeftFoot"); rightFootHash = UMAUtils.StringToHash("RightFoot"); leftUpLegHash = UMAUtils.StringToHash("LeftUpLeg"); rightUpLegHash = UMAUtils.StringToHash("RightUpLeg"); leftShoulderHash = UMAUtils.StringToHash("LeftShoulder"); rightShoulderHash = UMAUtils.StringToHash("RightShoulder"); mandibleHash = UMAUtils.StringToHash("Mandible"); builtHashes = true; }
/// <summary> /// Gets the game object for a bone by name. /// </summary> /// <returns>The game object (or null if hash not in skeleton).</returns> /// <param name="boneName">Bone name.</param> public GameObject GetBoneGameObject(string boneName) { return(GetBoneGameObject(UMAUtils.StringToHash(boneName))); }
public HashListItem(string nameToAdd) { hashName = nameToAdd; hash = UMAUtils.StringToHash(nameToAdd); }
public void Initialize() { gameObject.name = "GeometrySelector"; if (_sharedMesh == null) { Debug.LogWarning("GeometrySelector: Initializing with no mesh!"); return; } if (meshAsset != null) { if (meshAsset.asset.meshData.rootBoneHash == UMAUtils.StringToHash("Global")) { gameObject.transform.localRotation = Quaternion.Euler(-90f, 0f, 0f); } } gameObject.transform.hideFlags = HideFlags.NotEditable | HideFlags.HideInInspector; if (selectedTriangles == null) { selectedTriangles = new BitArray(_sharedMesh.triangles.Length / 3); } if (!gameObject.GetComponent <MeshFilter>()) { MeshFilter meshFilter = gameObject.AddComponent <MeshFilter>(); meshFilter.mesh = _sharedMesh; meshFilter.hideFlags = HideFlags.HideInInspector; } if (!gameObject.GetComponent <MeshRenderer>()) { _meshRenderer = gameObject.AddComponent <MeshRenderer>(); _meshRenderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off; _meshRenderer.receiveShadows = false; _meshRenderer.hideFlags = HideFlags.HideInInspector; } if (!gameObject.GetComponent <MeshCollider>()) { _meshCollider = gameObject.AddComponent <MeshCollider>(); _meshCollider.convex = false; _meshCollider.sharedMesh = _sharedMesh; _meshCollider.hideFlags = HideFlags.HideInInspector; } if (_Materials == null) { _Materials = new Material[2]; //Selected _Materials[1] = new Material(Shader.Find("Standard")); _Materials[1].name = "Selected"; _Materials[1].color = Color.red; //UnSelected _Materials[0] = new Material(Shader.Find("Standard")); _Materials[0].name = "UnSelected"; _Materials[0].color = Color.gray; _sharedMesh.subMeshCount = 2; _meshRenderer.sharedMaterials = _Materials; _meshRenderer.sharedMaterials[0].hideFlags = HideFlags.HideInInspector; _meshRenderer.sharedMaterials[1].hideFlags = HideFlags.HideInInspector; } }
#pragma warning restore 618 public override bool HasSlot(string name) { ValidateDictionary(); return(slotDictionary.ContainsKey(UMAUtils.StringToHash(name))); }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { EditorGUI.BeginProperty(position, label, property); Init(property); if (!_manuallyConfigured) { if (this.fieldInfo != null) { var attrib = this.fieldInfo.GetCustomAttributes(typeof(BaseCharacterModifier.ConfigAttribute), true).FirstOrDefault() as BaseCharacterModifier.ConfigAttribute; if (attrib != null) { _alwaysExpanded = attrib.alwaysExpanded; } } } if (!_alwaysExpanded) { var foldoutRect = new Rect(position.xMin, position.yMin, position.width, (EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing)); property.isExpanded = EditorGUI.Foldout(foldoutRect, property.isExpanded, label); } if (property.isExpanded || _alwaysExpanded) { EditorGUI.indentLevel++; position = EditorGUI.IndentedRect(position); if (!_alwaysExpanded) { position.yMin = position.yMin + (EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing); } // Don't make child fields be indented var indent = EditorGUI.indentLevel; EditorGUI.indentLevel = 0; var adjustScaleProp = property.FindPropertyRelative("_adjustScale"); var adjustHeightProp = property.FindPropertyRelative("_adjustHeight"); var adjustRadiusProp = property.FindPropertyRelative("_adjustRadius"); var adjustMassProp = property.FindPropertyRelative("_adjustMass"); var updateBoundsProp = property.FindPropertyRelative("_updateBounds"); var tightenBoundsProp = property.FindPropertyRelative("_tightenBounds"); var adjustBoundsProp = property.FindPropertyRelative("_adjustBounds"); var scaleAdjustProp = property.FindPropertyRelative("_scale"); var scaleBoneProp = property.FindPropertyRelative("_bone"); var scaleBoneHashProp = property.FindPropertyRelative("_scaleBoneHash"); var headRatioProp = property.FindPropertyRelative("_headRatio"); var radiusAdjustYProp = property.FindPropertyRelative("_radiusAdjustY"); var radiusAdjustProp = property.FindPropertyRelative("_radiusAdjust"); var massAdjustProp = property.FindPropertyRelative("_massAdjust"); var boundAdjustProp = property.FindPropertyRelative("_boundsAdjust"); //overall rects var scaleRect = new Rect(position.xMin, position.yMin, position.width, (EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing)); var heightRect = new Rect(position.xMin, scaleRect.yMax, position.width, (EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing)); var radiusRect = new Rect(position.xMin, heightRect.yMax, position.width, (EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing)); var massRect = new Rect(position.xMin, radiusRect.yMax, position.width, (EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing)); var boundsBoolsRect = new Rect(position.xMin, massRect.yMax, position.width, (EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing)); //labelsRects are all 120f wide or maybe 1/3rd or whatever unity makes them by standard var scaleLabelRect = new Rect(position.xMin, scaleRect.yMin, (position.width / 3), scaleRect.height); var heightLabelRect = new Rect(position.xMin, heightRect.yMin, (position.width / 3), scaleRect.height); var radiusLabelRect = new Rect(position.xMin, radiusRect.yMin, (position.width / 3), scaleRect.height); var massLabelRect = new Rect(position.xMin, massRect.yMin, (position.width / 3), scaleRect.height); var boundsLabelRect = new Rect(position.xMin, boundsBoolsRect.yMin, (position.width / 3), scaleRect.height); var boundsLabel1Rect = new Rect(boundsLabelRect.xMax, boundsBoolsRect.yMin, (position.width / 3), scaleRect.height); var boundsLabel2Rect = new Rect(position.xMin, boundsBoolsRect.yMax, (position.width / 3), scaleRect.height); //fieldsRects are whatever is left var scaleFieldsRect = new Rect(scaleLabelRect.xMax, scaleRect.yMin, (position.width / 3) * 2, scaleRect.height); var scaleFields1FieldRect = new Rect(scaleFieldsRect.xMin, scaleFieldsRect.yMin, (scaleFieldsRect.width / 3), EditorGUIUtility.singleLineHeight); var scaleFields2LabelRect = new Rect(scaleFields1FieldRect.xMax, scaleFieldsRect.yMin, 40f, EditorGUIUtility.singleLineHeight); var scaleFields2FieldRect = new Rect(scaleFields2LabelRect.xMax, scaleFieldsRect.yMin, ((scaleFieldsRect.width / 3) * 2) - 40f, EditorGUIUtility.singleLineHeight); var heightFieldsRect = new Rect(scaleLabelRect.xMax, heightRect.yMin, (position.width / 3) * 2, scaleRect.height); var heightFields1FieldRect = new Rect(heightFieldsRect.xMin, heightFieldsRect.yMin, ((heightFieldsRect.width / 3) * 2), EditorGUIUtility.singleLineHeight); var heightFields2FieldRect = new Rect(heightFields1FieldRect.xMax, heightFieldsRect.yMin, (heightFieldsRect.width / 3), EditorGUIUtility.singleLineHeight); var radiusFieldsRect = new Rect(scaleLabelRect.xMax, radiusRect.yMin, (position.width / 3) * 2, scaleRect.height); var radiusFields1FieldRect = new Rect(radiusFieldsRect.xMin, radiusFieldsRect.yMin, (radiusFieldsRect.width / 2), EditorGUIUtility.singleLineHeight); var radiusFields2FieldRect = new Rect(radiusFields1FieldRect.xMax, radiusFieldsRect.yMin, (radiusFieldsRect.width / 2), EditorGUIUtility.singleLineHeight); var massFieldsRect = new Rect(scaleLabelRect.xMax, massRect.yMin, (position.width / 3) * 2, scaleRect.height); var boundsFieldsRect = new Rect(scaleLabelRect.xMax, boundsBoolsRect.yMax, (position.width / 3) * 2, scaleRect.height); float prevlabelWidth = EditorGUIUtility.labelWidth; //you loose the tooltips when you do toggleLeft WTFF?!? //none of the tooltips show in play mode either!! What a f*****g pain... var scaleLabel = EditorGUI.BeginProperty(scaleLabelRect, new GUIContent(adjustScaleProp.displayName), adjustScaleProp); adjustScaleProp.boolValue = EditorGUI.ToggleLeft(scaleLabelRect, scaleLabel, adjustScaleProp.boolValue); EditorGUI.EndProperty(); EditorGUI.BeginDisabledGroup(!adjustScaleProp.boolValue); EditorGUIUtility.labelWidth = 40f; if (Application.isPlaying && _target.liveScale != -1) { EditorGUI.BeginDisabledGroup(true); EditorGUI.LabelField(scaleFields1FieldRect, new GUIContent("Scale", "The live scale is being modified by a converter above. Please exit playmode if you want to edit the base scale")); var fieldRect = new Rect(scaleFields1FieldRect.xMin + 40f, scaleFields1FieldRect.yMin, scaleFields1FieldRect.width - 40f, scaleFields1FieldRect.height); EditorGUI.FloatField(fieldRect, _target.liveScale); EditorGUI.EndDisabledGroup(); } else { scaleAdjustProp.floatValue = EditorGUI.FloatField(scaleFields1FieldRect, "Scale", scaleAdjustProp.floatValue); } EditorGUI.LabelField(scaleFields2LabelRect, " Bone"); EditorGUI.BeginChangeCheck(); //I want this to draw a bone selection popup when it can- i.e. when drawn inside a ConverterBehaviour and we are in play mode. scaleBoneProp.stringValue = EditorGUI.TextField(scaleFields2FieldRect, scaleBoneProp.stringValue); if (EditorGUI.EndChangeCheck()) { scaleBoneHashProp.intValue = UMAUtils.StringToHash(scaleBoneProp.stringValue); } EditorGUI.EndDisabledGroup(); var heightLabel = EditorGUI.BeginProperty(heightLabelRect, new GUIContent(adjustHeightProp.displayName), adjustHeightProp); adjustHeightProp.boolValue = EditorGUI.ToggleLeft(heightLabelRect, heightLabel, adjustHeightProp.boolValue); EditorGUI.EndProperty(); EditorGUI.BeginDisabledGroup(!adjustHeightProp.boolValue); EditorGUIUtility.labelWidth = 80f; headRatioProp.floatValue = EditorGUI.FloatField(heightFields1FieldRect, "Head Ratio", headRatioProp.floatValue); EditorGUIUtility.labelWidth = 20f; radiusAdjustYProp.floatValue = EditorGUI.FloatField(heightFields2FieldRect, " Y ", radiusAdjustYProp.floatValue); EditorGUI.EndDisabledGroup(); var radiusLabel = EditorGUI.BeginProperty(radiusLabelRect, new GUIContent(adjustRadiusProp.displayName), adjustRadiusProp); adjustRadiusProp.boolValue = EditorGUI.ToggleLeft(radiusLabelRect, radiusLabel, adjustRadiusProp.boolValue); EditorGUI.EndProperty(); EditorGUI.BeginDisabledGroup(!adjustRadiusProp.boolValue); var radiusV2 = radiusAdjustProp.vector2Value; EditorGUI.BeginChangeCheck(); radiusV2.x = EditorGUI.FloatField(radiusFields1FieldRect, "X ", radiusV2.x); radiusV2.y = EditorGUI.FloatField(radiusFields2FieldRect, " Z ", radiusV2.y); if (EditorGUI.EndChangeCheck()) { radiusAdjustProp.vector2Value = radiusV2; } EditorGUI.EndDisabledGroup(); var massLabel = EditorGUI.BeginProperty(massLabelRect, new GUIContent(adjustMassProp.displayName), adjustMassProp); adjustMassProp.boolValue = EditorGUI.ToggleLeft(massLabelRect, massLabel, adjustMassProp.boolValue); EditorGUI.EndProperty(); EditorGUI.BeginDisabledGroup(!adjustMassProp.boolValue); EditorGUI.PropertyField(massFieldsRect, massAdjustProp, GUIContent.none); EditorGUI.EndDisabledGroup(); var boundsLabel = EditorGUI.BeginProperty(boundsLabelRect, new GUIContent(updateBoundsProp.displayName), updateBoundsProp); updateBoundsProp.boolValue = EditorGUI.ToggleLeft(boundsLabelRect, boundsLabel, updateBoundsProp.boolValue); EditorGUI.EndProperty(); var boundsLabel1 = EditorGUI.BeginProperty(boundsLabelRect, new GUIContent(tightenBoundsProp.displayName), tightenBoundsProp); tightenBoundsProp.boolValue = EditorGUI.ToggleLeft(boundsLabel1Rect, boundsLabel1, tightenBoundsProp.boolValue); EditorGUI.EndProperty(); var boundsLabel2 = EditorGUI.BeginProperty(boundsLabel2Rect, new GUIContent(adjustBoundsProp.displayName), adjustBoundsProp); adjustBoundsProp.boolValue = EditorGUI.ToggleLeft(boundsLabel2Rect, boundsLabel2, adjustBoundsProp.boolValue); EditorGUI.EndProperty(); EditorGUI.BeginDisabledGroup(!adjustBoundsProp.boolValue); EditorGUI.PropertyField(boundsFieldsRect, boundAdjustProp, GUIContent.none); EditorGUI.EndDisabledGroup(); property.serializedObject.ApplyModifiedProperties(); EditorGUIUtility.labelWidth = prevlabelWidth; // Set indent back to what it was EditorGUI.indentLevel = indent; EditorGUI.indentLevel--; } EditorGUI.EndProperty(); }
public override void Prepare() { if (builtHashes) { return; } /* * man's config must be same with woman's config, * you must change this script if you change 3d resources' names */ headAdjustHash = UMAUtils.StringToHash("HeadAdjust"); neckAdjustHash = UMAUtils.StringToHash("NeckAdjust"); leftOuterBreastHash = UMAUtils.StringToHash("LeftOuterBreast"); rightOuterBreastHash = UMAUtils.StringToHash("RightOuterBreast"); leftEyeHash = UMAUtils.StringToHash("LeftEye"); rightEyeHash = UMAUtils.StringToHash("RightEye"); leftEyeAdjustHash = UMAUtils.StringToHash("LeftEyeAdjust"); rightEyeAdjustHash = UMAUtils.StringToHash("RightEyeAdjust"); spine1AdjustHash = UMAUtils.StringToHash("Spine1Adjust"); spineAdjustHash = UMAUtils.StringToHash("SpineAdjust"); lowerBackBellyHash = UMAUtils.StringToHash("LowerBackBelly"); lowerBackAdjustHash = UMAUtils.StringToHash("LowerBackAdjust"); leftTrapeziusHash = UMAUtils.StringToHash("LeftTrapezius"); rightTrapeziusHash = UMAUtils.StringToHash("RightTrapezius"); leftArmAdjustHash = UMAUtils.StringToHash("LeftArmAdjust"); rightArmAdjustHash = UMAUtils.StringToHash("RightArmAdjust"); leftForeArmAdjustHash = UMAUtils.StringToHash("LeftForeArmAdjust"); rightForeArmAdjustHash = UMAUtils.StringToHash("RightForeArmAdjust"); leftForeArmTwistAdjustHash = UMAUtils.StringToHash("LeftForeArmTwistAdjust"); rightForeArmTwistAdjustHash = UMAUtils.StringToHash("RightForeArmTwistAdjust"); leftShoulderAdjustHash = UMAUtils.StringToHash("LeftShoulderAdjust"); rightShoulderAdjustHash = UMAUtils.StringToHash("RightShoulderAdjust"); leftUpLegAdjustHash = UMAUtils.StringToHash("LeftUpLegAdjust"); rightUpLegAdjustHash = UMAUtils.StringToHash("RightUpLegAdjust"); leftLegAdjustHash = UMAUtils.StringToHash("LeftLegAdjust"); rightLegAdjustHash = UMAUtils.StringToHash("RightLegAdjust"); leftGluteusHash = UMAUtils.StringToHash("LeftGluteus"); rightGluteusHash = UMAUtils.StringToHash("RightGluteus"); leftEarAdjustHash = UMAUtils.StringToHash("LeftEarAdjust"); rightEarAdjustHash = UMAUtils.StringToHash("RightEarAdjust"); noseBaseAdjustHash = UMAUtils.StringToHash("NoseBaseAdjust"); noseMiddleAdjustHash = UMAUtils.StringToHash("NoseMiddleAdjust"); leftNoseAdjustHash = UMAUtils.StringToHash("LeftNoseAdjust"); rightNoseAdjustHash = UMAUtils.StringToHash("RightNoseAdjust"); upperLipsAdjustHash = UMAUtils.StringToHash("UpperLipsAdjust"); mandibleAdjustHash = UMAUtils.StringToHash("MandibleAdjust"); leftLowMaxilarAdjustHash = UMAUtils.StringToHash("LeftLowMaxilarAdjust"); rightLowMaxilarAdjustHash = UMAUtils.StringToHash("RightLowMaxilarAdjust"); leftCheekAdjustHash = UMAUtils.StringToHash("LeftCheekAdjust"); rightCheekAdjustHash = UMAUtils.StringToHash("RightCheekAdjust"); leftLowCheekAdjustHash = UMAUtils.StringToHash("LeftLowCheekAdjust"); rightLowCheekAdjustHash = UMAUtils.StringToHash("RightLowCheekAdjust"); noseTopAdjustHash = UMAUtils.StringToHash("NoseTopAdjust"); leftEyebrowLowAdjustHash = UMAUtils.StringToHash("LeftEyebrowLowAdjust"); rightEyebrowLowAdjustHash = UMAUtils.StringToHash("RightEyebrowLowAdjust"); leftEyebrowMiddleAdjustHash = UMAUtils.StringToHash("LeftEyebrowMiddleAdjust"); rightEyebrowMiddleAdjustHash = UMAUtils.StringToHash("RightEyebrowMiddleAdjust"); leftEyebrowUpAdjustHash = UMAUtils.StringToHash("LeftEyebrowUpAdjust"); rightEyebrowUpAdjustHash = UMAUtils.StringToHash("RightEyebrowUpAdjust"); lipsSuperiorAdjustHash = UMAUtils.StringToHash("LipsSuperiorAdjust"); lipsInferiorAdjustHash = UMAUtils.StringToHash("LipsInferiorAdjust"); leftLipsSuperiorMiddleAdjustHash = UMAUtils.StringToHash("LeftLipsSuperiorMiddleAdjust"); rightLipsSuperiorMiddleAdjustHash = UMAUtils.StringToHash("RightLipsSuperiorMiddleAdjust"); leftLipsInferiorAdjustHash = UMAUtils.StringToHash("LeftLipsInferiorAdjust"); rightLipsInferiorAdjustHash = UMAUtils.StringToHash("RightLipsInferiorAdjust"); leftLipsAdjustHash = UMAUtils.StringToHash("LeftLipsAdjust"); rightLipsAdjustHash = UMAUtils.StringToHash("RightLipsAdjust"); globalHash = UMAUtils.StringToHash("Global"); positionHash = UMAUtils.StringToHash("Position"); lowerBackHash = UMAUtils.StringToHash("LowerBack"); //headHash = UMAUtils.StringToHash("Head"); headHash = UMAUtils.StringToHash("Bip001 Head"); leftArmHash = UMAUtils.StringToHash("LeftArm"); rightArmHash = UMAUtils.StringToHash("RightArm"); leftForeArmHash = UMAUtils.StringToHash("LeftForeArm"); rightForeArmHash = UMAUtils.StringToHash("RightForeArm"); leftHandHash = UMAUtils.StringToHash("LeftHand"); rightHandHash = UMAUtils.StringToHash("RightHand"); //leftFootHash = UMAUtils.StringToHash("LeftFoot"); leftFootHash = UMAUtils.StringToHash("Bip001 L Foot"); //rightFootHash = UMAUtils.StringToHash("RightFoot"); rightFootHash = UMAUtils.StringToHash("Bip001 R Foot"); leftUpLegHash = UMAUtils.StringToHash("LeftUpLeg"); rightUpLegHash = UMAUtils.StringToHash("RightUpLeg"); leftShoulderHash = UMAUtils.StringToHash("LeftShoulder"); rightShoulderHash = UMAUtils.StringToHash("RightShoulder"); mandibleHash = UMAUtils.StringToHash("Mandible"); builtHashes = true; }