コード例 #1
0
    protected void LateUpdate()
    {
        int   eyesOpen   = DataStore.GetIntValue("me:eyes:open", 70);
        float morphValue = (70f - eyesOpen);

        charMgr.SetBlendshapeValue("eCTRLEyesClosed", morphValue);
    }
コード例 #2
0
 private void OnTriggerEnter(Collider other)
 {
     m_CharacterManager = GetComponent <M3DCharacterManager>();
     if (other.gameObject.CompareTag("Pick Up"))
     {
         other.gameObject.SetActive(false);
         count++;
         m_CharacterManager.SetBlendshapeValue("FBMHeavy", count * (100.0f / 12));
     }
 }
コード例 #3
0
    // Update is called once per frame
    void Update()
    {
        if (!procurarAvatar || SceneManager.GetActiveScene().name != "Provador")
        {
            return;
        }
        try
        {
            CorpoCtrl = GameObject.Find("avatar").GetComponent <M3DCharacterManager>();
        }
        catch (UnityException ue)
        {
            Debug.LogWarning(ue);
            return;
        }

        foreach (string s in valores)
        {
            string[] split = s.Split('#');
            CorpoCtrl.SetBlendshapeValue(split[0], float.Parse(split[1]));
        }

        procurarAvatar = false;
    }
コード例 #4
0
 public void controlaGordura()
 {
     CorpoCtrl.SetBlendshapeValue("FBMHeavy", slider.value);
 }
