public static void Init(SetResult action, string[] options)
    {
        if(SearchableWindow.windowInstance != null)
            SearchableWindow.windowInstance.Close();

        windowInstance = EditorWindow.GetWindow <SearchableWindow>(true, "Search Window", true);
        windowInstance.action = action;
        windowInstance.options = options;
    }
Exemple #2
0
    public static void Init(SetResult action, string[] options)
    {
        if (SearchableWindow.windowInstance != null)
        {
            SearchableWindow.windowInstance.Close();
        }

        windowInstance         = EditorWindow.GetWindow <SearchableWindow>(true, "Search Window", true);
        windowInstance.action  = action;
        windowInstance.options = options;
    }
Exemple #3
0
 void OnEnable()
 {
     windowInstance = this;
 }
Exemple #4
0
 void OnDestroy()
 {
     windowInstance = null;
 }
Exemple #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
        }
Exemple #6
0
        public override void OnInspectorGUI()
        {
            #region just_stuff
            serializedObject.Update();
            if (charMan == null)
            {
                charMan = (MCSCharacterManager)target;
            }


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

            GUIStyle mcsDefaultButtonStyle = new GUIStyle(GUI.skin.button);
            mcsDefaultButtonStyle.margin  = new RectOffset(10, 10, 5, 5);
            mcsDefaultButtonStyle.padding = new RectOffset(5, 5, 5, 5);

            #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)
            {
                //SerializedObject so = new SerializedObject(charMan.coreMorphs);
                //so.Update();

                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", mcsDefaultButtonStyle))
                {
                    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", mcsDefaultButtonStyle))
                {
                    Undo.RecordObject(charMan, "Detach All Morphs");
                    charMan.RemoveAllMorphs();
                    EditorUtility.SetDirty(charMan);
                }
                EditorGUILayout.Space();

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

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

                if (dirtyMorphDettachments.Count > 0 || dirtyMorphAttachments.Count > 0 || dirtyMorphValues.Count > 0)
                {
                    Undo.RecordObject(charMan.coreMorphs, "Change Morph");
                    charMan.coreMorphs.DettachMorphs(dirtyMorphDettachments.ToArray());
                    charMan.coreMorphs.AttachMorphs(dirtyMorphAttachments.ToArray());
                    charMan.coreMorphs.SyncMorphValues(dirtyMorphValues.ToArray());
                    charMan.SyncAllBlendShapes();

                    //so.ApplyModifiedProperties();
                    EditorUtility.SetDirty(charMan.coreMorphs);
                }

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

            #region Morph Groups

            var body           = charMan.gameObject.GetComponentInChildren <CIbody>();
            var bodyName       = body.dazName;
            var morphTypeGroup = MorphGroupService.GetMorphGroups(bodyName);
            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", mcsDefaultButtonStyle))
                {
                    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);
                            }
                        }
                    }
                }

                if (GUILayout.Button("Clear Lingering Content Packs", mcsDefaultButtonStyle))
                {
                    charMan.RemoveRogueContent();
                }

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

            #region hair
            showHair = EditorGUILayout.Foldout(showHair, "Hair");
            if (showHair)
            {
                EditorGUI.indentLevel++;
                List <MCS.COSTUMING.CIhair> allHair = charMan.GetAllHair();
                foreach (MCS.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();
            Dictionary <string, string> idToName = new Dictionary <string, string>();
            string[] propsNames = new string[] {};
            if (props != null)
            {
                propsNames = new string[props.Count];
            }
            for (int i = 0; i < propsNames.Length; i++)
            {
                propsNames[i]         = props[i].dazName + "|" + props[i].ID;
                idToName[props[i].ID] = props[i].dazName;
            }

            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();

                            string propDisplay = !string.IsNullOrEmpty(selectedPropsNames[i]) ? idToName[selectedPropsNames[i]] : null;

                            EditorGUILayout.LabelField("Add Prop:", GUILayout.Width(150));
                            EditorGUILayout.LabelField(propDisplay, 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) {
                                    string id = newName;
                                    int pos   = newName.LastIndexOf('|');
                                    if (pos >= 0)
                                    {
                                        id = newName.Substring(pos + 1);
                                    }

                                    selectedPropsNames[num] = id;
                                }, propsNames);
                            }
                            if (selectedPropsNames[i] != "" && selectedPropsNames[i] != null && GUILayout.Button("Add"))
                            {
                                Undo.RecordObject(charMan, "Attach Prop");
                                //UnityEngine.Debug.Log("Prop:" + selectedPropsNames[i]);
                                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

            #region advanced


            showAdvanced = EditorGUILayout.Foldout(showAdvanced, "Advanced");
            if (showAdvanced)
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Recalculate Bounds Frequency");
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                List <BoundsOptionsIndex> boundsOptions = new List <BoundsOptionsIndex>();
                boundsOptions.Add(new BoundsOptionsIndex(0, COSTUME_BOUNDS_UPDATE_FREQUENCY.NEVER));
                boundsOptions.Add(new BoundsOptionsIndex(1, COSTUME_BOUNDS_UPDATE_FREQUENCY.ON_ATTACH));
                boundsOptions.Add(new BoundsOptionsIndex(2, COSTUME_BOUNDS_UPDATE_FREQUENCY.ON_MORPH));

                int      currentSlot       = 0;
                string[] boundsOptionsText = new string[boundsOptions.Count];
                for (int i = 0; i < boundsOptions.Count; i++)
                {
                    if (boundsOptions[i].frequency == charMan.CostumeBoundsUpdateFrequency)
                    {
                        currentSlot = i;
                    }
                    boundsOptionsText[i] = boundsOptions[i].display;
                }

                Undo.RecordObject(charMan, "Alter Bounds Frequency");
                int boundsSlot = EditorGUILayout.Popup(currentSlot, boundsOptionsText);
                charMan.CostumeBoundsUpdateFrequency = boundsOptions[boundsSlot].frequency;
                EditorUtility.SetDirty(charMan);
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                bool resetBlendshapesOnStart = EditorGUILayout.Toggle("Reset Blendshapes on Start", charMan.ResetBlendshapesOnStart);
                if (resetBlendshapesOnStart != charMan.ResetBlendshapesOnStart)
                {
                    Undo.RecordObject(charMan, "Reset Blendshapes on Start");
                    charMan.ResetBlendshapesOnStart = resetBlendshapesOnStart;
                    EditorUtility.SetDirty(charMan);
                }
                EditorGUILayout.EndHorizontal();


                EditorGUILayout.BeginHorizontal();
                bool forceJawShut = EditorGUILayout.Toggle("Force Jaw Shut", charMan.ForceJawShut);
                if (forceJawShut != charMan.ForceJawShut)
                {
                    Undo.RecordObject(charMan, "Force Jaw Shut");
                    charMan.ForceJawShut = forceJawShut;
                    EditorUtility.SetDirty(charMan);
                }
                EditorGUILayout.EndHorizontal();

                //show option to toggle updates per frame for this character
                EditorGUILayout.BeginHorizontal();
                bool autoUpdate = EditorGUILayout.Toggle("Auto Frame Update", charMan.autoUpdateModel);
                if (autoUpdate != charMan.autoUpdateModel)
                {
                    Undo.RecordObject(charMan, "Auto Frame Update");
                    charMan.autoUpdateModel = autoUpdate;
                    EditorUtility.SetDirty(charMan);
                }
                EditorGUILayout.EndHorizontal();

                //show option to toggle updates per frame for this character
                EditorGUILayout.BeginHorizontal();
                bool autoLateUpdate = EditorGUILayout.Toggle("Auto Late Frame Update", charMan.autoUpdateModelLate);
                if (autoLateUpdate != charMan.autoUpdateModelLate)
                {
                    Undo.RecordObject(charMan, "Auto Late Frame Update");
                    charMan.autoUpdateModelLate = autoLateUpdate;
                    EditorUtility.SetDirty(charMan);
                }
                EditorGUILayout.EndHorizontal();

                //We're not quite ready to support this w/o having documentation about it

                /*
                 * if (charMan.alphaInjection != null)
                 * {
                 *  EditorGUILayout.BeginHorizontal();
                 *  EditorGUILayout.LabelField("Alpha Injection");
                 *  EditorGUILayout.EndHorizontal();
                 *  if (GUILayout.Button("Force Current Mats into Buffer (use non-instanced mats)", mcsDefaultButtonStyle))
                 *  {
                 *      Undo.RecordObject(charMan.alphaInjection, "Force Update AI");
                 *      charMan.alphaInjection.ForceCurrentMaterialsIntoOriginals();
                 *      EditorUtility.SetDirty(charMan.alphaInjection);
                 *  }
                 * }
                 */
            }

            #endregion
        }
 void OnEnable()
 {
     windowInstance = this;
 }
 void OnDestroy()
 {
     windowInstance = null;
 }
Exemple #9
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
        }