コード例 #5
0
        public override void OnInspectorGUI()
        {
            #region just_stuff
            serializedObject.Update();
            if (charMan == null)
            {
                charMan = (M3DCharacterManager)target;
            }


            if (charMan == null || !charMan.isAwake)
            {
                GUILayout.Label("Your figure must be in the scene to edit settings");
                return;
            }

            #endregion just_stuff


            #region LOD
            float lod;
            lod = EditorGUILayout.Slider("LOD", charMan.currentLODLevel, 0, 1);
            if (lod != charMan.currentLODLevel)
            {
                Undo.RecordObject(charMan, "Change LOD");
                charMan.SetLODLevel(lod);
                EditorUtility.SetDirty(charMan);
            }
            EditorGUILayout.Space();
            #endregion LOD

            #region morphs
            showMorphs = EditorGUILayout.Foldout(showMorphs, "Morphs");
            if (showMorphs)
            {
                charMan.coreMorphs.SortIfNeeded();
                EditorGUI.indentLevel++;

                GUILayout.BeginHorizontal();
                selectedBlendShape = GUILayout.TextField(selectedBlendShape, GUI.skin.FindStyle("ToolbarSeachTextField"));
                if (GUILayout.Button("", GUI.skin.FindStyle("ToolbarSeachCancelButton")))
                {
                    selectedBlendShape = "";
                    GUI.FocusControl(null);
                }
                GUILayout.EndHorizontal();
                EditorGUILayout.Space();

                if (GUILayout.Button("Reset All"))
                {
                    Undo.RecordObject(charMan, "Change Morph");
                    for (int i = 0; i < charMan.coreMorphs.morphs.Count; i++)
                    {
                        if (charMan.coreMorphs.morphs[i].attached)
                        {
                            charMan.SetBlendshapeValue(charMan.coreMorphs.morphs[i].name, 0);
                        }
                    }
                    EditorUtility.SetDirty(charMan);
                }
                EditorGUILayout.Space();
                if (GUILayout.Button("Detach All"))
                {
                    Undo.RecordObject(charMan, "Detach All Morphs");
                    charMan.RemoveAllMorphs();
                    EditorUtility.SetDirty(charMan);
                }
                EditorGUILayout.Space();

                List <MORPH3D.FOUNDATIONS.Morph> dirtyMorphValues       = new List <MORPH3D.FOUNDATIONS.Morph>();
                List <MORPH3D.FOUNDATIONS.Morph> dirtyMorphAttachments  = new List <MORPH3D.FOUNDATIONS.Morph>();
                List <MORPH3D.FOUNDATIONS.Morph> dirtyMorphDettachments = new List <MORPH3D.FOUNDATIONS.Morph>();

                EditorMorphs(charMan.coreMorphs.morphs, dirtyMorphValues, dirtyMorphAttachments, dirtyMorphDettachments);

                if (dirtyMorphDettachments.Count > 0 || dirtyMorphAttachments.Count > 0 || dirtyMorphValues.Count > 0)
                {
                    charMan.coreMorphs.DettachMorphs(dirtyMorphDettachments.ToArray());
                    charMan.coreMorphs.AttachMorphs(dirtyMorphAttachments.ToArray());
                    charMan.coreMorphs.SyncMorphValues(dirtyMorphValues.ToArray());
                    charMan.SyncAllBlendShapes();
                }

                EditorGUILayout.Space();
                EditorGUI.indentLevel--;
            }
            #endregion

            #region Morph Groups

            var morphTypeGroup = FOUNDATIONS.MorphTypeGroupService.GetMorphTypeGroups(charMan.gameObject.name);
            if (morphTypeGroup != null)
            {
                showMorphTypeGroups = EditorGUILayout.Foldout(showMorphTypeGroups, "Morph Groups");
                if (showMorphTypeGroups)
                {
                    charMan.coreMorphs.SortIfNeeded();
                    EditorGUI.indentLevel++;
                    foreach (var group in morphTypeGroup.SubGroups.Values)
                    {
                        ShowMorphTypeGroup(group);
                    }
                    EditorGUI.indentLevel--;
                }
            }

            #endregion

            #region contentPacks
            showContentPacks = EditorGUILayout.Foldout(showContentPacks, "Content Packs");

            if (showContentPacks)
            {
                EditorGUI.indentLevel++;
                List <ContentPack> allPacks = charMan.GetAllContentPacks();
                for (int i = 0; i < allPacks.Count; i++)
                {
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.LabelField(allPacks[i].name);
                    if (GUILayout.Button("X"))
                    {
                        Undo.RecordObject(charMan, "Remove Bundle");
                        charMan.RemoveContentPack(allPacks[i]);
                        EditorUtility.SetDirty(charMan);
                    }
                    EditorGUILayout.EndHorizontal();
                }

                /*
                 * CostumeItem tempPack = null;
                 *              tempPack = (CostumeItem)EditorGUILayout.ObjectField("New", tempPack, typeof(CostumeItem), true);
                 *              if(tempPack != null)
                 *              {
                 *                      ContentPack packScript = new ContentPack(tempPack.gameObject);
                 *                      Undo.RecordObject(charMan, "Add Bundle");
                 *                      charMan.AddContentPack(packScript);
                 *                      EditorUtility.SetDirty(charMan);
                 *              }
                 */
                GameObject tempPack = null;
                tempPack = (GameObject)EditorGUILayout.ObjectField("New", tempPack, typeof(GameObject), true);
                if (tempPack != null)
                {
                    string tPPath = AssetDatabase.GetAssetPath(tempPack);
                    if (tPPath.EndsWith(".fbx"))
                    {
                        //if we dropped an fbx, try replacing it with a matching .prefab instead
                        tPPath = tPPath.Replace(".fbx", ".prefab");
                        GameObject prefabObj = AssetDatabase.LoadAssetAtPath <GameObject>(tPPath);
                        if (prefabObj != null)
                        {
                            tempPack = prefabObj;
                        }
                    }
                    ContentPack packScript = new ContentPack(tempPack);
                    Undo.RecordObject(charMan, "Add Bundle");
                    charMan.AddContentPack(packScript);
                    EditorUtility.SetDirty(charMan);
                }


                if (GUILayout.Button("Import Selected From Project Pane"))
                {
                    string[]      guids = Selection.assetGUIDs;
                    List <string> paths = new List <string>();
                    foreach (string guid in guids)
                    {
                        string path = AssetDatabase.GUIDToAssetPath(guid);

                        if (System.IO.Directory.Exists(path))
                        {
                            string[] prefabPaths = System.IO.Directory.GetFiles(path, "*.prefab", System.IO.SearchOption.AllDirectories);
                            for (int i = 0; i < prefabPaths.Length; i++)
                            {
                                string dirtyPath = prefabPaths[i];
                                dirtyPath = dirtyPath.Replace(@"\", "/");
                                paths.Add(dirtyPath);
                            }
                        }
                    }

                    foreach (string path in paths)
                    {
                        if (path.EndsWith(".prefab"))
                        {
                            GameObject  go = AssetDatabase.LoadAssetAtPath <GameObject>(path);
                            CostumeItem ci = go.GetComponent <CostumeItem>();
                            if (ci != null)
                            {
                                ContentPack packScript = new ContentPack(go);
                                Undo.RecordObject(charMan, "Add Bundle");
                                charMan.AddContentPack(packScript);
                                EditorUtility.SetDirty(charMan);
                            }
                        }
                    }
                }

                EditorGUI.indentLevel--;
            }
            EditorGUILayout.Space();
            #endregion contentPacks

            #region hair
            showHair = EditorGUILayout.Foldout(showHair, "Hair");
            if (showHair)
            {
                EditorGUI.indentLevel++;
                List <MORPH3D.COSTUMING.CIhair> allHair = charMan.GetAllHair();
                foreach (MORPH3D.COSTUMING.CIhair mesh in allHair)
                {
                    if (DisplayHair(mesh))
                    {
                        Undo.RecordObject(charMan, "Toggle Hair");
                        mesh.SetVisibility(!mesh.isVisible);
                        //						data.SetVisibilityOnHairItem(mesh.ID, !mesh.isVisible);
                        EditorUtility.SetDirty(charMan);
                    }
                }
                EditorGUI.indentLevel--;
            }
            EditorGUILayout.Space();
            #endregion hair

            #region clothing
            showAllClothing = EditorGUILayout.Foldout(showAllClothing, "Clothing");
            if (showAllClothing)
            {
                EditorGUI.indentLevel++;

                List <CIclothing> allClothing = null;
                allClothing = charMan.GetAllClothing();
                foreach (CIclothing mesh in allClothing)
                {
//					bool tempLock;
                    bool temp = DisplayClothingMesh(mesh);

//					if(tempLock != mesh.isLocked)
//					{
//						Undo.RecordObject(data, "Lock Clothing");
//						if(tempLock)
                    //							data.LockClothingItem(mesh.ID);
//						else
                    //							data.UnlockClothingItem(mesh.ID);
//						EditorUtility.SetDirty(data);
//					}

                    if (temp)
                    {
                        Undo.RecordObject(charMan, "Toggle Clothing");
                        charMan.SetClothingVisibility(mesh.ID, !mesh.isVisible);
                        EditorUtility.SetDirty(charMan);
                    }
                }
                EditorGUI.indentLevel--;
            }
            EditorGUILayout.Space();
            #endregion clothing

            #region props
            CIattachmentPoint[] attachmentPoints = charMan.GetAllAttachmentPoints();
//			Debug.Log("AP LENGTH:"+attachmentPoints.Length);
            if (showAttachmentPointsGroups == null || showAttachmentPointsGroups.Length != attachmentPoints.Length)
            {
                showAttachmentPointsGroups = new bool[attachmentPoints.Length];
            }

            /*
             * if(selectedProps == null || selectedProps.Length != attachmentPoints.Length)
             *      selectedProps = new int[attachmentPoints.Length];
             */
            if (selectedPropsNames == null || selectedPropsNames.Length != attachmentPoints.Length)
            {
                selectedPropsNames = new string[attachmentPoints.Length];
            }
            List <CIprop> props      = charMan.GetAllLoadedProps();
            string[]      propsNames = new string[] {};
            if (props != null)
            {
                propsNames = new string[props.Count];
            }
            for (int i = 0; i < propsNames.Length; i++)
            {
                propsNames[i] = props[i].ID;
            }

            showAttachmentPoints = EditorGUILayout.Foldout(showAttachmentPoints, "Attachment Points");
            if (showAttachmentPoints)
            {
                int deleteAttachment = -1;
                EditorGUI.indentLevel++;
                for (int i = 0; i < attachmentPoints.Length; i++)
                {
                    EditorGUILayout.BeginHorizontal();
                    showAttachmentPointsGroups[i] = EditorGUILayout.Foldout(showAttachmentPointsGroups[i], attachmentPoints[i].attachmentPointName);
                    GUILayout.FlexibleSpace();
                    if (GUILayout.Button("X", GUILayout.Width(45)))
                    {
                        deleteAttachment = i;
                    }
                    GUILayout.FlexibleSpace();
                    EditorGUILayout.EndHorizontal();
                    if (showAttachmentPointsGroups[i])
                    {
                        EditorGUI.indentLevel++;
                        CIprop[] activeProps = attachmentPoints[i].getAttachmentArray();
                        int      destroyProp = -1;
                        for (int x = 0; x < activeProps.Length; x++)
                        {
                            if (DisplayProp(activeProps[x]))
                            {
                                destroyProp = x;
                            }
                        }
                        if (destroyProp >= 0)
                        {
                            Undo.RecordObject(charMan, "Destroy Prop");
                            charMan.DetachPropFromAttachmentPoint(activeProps[destroyProp].ID, attachmentPoints[i].attachmentPointName);
                            EditorUtility.SetDirty(charMan);
                        }
//						Debug.Log("GF");
                        if (propsNames.Length > 0)
                        {
//							Debug.Log("FDFG");
                            EditorGUILayout.Space();
                            EditorGUILayout.BeginHorizontal();
                            EditorGUILayout.LabelField("Add Prop:", GUILayout.Width(150));
                            EditorGUILayout.LabelField(selectedPropsNames[i], GUILayout.Width(150));
                            if (selectedPropsNames[i] != "" && selectedPropsNames[i] != null && charMan.GetLoadedPropByName(selectedPropsNames[i]) == null)
                            {
                                selectedPropsNames[i] = "";
                            }
                            if (GUILayout.Button("Search"))
                            {
                                int num = i;
                                SearchableWindow.Init(delegate(string newName) { selectedPropsNames[num] = newName; }, propsNames);
                            }
                            if (selectedPropsNames[i] != "" && selectedPropsNames[i] != null && GUILayout.Button("Add"))
                            {
                                Undo.RecordObject(charMan, "Attach Prop");
                                charMan.AttachPropToAttachmentPoint(selectedPropsNames[i], attachmentPoints[i].attachmentPointName);
                                EditorUtility.SetDirty(charMan);
                                selectedPropsNames[i] = "";
                            }
                            GUILayout.FlexibleSpace();
                            EditorGUILayout.EndHorizontal();

                            /*
                             * EditorGUILayout.Space();
                             * EditorGUILayout.BeginHorizontal();
                             * selectedProps[i] = EditorGUILayout.Popup (selectedProps[i], propsNames, GUILayout.Width(150));
                             * if(GUILayout.Button("Add"))
                             * {
                             *      Undo.RecordObject(data, "Attach Prop");
                             *      data.AttachPropToAttachmentPoint(propsNames[selectedProps[i]], attachmentPoints[i].attachmentPointName);
                             *      EditorUtility.SetDirty(data);
                             *      selectedProps[i] = 0;
                             * }
                             * GUILayout.FlexibleSpace();
                             * EditorGUILayout.EndHorizontal();
                             */
                        }
                        EditorGUILayout.Space();
                        EditorGUI.indentLevel--;
                    }
                }

                if (deleteAttachment >= 0)
                {
                    Undo.RecordObject(attachmentPoints[deleteAttachment], "Delete Attachment Point");
                    charMan.DeleteAttachmentPoint(attachmentPoints[deleteAttachment].attachmentPointName);
                }

                EditorGUILayout.Space();
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("New Point:", GUILayout.Width(150));
                EditorGUILayout.LabelField(selectedNewAttachmentPointName, GUILayout.Width(150));
                Transform tempBone = charMan.GetBoneByName(selectedNewAttachmentPointName);
                if (selectedNewAttachmentPointName != "" && selectedNewAttachmentPointName != null && tempBone == null)
                {
                    selectedNewAttachmentPointName = "";
                }
                if (GUILayout.Button("Search"))
                {
                    SearchableWindow.Init(delegate(string newName) { selectedNewAttachmentPointName = newName; }, charMan.GetAllBonesNames());
                }
                if (selectedNewAttachmentPointName != "" && selectedNewAttachmentPointName != null && tempBone != null && GUILayout.Button("Add"))
                {
                    Undo.RecordObject(tempBone.gameObject, "New Attachment Point");
                    charMan.CreateAttachmentPointOnBone(selectedNewAttachmentPointName);
                    selectedNewAttachmentPointName = "";
                }
                GUILayout.FlexibleSpace();
                EditorGUILayout.EndHorizontal();

                /*
                 * EditorGUILayout.Space();
                 * EditorGUILayout.BeginHorizontal();
                 * selectedNewAttachmentPointName = EditorGUILayout.TextField("New Point Bone Name", selectedNewAttachmentPointName);
                 * if(GUILayout.Button("Add") && selectedNewAttachmentPointName != "")
                 * {
                 *      Transform bone = data.boneService.getBoneByName (selectedNewAttachmentPointName);
                 *      if(bone != null)
                 *      {
                 *              Undo.RecordObject(bone.gameObject, "New Attachment Point");
                 *              data.CreateAttachmentPointOnBone(selectedNewAttachmentPointName);
                 *      }
                 *      selectedNewAttachmentPointName = "";
                 * }
                 * EditorGUILayout.EndHorizontal();
                 *
                 * EditorGUILayout.BeginHorizontal();
                 * selectedNewAttachmentPoint = (GameObject)EditorGUILayout.ObjectField("New Attachemnt Point", selectedNewAttachmentPoint, typeof(GameObject), true);
                 * if(selectedNewAttachmentPoint != null && !selectedNewAttachmentPoint.activeInHierarchy)
                 *      selectedNewAttachmentPoint = null;
                 * if(GUILayout.Button("Add") && selectedNewAttachmentPoint != null)
                 * {
                 *      if(selectedNewAttachmentPoint.GetComponent<CIattachmentPoint>() == null)
                 *      {
                 *              Undo.RecordObject(selectedNewAttachmentPoint, "New Attachment Point");
                 *              data.CreateAttachmentPointFromGameObject(selectedNewAttachmentPoint);
                 *      }
                 *      selectedNewAttachmentPoint = null;
                 * }
                 * EditorGUILayout.EndHorizontal();
                 */

                EditorGUI.indentLevel--;
            }
            EditorGUILayout.Space();
            #endregion props
        }
コード例 #6
0
    public void Rand()
    {
        if (isMCSModel)
        {
            manager.SetBlendshapeValue("FBMHeavy", Random.Range(0f, 60f));

            MCSMakeModelNaked();

            var jacketIndex = Random.Range(0, Jacket.Length * 2);
            if (jacketIndex < Jacket.Length)
            {
                ShowClothing(Jacket[jacketIndex]);
            }

            var shirtIndex = Random.Range(0, Shirt.Length + 1);
            if (shirtIndex < Shirt.Length)
            {
                ShowClothing(Shirt[shirtIndex]);
            }

            var pantsIndex = Random.Range(0, Pants.Length + 1);
            if (pantsIndex < Pants.Length)
            {
                ShowClothing(Pants[pantsIndex]);
            }

            var shoseIndex = Random.Range(0, Shose.Length / 2 + 1);
            if (shoseIndex < Shose.Length / 2)
            {
                ShowClothing(Shose[shoseIndex * 2]);
                ShowClothing(Shose[shoseIndex * 2 + 1]);
            }

            var hairIndex = Random.Range(0, hairList.Count + 1);
            if (hairIndex < hairList.Count)
            {
                hairList[hairIndex].isVisible = true;
            }
        }

        if (isUnityChan)
        {
            if (Random.Range(0, 2) == 0)
            {
                foreach (var item in UnityChanHair)
                {
                    item.SetActive(true);
                }
            }
            else
            {
                foreach (var item in UnityChanHair)
                {
                    item.SetActive(false);
                }
            }

            var bodyIndex = Random.Range(0, UnityChanBodyTexture.Length);
            if (bodyIndex < UnityChanBodyTexture.Length)
            {
                UnityChanBodyMaterial.SetTexture("_MainTex", UnityChanBodyTexture[bodyIndex]);
            }

            var hairIndex = Random.Range(0, UnityChanHairTexture.Length);
            if (hairIndex < UnityChanHairTexture.Length)
            {
                UnityChanHairMaterial.SetTexture("_MainTex", UnityChanHairTexture[hairIndex]);
            }
        }

        if (isBlueSuitMan)
        {
            var headIndex = Random.Range(0, BlueSuitManHeadTexture.Length);
            if (headIndex < BlueSuitManHeadTexture.Length)
            {
                BlueSuitManHeadMaterial.SetTexture("_MainTex", BlueSuitManHeadTexture[headIndex]);
            }

            var suitIndex = Random.Range(0, BlueSuitManSuitTexture.Length);
            if (suitIndex < BlueSuitManSuitTexture.Length)
            {
                BlueSuitManSuitMaterial.SetTexture("_MainTex", BlueSuitManSuitTexture[suitIndex]);
            }
        }

        if (isDefaultAvatar)
        {
            var headIndex = Random.Range(0, DefaultAvatarHeadTexture.Length);
            if (headIndex < DefaultAvatarHeadTexture.Length)
            {
                DefaultAvatarHeadMaterial.SetTexture("_MainTex", DefaultAvatarHeadTexture[headIndex]);
            }

            var suitIndex = Random.Range(0, DefaultAvatarSuitTexture.Length);
            if (suitIndex < DefaultAvatarSuitTexture.Length)
            {
                DefaultAvatarSuitMaterial.SetTexture("_MainTex", DefaultAvatarSuitTexture[suitIndex]);
            }
        }

        if (isRp_alison_rigged_001)
        {
            var rIndex = Random.Range(0, Rp_alison_rigged_001Texture.Length);
            if (rIndex < Rp_alison_rigged_001Texture.Length)
            {
                Rp_alison_rigged_001Material.SetTexture("_MainTex", Rp_alison_rigged_001Texture[rIndex]);
            }
        }

        if (isRp_eric_rigged_001_yup_t)
        {
            var rIndex = Random.Range(0, Rp_eric_rigged_001_yup_tTexture.Length);
            if (rIndex < Rp_eric_rigged_001_yup_tTexture.Length)
            {
                Rp_eric_rigged_001_yup_tMaterial.SetTexture("_MainTex", Rp_eric_rigged_001_yup_tTexture[rIndex]);
            }
        }

        if (isBaseball)
        {
            BaseballCapMaterial.SetColor("_Color", new Color(Random.Range(0.4f, 1f), Random.Range(0.4f, 1f), Random.Range(0.4f, 1f)));
            BaseballShirtsMaterial.SetColor("_Color", new Color(Random.Range(0.4f, 1f), Random.Range(0.4f, 1f), Random.Range(0.4f, 1f)));
            BaseballPantsMaterial.SetColor("_Color", new Color(Random.Range(0.4f, 1f), Random.Range(0.4f, 1f), Random.Range(0.4f, 1f)));
        }
    }
コード例 #7
0
 public void SetBlendshapeValue(float value)
 {
     Debug.Log("Set BlendShape called with value " + value);
     manager.SetBlendshapeValue("FBMHeavy", value);
 }
コード例 #8
0
        public override void OnInspectorGUI()
        {
            #region just_stuff
            serializedObject.Update();
            if (data == null)
            {
                data = (M3DCharacterManager)target;
            }
            if (names == null)
            {
//				Debug.Log("NAMES SCIRPTZABLE OBJECT NULL IN EDITOR");
                names = (M3DBlendshapeNames)Resources.Load("M3D_BlendshapesNames");
            }
            #endregion just_stuff


            #region LOD
            float lod;
            lod = EditorGUILayout.Slider("LOD", data.currentLODLevel, 0, 1);
            if (lod != data.currentLODLevel)
            {
                Undo.RecordObject(data, "Change LOD");
                data.setCharacterLODLevel(lod);
                EditorUtility.SetDirty(data);
            }
            EditorGUILayout.Space();
            #endregion LOD

            #region blendshapes
            List <MORPH3D.FOUNDATIONS.CoreBlendshape> shapes = data.GetAllBlendshapes();
            if (shapes.Count == 0)             //this check houldnt be needed. it's now included in the bendshape model itself
            {
                Debug.Log("NO BLEnDSHAPES VIA EDITOR");
                data.InitBlendshapeModel();
                shapes = data.GetAllBlendshapes();
            }


            showAllBlendShapes = EditorGUILayout.Foldout(showAllBlendShapes, "All Blendshapes");
            if (showAllBlendShapes)
            {
                EditorGUI.indentLevel++;

                GUILayout.BeginHorizontal();
                selectedBlendShape = GUILayout.TextField(selectedBlendShape, GUI.skin.FindStyle("ToolbarSeachTextField"));
                if (GUILayout.Button("", GUI.skin.FindStyle("ToolbarSeachCancelButton")))
                {
                    selectedBlendShape = "";
                    GUI.FocusControl(null);
                }
                GUILayout.EndHorizontal();
                EditorGUILayout.Space();
                if (GUILayout.Button("Reset All"))
                {
                    Undo.RecordObject(data, "Change Blendshape");
                    foreach (MORPH3D.FOUNDATIONS.CoreBlendshape shape in shapes)
                    {
                        data.SetBlendshapeValue(shape.displayName, 0);
                    }
                    EditorUtility.SetDirty(data);
                }

                foreach (MORPH3D.FOUNDATIONS.CoreBlendshape shape in shapes)
                {
                    if (selectedBlendShape != "" && names.GetLabelFromDisplayName(shape.displayName).IndexOf(selectedBlendShape, System.StringComparison.OrdinalIgnoreCase) < 0)
                    {
                        continue;
                    }

                    bool  tempLock;
                    float temp = DisplayBlendShape(shape, out tempLock);

                    if (tempLock != shape.isLocked)
                    {
                        Undo.RecordObject(data, "Lock Blendshape");
                        if (tempLock)
                        {
                            data.LockBlendshape(shape.displayName);
                        }
                        else
                        {
                            data.UnlockBlendshape(shape.displayName);
                        }
                        EditorUtility.SetDirty(data);
                    }
                    if (temp != shape.currentValue)
                    {
                        Undo.RecordObject(data, "Change Blendshape");
                        data.SetBlendshapeValue(shape.displayName, temp);
                        EditorUtility.SetDirty(data);
                    }
                }
                if (GUILayout.Button("Reset All"))
                {
                    Undo.RecordObject(data, "Change Blendshape");
                    foreach (MORPH3D.FOUNDATIONS.CoreBlendshape shape in shapes)
                    {
                        data.SetBlendshapeValue(shape.displayName, 0);
                    }
                    EditorUtility.SetDirty(data);
                }
                EditorGUI.indentLevel--;
            }

            showAllBlendshapesGroups = EditorGUILayout.Foldout(showAllBlendshapesGroups, "Blendshape Groups");
            if (showAllBlendshapesGroups)
            {
                namesList = names.GetAllNames();
                List <MORPH3D.FOUNDATIONS.CoreBlendshapeGroup> groups = data.GetAllBlendshapeGroups();
                if (showBlendshapeGroups == null || showBlendshapeGroups.Length != groups.Count)
                {
                    showBlendshapeGroups = new bool[groups.Count];
                }
                if (selectedBlendshapeNames == null || selectedBlendshapeNames.Length != groups.Count)
                {
                    selectedBlendshapeNames = new string[groups.Count];
                }

                EditorGUI.indentLevel++;

                int remove = -1;
                for (int i = 0; i < groups.Count; i++)
                {
                    showBlendshapeGroups[i] = EditorGUILayout.Foldout(showBlendshapeGroups[i], groups[i].groupName);
                    if (showBlendshapeGroups[i])
                    {
                        string tempName;
                        EditorGUI.indentLevel++;
                        if (!groups[i].isLocked)
                        {
                            tempName = EditorGUILayout.TextField("Name", groups[i].groupName);
                            if (groups[i].groupName != tempName)
                            {
                                groups[i].groupName = tempName;
                                EditorUtility.SetDirty(data);
                            }
                        }

                        if (groups[i].bsCount > 0)
                        {
                            float groupVal = EditorGUILayout.Slider("Group Weight", groups[i].groupValue, 0, 100);
                            if (groups[i].groupValue != groupVal)
                            {
                                Undo.RecordObject(data, "Change Group Value");
                                data.SetGroupValue(groups[i].groupName, groupVal);
                                EditorUtility.SetDirty(data);
                            }
                            EditorGUILayout.Space();
                        }

                        List <MORPH3D.FOUNDATIONS.CoreBlendshape> groupShapes = groups[i].GetAllBlendshapes();

                        EditorGUILayout.BeginHorizontal();
                        GUILayout.FlexibleSpace();
                        if (GUILayout.Button("Reset Group", GUILayout.Width(250)))
                        {
                            Undo.RecordObject(data, "Change Blendshape");
                            for (int x = 0; x < groupShapes.Count; x++)
                            {
                                data.SetBlendshapeValue(groupShapes[x].displayName, 0);
                            }
                            EditorUtility.SetDirty(data);
                        }
                        GUILayout.FlexibleSpace();
                        EditorGUILayout.EndHorizontal();

                        int deleteFromGroup = -1;
                        for (int x = 0; x < groupShapes.Count; x++)
                        {
                            bool  tempLock;
                            bool  delete;
                            float temp = (groups[i].isLocked) ? DisplayBlendShape(groupShapes[x], out tempLock) : DisplayBlendShape(groupShapes[x], out tempLock, out delete);

                            if (delete)
                            {
                                deleteFromGroup = x;
                            }

                            if (tempLock != groupShapes[x].isLocked)
                            {
                                Undo.RecordObject(data, "Lock Blendshape");
                                if (tempLock)
                                {
                                    data.LockBlendshape(groupShapes[x].displayName);
                                }
                                else
                                {
                                    data.UnlockBlendshape(groupShapes[x].displayName);
                                }
                                EditorUtility.SetDirty(data);
                            }
                            if (temp != groupShapes[x].currentValue)
                            {
                                Undo.RecordObject(data, "Change Blendshape");
                                data.SetBlendshapeValue(groupShapes[x].displayName, temp);
                                EditorUtility.SetDirty(data);
                            }
                        }
                        if (deleteFromGroup >= 0)
                        {
                            Undo.RecordObject(data, "Delete Blendshape from Group");
                            groupShapes.RemoveAt(deleteFromGroup);
                            EditorUtility.SetDirty(data);
                        }

                        if (!groups[i].isLocked)
                        {
                            if (namesList.Length > 0)
                            {
                                EditorGUILayout.Space();
                                EditorGUILayout.BeginHorizontal();
                                EditorGUILayout.LabelField("Add Blendshape:", GUILayout.Width(150));
                                EditorGUILayout.LabelField(selectedBlendshapeNames[i], GUILayout.Width(150));
                                MORPH3D.FOUNDATIONS.CoreBlendshape tempBlendshape = data.GetBlendshapeByName(names.GetDisplayName(selectedBlendshapeNames[i]));
                                if (selectedBlendshapeNames[i] != "" && selectedBlendshapeNames[i] != null && tempBlendshape == null)
                                {
                                    selectedBlendshapeNames[i] = "";
                                }
                                if (GUILayout.Button("Search"))
                                {
                                    int num = i;
                                    SearchableWindow.Init(delegate(string newName) { selectedBlendshapeNames[num] = newName; }, namesList);
                                }
                                if (selectedBlendshapeNames[i] != "" && selectedBlendshapeNames[i] != null && tempBlendshape != null && GUILayout.Button("Add"))
                                {
                                    Undo.RecordObject(data, "Add Blendshape to Group");
                                    groups[i].AddBlendshapeToGroup(tempBlendshape);
                                    EditorUtility.SetDirty(data);
                                    selectedBlendshapeNames[i] = "";
                                }
                                GUILayout.FlexibleSpace();
                                EditorGUILayout.EndHorizontal();
                            }

                            /*
                             * EditorGUILayout.Space();
                             * EditorGUILayout.BeginHorizontal();
                             * GUILayout.FlexibleSpace();
                             * selectedBlendshapeName = EditorGUILayout.Popup(selectedBlendshapeName, namesList);
                             * if(GUILayout.Button("Add Shape", GUILayout.Width(100)))
                             * {
                             *      MORPH3D.FOUNDATIONS.CoreBlendshape shape = data.GetBlendshapeByName(names.GetDisplayName(namesList[selectedBlendshapeName]));
                             *      if(shape != null && !groups[i].ContainsBlendshape(shape))
                             *      {
                             *              Undo.RecordObject(data, "Add Blendshape to Group");
                             *              groups[i].AddBlendshapeToGroup(shape);
                             *              EditorUtility.SetDirty(data);
                             *              selectedBlendshapeName = 0;
                             *      }
                             * }
                             * GUILayout.FlexibleSpace();
                             * EditorGUILayout.EndHorizontal();
                             */

                            EditorGUILayout.Space();
                            EditorGUILayout.BeginHorizontal();
                            GUILayout.FlexibleSpace();
                            if (GUILayout.Button("Delete Group", GUILayout.Width(100)))
                            {
                                remove = i;
                            }
                            GUILayout.FlexibleSpace();
                            EditorGUILayout.EndHorizontal();
                        }
                        EditorGUI.indentLevel--;
                    }
                }
                if (remove >= 0)
                {
                    Undo.RecordObject(data, "Remove Blendshape Group");
                    groups.RemoveAt(remove);
                    EditorUtility.SetDirty(data);
                }
                EditorGUILayout.Space();
                EditorGUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                if (GUILayout.Button("Add Group", GUILayout.Width(100)))
                {
                    Undo.RecordObject(data, "Create Blendshape Group");
                    data.AddBlendShapeGroup("New Group");
                    EditorUtility.SetDirty(data);
                }
                if (GUILayout.Button("Save to Group", GUILayout.Width(150)))
                {
                    List <MORPH3D.FOUNDATIONS.CoreBlendshape> lst = new List <MORPH3D.FOUNDATIONS.CoreBlendshape>();
                    foreach (MORPH3D.FOUNDATIONS.CoreBlendshape shape in shapes)
                    {
                        if (shape.currentValue <= 0)
                        {
                            continue;
                        }
                        lst.Add(shape);
                    }
                    if (lst.Count > 0)
                    {
                        Undo.RecordObject(data, "Save to Blendshape Group");
                        data.AddBlendShapeGroup("New Group", lst);
                        EditorUtility.SetDirty(data);
                    }
                }
                GUILayout.FlexibleSpace();
                EditorGUILayout.EndHorizontal();
                EditorGUI.indentLevel--;
            }
            EditorGUILayout.Space();
            #endregion blendshapes

            #region contentPacks
            showContentPacks = EditorGUILayout.Foldout(showContentPacks, "Content Packs");
            if (showContentPacks)
            {
                EditorGUI.indentLevel++;
                ContentPack[] allPacks = data.GetAllContentPacks();
                for (int i = 0; i < allPacks.Length; i++)
                {
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.LabelField(allPacks[i].name);
                    if (GUILayout.Button("X"))
                    {
                        Undo.RecordObject(data, "Remove Bundle");
                        data.UnloadContentPackFromFigure(allPacks[i]);
                        data.RemoveContentPackFromModel(allPacks[i].RootGameObject, true);
                        EditorUtility.SetDirty(data);
                    }
                    EditorGUILayout.EndHorizontal();
                }
                GameObject tempPack;
                tempPack = (GameObject)EditorGUILayout.ObjectField("New", null, typeof(GameObject), false);
                if (tempPack != null)
                {
                    ContentPack packScript = new ContentPack(tempPack);
                    Undo.RecordObject(data, "Add Bundle");
                    data.AddContentPack(packScript);
                    EditorUtility.SetDirty(data);
                }
                EditorGUI.indentLevel--;
            }
            EditorGUILayout.Space();
            #endregion contentPacks

            #region hair
            showHair = EditorGUILayout.Foldout(showHair, "Hair");
            if (showHair)
            {
                EditorGUI.indentLevel++;
                List <MORPH3D.COSTUMING.CIhair> allHair = data.GetAllHairItems();
                foreach (MORPH3D.COSTUMING.CIhair mesh in allHair)
                {
                    if (DisplayHair(mesh))
                    {
                        Undo.RecordObject(data, "Toggle Hair");
                        data.SetVisibilityOnHairItem(mesh.displayName, !mesh.isVisible);
                        EditorUtility.SetDirty(data);
                    }
                }
                EditorGUI.indentLevel--;
            }
            EditorGUILayout.Space();
            #endregion hair

            #region clothing
            showAllClothing = EditorGUILayout.Foldout(showAllClothing, "Clothing");
            if (showAllClothing)
            {
                EditorGUI.indentLevel++;

                List <CIclothing> allClothing = null;
                allClothing = data.GetAllLoadedClothingItems();
                foreach (CIclothing mesh in allClothing)
                {
                    bool tempLock;
                    bool temp = DisplayClothingMesh(mesh, out tempLock);

                    if (tempLock != mesh.isLocked)
                    {
                        Undo.RecordObject(data, "Lock Clothing");
                        if (tempLock)
                        {
                            data.LockClothingItem(mesh.displayName);
                        }
                        else
                        {
                            data.UnlockClothingItem(mesh.displayName);
                        }
                        EditorUtility.SetDirty(data);
                    }

                    if (temp)
                    {
                        Undo.RecordObject(data, "Toggle Clothing");
                        data.SetClothingVisibility(mesh.displayName, !mesh.isVisible);
                        EditorUtility.SetDirty(data);
                    }
                }
                EditorGUI.indentLevel--;
            }
            EditorGUILayout.Space();
            #endregion clothing

            #region props
            CIattachmentPoint[] attachmentPoints = data.GetAllAttachmentPoints();
//			Debug.Log("AP LENGTH:"+attachmentPoints.Length);
            if (showAttachmentPointsGroups == null || showAttachmentPointsGroups.Length != attachmentPoints.Length)
            {
                showAttachmentPointsGroups = new bool[attachmentPoints.Length];
            }

            /*
             * if(selectedProps == null || selectedProps.Length != attachmentPoints.Length)
             *      selectedProps = new int[attachmentPoints.Length];
             */
            if (selectedPropsNames == null || selectedPropsNames.Length != attachmentPoints.Length)
            {
                selectedPropsNames = new string[attachmentPoints.Length];
            }
            List <CIprop> props      = data.GetAllLoadedProps();
            string[]      propsNames = new string[] {};
            if (props != null)
            {
                propsNames = new string[props.Count];
            }
            for (int i = 0; i < propsNames.Length; i++)
            {
                propsNames[i] = props[i].displayName;
            }

            showAttachmentPoints = EditorGUILayout.Foldout(showAttachmentPoints, "Attachment Points");
            if (showAttachmentPoints)
            {
                int deleteAttachment = -1;
                EditorGUI.indentLevel++;
                for (int i = 0; i < attachmentPoints.Length; i++)
                {
                    EditorGUILayout.BeginHorizontal();
                    showAttachmentPointsGroups[i] = EditorGUILayout.Foldout(showAttachmentPointsGroups[i], attachmentPoints[i].attachmentPointName);
                    GUILayout.FlexibleSpace();
                    if (GUILayout.Button("X", GUILayout.Width(45)))
                    {
                        deleteAttachment = i;
                    }
                    GUILayout.FlexibleSpace();
                    EditorGUILayout.EndHorizontal();
                    if (showAttachmentPointsGroups[i])
                    {
                        EditorGUI.indentLevel++;
                        CIprop[] activeProps = attachmentPoints[i].getAttachmentArray();
                        int      destroyProp = -1;
                        for (int x = 0; x < activeProps.Length; x++)
                        {
                            if (DisplayProp(activeProps[x]))
                            {
                                destroyProp = x;
                            }
                        }
                        if (destroyProp >= 0)
                        {
                            Undo.RecordObject(data, "Destroy Prop");
                            data.DetachPropFromAttachmentPoint(activeProps[destroyProp].displayName, attachmentPoints[i].attachmentPointName);
                            EditorUtility.SetDirty(data);
                        }
//						Debug.Log("GF");
                        if (propsNames.Length > 0)
                        {
//							Debug.Log("FDFG");
                            EditorGUILayout.Space();
                            EditorGUILayout.BeginHorizontal();
                            EditorGUILayout.LabelField("Add Prop:", GUILayout.Width(150));
                            EditorGUILayout.LabelField(selectedPropsNames[i], GUILayout.Width(150));
                            if (selectedPropsNames[i] != "" && selectedPropsNames[i] != null && data.GetLoadedPropByName(selectedPropsNames[i]) == null)
                            {
                                selectedPropsNames[i] = "";
                            }
                            if (GUILayout.Button("Search"))
                            {
                                int num = i;
                                SearchableWindow.Init(delegate(string newName) { selectedPropsNames[num] = newName; }, propsNames);
                            }
                            if (selectedPropsNames[i] != "" && selectedPropsNames[i] != null && GUILayout.Button("Add"))
                            {
                                Undo.RecordObject(data, "Attach Prop");
                                data.AttachPropToAttachmentPoint(selectedPropsNames[i], attachmentPoints[i].attachmentPointName);
                                EditorUtility.SetDirty(data);
                                selectedPropsNames[i] = "";
                            }
                            GUILayout.FlexibleSpace();
                            EditorGUILayout.EndHorizontal();

                            /*
                             * EditorGUILayout.Space();
                             * EditorGUILayout.BeginHorizontal();
                             * selectedProps[i] = EditorGUILayout.Popup (selectedProps[i], propsNames, GUILayout.Width(150));
                             * if(GUILayout.Button("Add"))
                             * {
                             *      Undo.RecordObject(data, "Attach Prop");
                             *      data.AttachPropToAttachmentPoint(propsNames[selectedProps[i]], attachmentPoints[i].attachmentPointName);
                             *      EditorUtility.SetDirty(data);
                             *      selectedProps[i] = 0;
                             * }
                             * GUILayout.FlexibleSpace();
                             * EditorGUILayout.EndHorizontal();
                             */
                        }
                        EditorGUILayout.Space();
                        EditorGUI.indentLevel--;
                    }
                }

                if (deleteAttachment >= 0)
                {
                    Undo.RecordObject(attachmentPoints[deleteAttachment], "Delete Attachment Point");
                    data.DeleteAttachmentPoint(attachmentPoints[deleteAttachment].attachmentPointName);
                }

                EditorGUILayout.Space();
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("New Point:", GUILayout.Width(150));
                EditorGUILayout.LabelField(selectedNewAttachmentPointName, GUILayout.Width(150));
                Transform tempBone = data.GetBoneByName(selectedNewAttachmentPointName);
                if (selectedNewAttachmentPointName != "" && selectedNewAttachmentPointName != null && tempBone == null)
                {
                    selectedNewAttachmentPointName = "";
                }
                if (GUILayout.Button("Search"))
                {
                    SearchableWindow.Init(delegate(string newName) { selectedNewAttachmentPointName = newName; }, data.GetAllBonesNames());
                }
                if (selectedNewAttachmentPointName != "" && selectedNewAttachmentPointName != null && tempBone != null && GUILayout.Button("Add"))
                {
                    Undo.RecordObject(tempBone.gameObject, "New Attachment Point");
                    data.CreateAttachmentPointOnBone(selectedNewAttachmentPointName);
                    selectedNewAttachmentPointName = "";
                }
                GUILayout.FlexibleSpace();
                EditorGUILayout.EndHorizontal();

                /*
                 * EditorGUILayout.Space();
                 * EditorGUILayout.BeginHorizontal();
                 * selectedNewAttachmentPointName = EditorGUILayout.TextField("New Point Bone Name", selectedNewAttachmentPointName);
                 * if(GUILayout.Button("Add") && selectedNewAttachmentPointName != "")
                 * {
                 *      Transform bone = data.boneService.getBoneByName (selectedNewAttachmentPointName);
                 *      if(bone != null)
                 *      {
                 *              Undo.RecordObject(bone.gameObject, "New Attachment Point");
                 *              data.CreateAttachmentPointOnBone(selectedNewAttachmentPointName);
                 *      }
                 *      selectedNewAttachmentPointName = "";
                 * }
                 * EditorGUILayout.EndHorizontal();
                 *
                 * EditorGUILayout.BeginHorizontal();
                 * selectedNewAttachmentPoint = (GameObject)EditorGUILayout.ObjectField("New Attachemnt Point", selectedNewAttachmentPoint, typeof(GameObject), true);
                 * if(selectedNewAttachmentPoint != null && !selectedNewAttachmentPoint.activeInHierarchy)
                 *      selectedNewAttachmentPoint = null;
                 * if(GUILayout.Button("Add") && selectedNewAttachmentPoint != null)
                 * {
                 *      if(selectedNewAttachmentPoint.GetComponent<CIattachmentPoint>() == null)
                 *      {
                 *              Undo.RecordObject(selectedNewAttachmentPoint, "New Attachment Point");
                 *              data.CreateAttachmentPointFromGameObject(selectedNewAttachmentPoint);
                 *      }
                 *      selectedNewAttachmentPoint = null;
                 * }
                 * EditorGUILayout.EndHorizontal();
                 */

                EditorGUI.indentLevel--;
            }
            EditorGUILayout.Space();
            #endregion props
        }
コード例 #9
0
 public void stopTalking()
 {
     m_CharacterManager.SetBlendshapeValue("eCTRLvER", 0);
     CancelInvoke();
 }
コード例 #10
0
 // Use this for initialization
 void Start()
 {
     m_CharacterManager = GetComponent <M3DCharacterManager>();
     m_CharacterManager.SetBlendshapeValue("eCTRLvER", 0);
 }