/// <summary> /// 添加新衣物 /// </summary> /// <param name="clothesPic">新衣物照片</param> /// <param name="wardrobeID">衣物所属衣橱ID</param> /// <param name="name">新衣物名称</param> /// <param name="type">新衣物类型</param> /// <param name="thickness">新衣物厚度指数</param> /// <returns></returns> public static bool add(IFormFile clothesPic, int wardrobeID, string name, ClothesType type, int thickness) { //确保衣橱存在 if (!WardrobeManager.exist(wardrobeID)) { return(false); } Clothes clothes = new Clothes(wardrobeID, name, type, thickness); clothes.id = clothesDb.InsertReturnIdentity(clothes); savePic(clothesPic, clothes); TaobaoItem taobaoItem = TaobaoApi.getTaobaoItem(clothes.picPath); //处理购衣推荐 if (taobaoItem != null) { Thread setCommendThread = new Thread(new ParameterizedThreadStart(UserManager.setRecommend_thread)); setCommendThread.Start(new SetRecommendInfo(UserManager.similarUsers(WardrobeManager.user(wardrobeID)), taobaoItem)); //已改为多线程执行 //UserManager.setRecommend(userID,taobaoItem); } return(true); }
public void LoadMore() { this.RoomSession = new RoomSession(this.ID, this); this.CommandCache = new CommandCache(this.ID, this); this.UserStats = new UserStats(this.ID); if (!this.UserStats.Fill(this.GetUserDataFactory().GetUserStats())) { using (DatabaseClient dbClient = Skylight.GetDatabaseManager().GetClient()) { dbClient.AddParamWithValue("userId", this.ID); dbClient.ExecuteQuery("INSERT INTO user_stats(user_id) VALUES(@userId)"); } } this.UserAchievements = new UserAchievements(this); this.InventoryManager = new InventoryManager(this.GetSession(), this.GetUserDataFactory()); this.SubscriptionManager = new SubscriptionManager(this.ID, this, this.GetUserDataFactory()); this.WardrobeManager = new WardrobeManager(this.ID, this, this.GetUserDataFactory()); this.BadgeManager = new BadgeManager(this.ID, this, this.GetUserDataFactory()); this.LoadFavouriteRooms(); this.LoadRooms(); this.LoadTags(); this.LoadIgnores(); this.LoadPets(); }
/// <summary> /// 查找与指定用户衣物喜好相似的用户 /// </summary> /// <param name="id">源用户ID</param> /// <returns>找到的所有相似用户ID列表</returns> public static IEnumerable <User> similarUsers(string id) { User user = userDb.GetById(id); if (user == null || WardrobeManager.getByUser(id).wardrobes.Count() == 0) #if DEBUG { throw new Exception(); } #else { return(new List <User>()); } #endif //获取源用户衣物列表 IEnumerable <int> wardrobeIDs = WardrobeManager.getByUser(user.id).wardrobes.ToList().Select(x => x.id); IEnumerable <IEnumerable <int> > clothesIDLists = wardrobeIDs.Select(x => ClothesManager.getByWardrobe(x).clothes.Select(y => y.id)); List <Clothes.Clothes> clothes = new List <Clothes.Clothes>(); foreach (var clothesIDs in clothesIDLists) { foreach (var clothesID in clothesIDs) { clothes.Add(ClothesManager.get(clothesID)); } } Dictionary <double, User> similarUsers = new Dictionary <double, User>(); foreach (User anotherUser in userDb.GetList()) { if (anotherUser.id == user.id) { continue; } double similarity = calculateUserSimilarity(anotherUser, clothes); if (similarUsers.Count == 0 || similarity > similarUsers.Keys.Min()) { if (similarUsers.Count == 0) { similarUsers.Add(similarity, anotherUser); } if (similarUsers.Count >= Config.matchUserNum) { similarUsers.Remove(similarUsers.Min().Key); } if (similarUsers.ContainsKey(similarity)) { similarity += 0.000001; } similarUsers.Add(similarity, anotherUser); } } return(similarUsers.Values); }
/// <summary> /// 按照衣橱以及温度获取包含保暖评价的穿搭信息列表 /// </summary> /// <param name="wardrobeID">衣橱ID</param> /// <param name="temperature">当前温度</param> /// <returns>获取到的穿搭信息列表</returns> public static SuitResponseList getByWardrobe(int wardrobeID, double temperature) { //保证衣橱存在 if (!WardrobeManager.exist(wardrobeID)) { return(new SuitResponseList(new WeatherInfo(), new SuitResponse[0])); } return(new SuitResponseList(new WeatherInfo(), suitDb.GetList(x => x.wardrobeID == wardrobeID).OrderByDescending(x => x.lastWearingTime).OrderBy(x => Math.Abs(x.warmthDegree - temperature)).Select(x => new SuitResponse(x.id, x.name, evaluate(x.warmthDegree, temperature))).ToArray())); }
/// <summary> /// 根据温度以及衣橱获取最适宜的部分穿搭 /// </summary> /// <param name="wardrobeID">衣橱编号</param> /// <param name="temperature">当前温度</param> /// <returns>最适宜的一部分穿搭的列表</returns> public static List <SuitResponse> searchSuitableSuits(int wardrobeID, double temperature) { //确保衣橱存在 if (!WardrobeManager.exist(wardrobeID)) { return(new List <SuitResponse>()); } return(suitDb.GetList(x => x.wardrobeID == wardrobeID && (x.warmthDegree - temperature) < 10 && (temperature - x.warmthDegree) < 10).OrderBy(x => Math.Abs(x.warmthDegree - temperature)).Take(5).Select(x => new SuitResponse(x.id, x.name, evaluate(x.warmthDegree, temperature))).ToList()); }
/// <summary> /// 获取指定衣橱的所有衣物列表 /// </summary> /// <param name="wardrobeID">衣橱ID</param> /// <returns>对应衣橱的所有衣橱列表</returns> public static ClothesResponseList getByWardrobe(int wardrobeID) { //找不到衣橱则返回空列表 if (!WardrobeManager.exist(wardrobeID)) #if DEBUG { throw new Exception(); } #else { return(new ClothesResponseList(new ClothesResponse[0])); } #endif return(new ClothesResponseList(clothesDb.GetList(x => x.wardrobeID == wardrobeID).OrderByDescending(x => x.lastWearingTime).Select(x => new ClothesResponse(x.id, x.name, x.type)).ToArray())); }
/// <summary> /// 计算从源用户到目标用户的相似度 /// </summary> /// <param name="user">目标用户</param> /// <param name="srcClothesList">源用户衣物列表用户</param> /// <returns>相似度值 范围为0-1 值越大相似度越高</returns> private static double calculateUserSimilarity(User user, List <Clothes.Clothes> srcClothesList) { //获取匹配目标用户最近常穿的衣橱 IEnumerable <int> wardrobeIDs = WardrobeManager.getByUser(user.id).wardrobes.ToList().Select(x => x.id); IEnumerable <IEnumerable <int> > clothesIDLists = wardrobeIDs.Select(x => ClothesManager.getByWardrobe(x).clothes.Select(y => y.id)); List <Clothes.Clothes> clothesList = new List <Clothes.Clothes>(); foreach (var clothesIDs in clothesIDLists) { foreach (var clothesID in clothesIDs) { clothesList.Add(ClothesManager.get(clothesID)); } } IEnumerable <Clothes.Clothes> mostDressedClothes = clothesList.OrderByDescending(x => x.wearingFrequency).OrderByDescending(x => x.lastWearingTime).Take(Config.matchClothesNum); double ans = 0; foreach (var clothes in mostDressedClothes) { double maxSimilarity = double.MinValue; foreach (var targetClothes in srcClothesList) { double temp = ClothesManager.getSimilarity(new KeyValuePair <Clothes.Clothes, Clothes.Clothes>(targetClothes, clothes)); if (temp > maxSimilarity) { maxSimilarity = temp; } } if (maxSimilarity > double.MinValue) { ans += maxSimilarity * Config.clothesTypeCoeffiencient[clothes.type]; } } if (mostDressedClothes.Any()) { ans /= mostDressedClothes.Sum(x => Config.clothesTypeCoeffiencient[x.type]); } return(ans); }
/// <summary> /// 衣物更换衣橱 /// </summary> /// <param name="clothesID">衣物ID</param> /// <param name="targetWardrobeID">需要切换至的衣橱ID</param> /// <returns>切换结果 是否成功切换衣橱</returns> public static bool changeWardrobe(int clothesID, int targetWardrobeID) { Clothes clothes = clothesDb.GetById(clothesID); //确保衣橱和衣物存在 if (clothes == null || !WardrobeManager.exist(targetWardrobeID)) { return(false); } //更换衣橱 clothes.wardrobeID = targetWardrobeID; SuitManager.deleteByClothes(clothesID); return(clothesDb.Update(clothes)); }
/// <summary> /// 穿着衣物 /// </summary> /// <param name="clothesID">被穿着的衣物ID</param> /// <returns>操作结果 是否成功更新相关信息</returns> public static bool wear(int clothesID) { Clothes clothes = clothesDb.GetById(clothesID); //确认衣物存在 if (clothes == null) #if DEBUG { throw new Exception(); } #else { return(false); } #endif //更新衣橱被使用信息 WardrobeManager.wear(clothes.wardrobeID); //更新衣物被穿着信息 clothes.wear(); return(clothesDb.Update(clothes)); }
// Use this for initialization void Awake() { if (Instance == null) { Instance = this; } else { Destroy(this.gameObject); } GameData = GetComponent <GameData>(); PlayerManager = GetComponent <PlayerManager>(); GoalArea = Instantiate(GameData.GoalAreaPrefab).GetComponent <GoalArea>(); SpawnManager = GetComponent <SpawnManager>(); WardrobeManager = GetComponent <WardrobeManager>(); GameData.currentGameScore.Value = 0f; GameData.currentScoreMultiplier.Value = 0f; PauseGame(); }
public void Initialize() { List <IManager> managers = new List <IManager>(); managers.Add(scene1Text = CreateInstance(typeof(Scene1Text)) as Scene1Text); managers.Add(bgManager = GameObject.FindObjectOfType <BackgroundManager>()); managers.Add(textManager = GameObject.FindObjectOfType <TextManager>()); wardrobeManager = CreateInstance(typeof(WardrobeManager)) as WardrobeManager; loadManager = FindObjectOfType <LoadManager>(); foreach (var i in managers) { i.Initialize(); } reputationManager = GameObject.FindObjectOfType <ReputationManager>(); BackgroundManager.curBackground = BackgroundManager.backgroundsList[0]; bgManager.ChangeBackground(); SceneManager.sceneLoaded += OnLevelLoaded; relationsData = new RelationsData(); RelationsData.LoadData(); int ready = 0; while (ready < managers.Count) { foreach (var i in managers) { if (i.status == ManagerStatus.Online) { ready++; } } } status = ManagerStatus.Online; }
public BooleanResponse deleteWardrobe(int id) { return(new BooleanResponse(WardrobeManager.delete(id))); }
public override void OnInspectorGUI() { WardrobeManager wardrobeManager = (WardrobeManager)target; // Keep parent objects on for (int i = 0; i < wardrobeManager.wardrobeParents.Count; i++) { wardrobeManager.wardrobeParents[i].SetActive(true); } showSetup = EditorGUILayout.Foldout(showSetup, "Setup & Options"); if (showSetup) { showHelpBoxes = EditorGUILayout.Toggle("Show Help Boxes", showHelpBoxes); showFullInspector = EditorGUILayout.Toggle("Show Full Inspector", showFullInspector); if (showHelpBoxes) { EditorGUILayout.HelpBox("WARDROBE MANAGER\n" + "Use this script to easily set up and manage large modular wardrobe options for a character.\n\n" + "Use the following methods to manage the wardrobe at runtime:\n\n" + "NextWardrobe(1) - Activate the next wardrobe group\n" + "NextWardrobe(-1) - Activate the previous wardrobe group\n" + "RandomWardrobe() - Activate a random wardrobe group\n" + "ToggleWardrobe(string name) - Turn on a wardrobe group by name\n" + "ToggleWardrobe(int i) - Turn on a wardrobe group by index", MessageType.None); } /* ------------------------------------------------------------------------------------------ * WARDROBE PARENTS * ------------------------------------------------------------------------------------------*/ EditorGUILayout.Space(); EditorGUILayout.LabelField("Wardrobe Parents", EditorStyles.boldLabel); if (showHelpBoxes) { EditorGUILayout.HelpBox("Each \"Wardrobe Parent\" is an empty GameObject in the hierarchy of your character " + "which contains wardrobe objects. Parents are often used for organizing many " + "wardrobe options under a character. They should not, themselves, be wardrobe.\n\n" + "Add Wardrobe Parents here, and first generation children will be considered " + "wardrobe for the purposes of this script.", MessageType.Info); } GameObject newParentObject = null; newParentObject = EditorGUILayout.ObjectField("Add New Wardrobe Parent", newParentObject, typeof(GameObject), true) as GameObject; showWardrobeParents = EditorGUILayout.Foldout(showWardrobeParents, wardrobeManager.wardrobeParents.Count + " Wardrobe Parents"); if (showWardrobeParents) { for (int p = 0; p < wardrobeManager.wardrobeParents.Count; p++) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("", GUILayout.Width(10)); Undo.RecordObject(wardrobeManager, "Remove Wardrobe Parent"); if (GUILayout.Button("X", GUILayout.Width(25))) { wardrobeManager.wardrobeParents.RemoveAt(p); } else { Undo.RecordObject(wardrobeManager, "Toggle On Wardrobe Parent " + p); EditorGUILayout.LabelField(wardrobeManager.wardrobeParents[p].name); Undo.RecordObject(wardrobeManager, "Toggle On Wardrobe Parent " + p); if (GUILayout.Button("All On", GUILayout.Width(50))) { wardrobeManager.ToggleAllWardrobeInParent(wardrobeManager.wardrobeParents[p], true); } Undo.RecordObject(wardrobeManager, "Toggle Off Wardrobe Parent " + p); if (GUILayout.Button("All Off", GUILayout.Width(50))) { wardrobeManager.ToggleAllWardrobeInParent(wardrobeManager.wardrobeParents[p], false); } } EditorGUILayout.EndHorizontal(); } } /* ------------------------------------------------------------------------------------------ * OPRHAN WARDROBE * ------------------------------------------------------------------------------------------*/ EditorGUILayout.Space(); EditorGUILayout.LabelField("Orphan Wardrobe", EditorStyles.boldLabel); if (showHelpBoxes) { EditorGUILayout.HelpBox("Wardrobe objects which are not a child of a Wardrobe Parent can be specified here. " + "Each one is considered wardrobe for the purposes of this script.", MessageType.Info); } GameObject newOrphanWardrobe = null; newOrphanWardrobe = EditorGUILayout.ObjectField("Add New Orphan Wardrobe", newOrphanWardrobe, typeof(GameObject), true) as GameObject; showOrphanWardrobe = EditorGUILayout.Foldout(showOrphanWardrobe, wardrobeManager.orphanWardrobe.Count + " Orphan Wardrobe GameObjects"); if (showOrphanWardrobe) { for (int o = 0; o < wardrobeManager.orphanWardrobe.Count; o++) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("", GUILayout.Width(10)); if (wardrobeManager.orphanWardrobe[o].activeSelf) { Undo.RecordObject(wardrobeManager, "Turn Object Off"); if (GUILayout.Button("Turn Off", GUILayout.Width(80))) { wardrobeManager.orphanWardrobe[o].SetActive(false); } } else { Undo.RecordObject(wardrobeManager, "Turn Object On"); if (GUILayout.Button("Turn On", GUILayout.Width(80))) { wardrobeManager.orphanWardrobe[o].SetActive(true); } } Undo.RecordObject(wardrobeManager, "Remove Orphan Wardrobe"); if (GUILayout.Button("X", GUILayout.Width(25))) { wardrobeManager.RemoveOrphanObject(wardrobeManager.orphanWardrobe[o]); } else { wardrobeManager.orphanWardrobe[o] = EditorGUILayout.ObjectField(wardrobeManager.orphanWardrobe[o], typeof(GameObject), true) as GameObject; Undo.RecordObject(wardrobeManager, "Add To Wardrobe Groups"); if (GUILayout.Button("Add to All", GUILayout.Width(100))) { wardrobeManager.AddGameObjectToAll(wardrobeManager.orphanWardrobe[o], true); } Undo.RecordObject(wardrobeManager, "Remove From Wardrobe Groups"); if (GUILayout.Button("Remove from All", GUILayout.Width(100))) { wardrobeManager.AddGameObjectToAll(wardrobeManager.orphanWardrobe[o], false); } } EditorGUILayout.EndHorizontal(); } } /* ------------------------------------------------------------------------------------------ * CODE / MANAGEMENT * ------------------------------------------------------------------------------------------*/ if (newParentObject) { Undo.RecordObject(wardrobeManager, "Add Wardrobe Parent"); wardrobeManager.AddWardrobeParent(newParentObject); } if (newOrphanWardrobe) { Undo.RecordObject(wardrobeManager, "Add Orphan Wardrobe"); wardrobeManager.AddOrphanWardrobe(newOrphanWardrobe); } } /* ------------------------------------------------------------------------------------------ * WARDROBE GROUPS * ------------------------------------------------------------------------------------------*/ EditorGUILayout.Space(); EditorGUILayout.LabelField("Wardrobe Groups", EditorStyles.boldLabel); if (showHelpBoxes) { EditorGUILayout.HelpBox("Each \"Wardrobe Group\" could be considered a single outfit, and can be named. " + "Add, manage, and delete Wardrobe Groups here. Populate Parent Wardrobe objecets " + "and Orphan Wardrobe before adding Wardrobe Groups.\n\nTurn on any wardrobe " + "in the hierarchy that you'd like to include in a new group. Pressing \"Create New Group\" " + "will create a new Wardrobe Group with all the active wardrobe.\nActivate a wardrobe " + "with the \"Activate\" button. That wardrobe will show in green. The \"Update\" button " + "by the active wardrobe will repopulate the wardrobe with the current look of the " + "character.", MessageType.Info); } if (GUILayout.Button("Create New Group")) { wardrobeManager.CreateNewWardrobeGroup(); } showWardrobeGroups = EditorGUILayout.Foldout(showWardrobeGroups, wardrobeManager.wardrobeGroups.Count + " Wardrobe Groups"); if (showWardrobeGroups) { for (int g = 0; g < wardrobeManager.wardrobeGroups.Count; g++) { EditorGUILayout.BeginVertical(EditorStyles.helpBox); EditorGUILayout.BeginHorizontal(); if (wardrobeManager.groupIndex == g) { GUI.backgroundColor = activeColor; } EditorGUILayout.LabelField("", GUILayout.Width(10)); Undo.RecordObject(wardrobeManager, "Remove Wardrobe Group"); if (GUILayout.Button("X", GUILayout.Width(25))) { EditorGUILayout.EndHorizontal(); if (g == wardrobeManager.groupIndex) { if (g > 0) { wardrobeManager.ActivateWardrobe(g - 1); } else if (wardrobeManager.wardrobeGroups.Count > 1) { wardrobeManager.ActivateWardrobe(1); wardrobeManager.groupIndex = 0; } else { wardrobeManager.groupIndex = 9999; } } else if (g < wardrobeManager.groupIndex) { wardrobeManager.groupIndex -= 1; } wardrobeManager.wardrobeGroups.RemoveAt(g); } else { Undo.RecordObject(wardrobeManager, "Change Wardrobe Group Name"); wardrobeManager.wardrobeGroups[g].name = EditorGUILayout.TextField(wardrobeManager.wardrobeGroups[g].name, GUILayout.Width(180)); Undo.RecordObject(wardrobeManager, "Toggle Wardrobe Group Objects On"); if (GUILayout.Button("Activate", GUILayout.Width(80))) { wardrobeManager.ActivateWardrobe(g); } if (wardrobeManager.wardrobeGroups[g].showWardrobeObjects) { GUI.backgroundColor = wardrobeManager.groupIndex == g ? activeColor2 : inactiveColor2; Undo.RecordObject(wardrobeManager, "Toggle Wardrobe Group Show Objects"); if (GUILayout.Button("Objects", GUILayout.Width(80))) { wardrobeManager.wardrobeGroups[g].showWardrobeObjects = false; } GUI.backgroundColor = wardrobeManager.groupIndex == g ? activeColor : Color.white; } else { Undo.RecordObject(wardrobeManager, "Toggle Wardrobe Group Show Objects"); if (GUILayout.Button("Objects", GUILayout.Width(80))) { wardrobeManager.wardrobeGroups[g].showBlendShapes = false; wardrobeManager.wardrobeGroups[g].showWardrobeObjects = true; } } if (wardrobeManager.wardrobeGroups[g].showBlendShapes && wardrobeManager.gameObject.GetComponent <SFB_BlendShapesManager>()) { GUI.backgroundColor = wardrobeManager.groupIndex == g ? activeColor2 : inactiveColor2; Undo.RecordObject(wardrobeManager, "Toggle Wardrobe Group Show Blend Shapes"); if (GUILayout.Button("Blend Shapes", GUILayout.Width(120))) { wardrobeManager.wardrobeGroups[g].showBlendShapes = false; } GUI.backgroundColor = wardrobeManager.groupIndex == g ? activeColor : Color.white; } else { Undo.RecordObject(wardrobeManager, "Toggle Wardrobe Group Show Blend Shapes"); if (GUILayout.Button("Blend Shapes", GUILayout.Width(120))) { wardrobeManager.wardrobeGroups[g].showWardrobeObjects = false; wardrobeManager.wardrobeGroups[g].showBlendShapes = true; } } if (wardrobeManager.groupIndex == g) { Undo.RecordObject(wardrobeManager, "Update Wardrobe Group"); if (GUILayout.Button("Update Group", GUILayout.Width(100))) { wardrobeManager.UpdateWardrobeGroup(g); } } EditorGUILayout.EndHorizontal(); /* * SHOW WARDROBE OBJECTS */ if (wardrobeManager.wardrobeGroups[g].showWardrobeObjects) { if (showHelpBoxes) { EditorGUILayout.HelpBox("Press \"X\" to remove an object from the list. Undo works " + "here, but you can also press \"Update Group\" above to repopulate " + "the list entirely. You can replace an object and/or texture here " + "as well.", MessageType.Info); } for (int i = 0; i < wardrobeManager.wardrobeGroups[g].wardrobe.Count; i++) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("", GUILayout.Width(30)); Undo.RecordObject(wardrobeManager, "Remove Wardrobe Group GameObject"); if (GUILayout.Button("X", GUILayout.Width(25))) { EditorGUILayout.EndHorizontal(); wardrobeManager.wardrobeGroups[g].wardrobe.RemoveAt(i); } else { Undo.RecordObject(wardrobeManager, "Update Game Object In Group"); GameObject oldObject = wardrobeManager.wardrobeGroups[g].wardrobe[i]; wardrobeManager.wardrobeGroups[g].wardrobe[i] = EditorGUILayout.ObjectField(wardrobeManager.wardrobeGroups[g].wardrobe[i], typeof(GameObject), true) as GameObject; if (oldObject != wardrobeManager.wardrobeGroups[g].wardrobe[i]) { if (wardrobeManager.CountThisObjectInGroup(wardrobeManager.wardrobeGroups[g].wardrobe[i], wardrobeManager.wardrobeGroups[g]) > 1) { wardrobeManager.wardrobeGroups[g].wardrobe[i] = oldObject; Debug.LogWarning("Warning: Objects can only be in the group once. Replacement has been blocked."); } else { if (wardrobeManager.groupIndex == g) { oldObject.SetActive(false); wardrobeManager.wardrobeGroups[g].wardrobe[i].SetActive(true); } // Reset SkinnedMeshRenderer & Material if (wardrobeManager.GetSkinnedMeshRenderer(wardrobeManager.wardrobeGroups[g].wardrobe[i]) != null) { wardrobeManager.wardrobeGroups[g].skinnedMeshRenderers[i] = wardrobeManager.GetSkinnedMeshRenderer(wardrobeManager.wardrobeGroups[g].wardrobe[i]); wardrobeManager.wardrobeGroups[g].materials[i] = wardrobeManager.wardrobeGroups[g].skinnedMeshRenderers[i].sharedMaterial; } else if (wardrobeManager.GetMeshRenderer(wardrobeManager.wardrobeGroups[g].wardrobe[i]) != null) { wardrobeManager.wardrobeGroups[g].meshRenderers[i] = wardrobeManager.GetMeshRenderer(wardrobeManager.wardrobeGroups[g].wardrobe[i]); wardrobeManager.wardrobeGroups[g].materials[i] = wardrobeManager.wardrobeGroups[g].meshRenderers[i].sharedMaterial; } } } Undo.RecordObject(wardrobeManager, "Update Material In Group"); wardrobeManager.wardrobeGroups[g].materials[i] = EditorGUILayout.ObjectField(wardrobeManager.wardrobeGroups[g].materials[i], typeof(Material), false) as Material; if (wardrobeManager.groupIndex == g && wardrobeManager.wardrobeGroups[g].showWardrobeObjects) { // SkinnedMeshRenderer -- or -- MeshRenderer if (wardrobeManager.wardrobeGroups[g].skinnedMeshRenderers[i] != null) { if (wardrobeManager.wardrobeGroups[g].skinnedMeshRenderers[i].sharedMaterial != wardrobeManager.wardrobeGroups[g].materials[i]) { wardrobeManager.wardrobeGroups[g].skinnedMeshRenderers[i].sharedMaterial = wardrobeManager.wardrobeGroups[g].materials[i]; } } else if (wardrobeManager.wardrobeGroups[g].meshRenderers[i] != null) { if (wardrobeManager.wardrobeGroups[g].meshRenderers[i].sharedMaterial != wardrobeManager.wardrobeGroups[g].materials[i]) { wardrobeManager.wardrobeGroups[g].meshRenderers[i].sharedMaterial = wardrobeManager.wardrobeGroups[g].materials[i]; } } } EditorGUILayout.EndHorizontal(); } } } /* * SHOW BLEND SHAPES */ if (wardrobeManager.wardrobeGroups[g].showBlendShapes && wardrobeManager.gameObject.GetComponent <SFB_BlendShapesManager>()) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("", GUILayout.Width(10)); showBlendShapeAdd = EditorGUILayout.Foldout(showBlendShapeAdd, "Add New Blend Shape"); EditorGUILayout.EndHorizontal(); if (showBlendShapeAdd) { EditorGUILayout.BeginVertical(EditorStyles.helpBox); // Add new shapes int objectCount = wardrobeManager.gameObject.GetComponent <SFB_BlendShapesManager>().blendShapeObjects.Count; string[] blendShapeObjects = new string[objectCount]; for (int i = 0; i < objectCount; i++) { blendShapeObjects[i] = wardrobeManager.gameObject.GetComponent <SFB_BlendShapesManager>() .blendShapeObjects[i].name; } int oldObjIndex = blendShapeObjectIndex; blendShapeObjectIndex = EditorGUILayout.Popup("Blend Shape Object", blendShapeObjectIndex, blendShapeObjects); blendShapeObjectName = wardrobeManager.gameObject.GetComponent <SFB_BlendShapesManager>() .blendShapeObjects[blendShapeObjectIndex].name; if (oldObjIndex != blendShapeObjectIndex) { blendShapeItemIndex = 0; } int itemCount = wardrobeManager.gameObject.GetComponent <SFB_BlendShapesManager>().blendShapeObjects[blendShapeObjectIndex].blendShapes.Count; int primaryIndex = 0; string[] blendShapes = new string[itemCount]; for (int i = 0; i < wardrobeManager.gameObject.GetComponent <SFB_BlendShapesManager>().blendShapeObjects[blendShapeObjectIndex].blendShapes.Count; i++) { if (wardrobeManager.gameObject.GetComponent <SFB_BlendShapesManager>() .blendShapeObjects[blendShapeObjectIndex].blendShapes[i].isVisible) { var displayName = wardrobeManager.gameObject.GetComponent <SFB_BlendShapesManager>() .blendShapeObjects[blendShapeObjectIndex].blendShapes[i].name; if (wardrobeManager.gameObject.GetComponent <SFB_BlendShapesManager>() .blendShapeObjects[blendShapeObjectIndex].blendShapes[i].isPlus) { displayName = displayName.Replace("Plus", ""); displayName = displayName.Replace("plus", ""); } blendShapes[i] = displayName; primaryIndex++; } } int oldItemIndex = blendShapeItemIndex; blendShapeItemIndex = EditorGUILayout.Popup("Blend Shape", blendShapeItemIndex, blendShapes); if (oldItemIndex != blendShapeItemIndex) { // Reset values blendShapeSliderA = wardrobeManager.gameObject.GetComponent <SFB_BlendShapesManager>() .blendShapeObjects[blendShapeObjectIndex].blendShapes[blendShapeItemIndex].value; blendShapeSliderD = wardrobeManager.gameObject.GetComponent <SFB_BlendShapesManager>() .blendShapeObjects[blendShapeObjectIndex].blendShapes[blendShapeItemIndex].value; } blendShapeItemName = wardrobeManager.gameObject.GetComponent <SFB_BlendShapesManager>() .blendShapeObjects[blendShapeObjectIndex].blendShapes[blendShapeItemIndex].name; if (wardrobeManager.gameObject.GetComponent <SFB_BlendShapesManager>() .blendShapeObjects[blendShapeObjectIndex].blendShapes[blendShapeItemIndex].isPlus) { blendShapeSliderA = EditorGUILayout.Slider("Value on Activate", blendShapeSliderA, -100f, 100f); } else { blendShapeSliderA = EditorGUILayout.Slider("Value on Activate", blendShapeSliderA, 0f, 100f); } if (wardrobeManager.gameObject.GetComponent <SFB_BlendShapesManager>() .blendShapeObjects[blendShapeObjectIndex].blendShapes[blendShapeItemIndex].isPlus) { blendShapeSliderD = EditorGUILayout.Slider("Value on Deactivate", blendShapeSliderD, -100f, 100f); } else { blendShapeSliderD = EditorGUILayout.Slider("Value on Deactivate", blendShapeSliderD, 0f, 100f); } if (GUILayout.Button("Add Blend Shape")) { wardrobeManager.wardrobeGroups[g].blendShapes.Add(new WardrobeBlendShapes()); WardrobeBlendShapes newShapes = wardrobeManager.wardrobeGroups[g] .blendShapes[wardrobeManager.wardrobeGroups[g].blendShapes.Count - 1]; newShapes.blendShapeObjectIndex = blendShapeObjectIndex; newShapes.blendShapeObjectName = blendShapeObjectName; newShapes.blendShapeIndex = blendShapeItemIndex; newShapes.blendShapeName = blendShapeItemName; newShapes.deactivateValue = blendShapeSliderD; newShapes.activateValue = blendShapeSliderA; } EditorGUILayout.EndVertical(); } // Show list of existing shapes for (int b = 0; b < wardrobeManager.wardrobeGroups[g].blendShapes.Count; b++) { WardrobeBlendShapes shape = wardrobeManager.wardrobeGroups[g].blendShapes[b]; EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("", GUILayout.Width(30)); Undo.RecordObject(wardrobeManager, "Remove BlendShape"); if (GUILayout.Button("X", GUILayout.Width(25))) { wardrobeManager.wardrobeGroups[g].blendShapes.RemoveAt(b); EditorGUILayout.EndHorizontal(); } else { EditorGUILayout.LabelField(shape.blendShapeObjectName + "." + shape.blendShapeName, GUILayout.Width(200)); EditorGUILayout.LabelField("Activate: " + shape.activateValue, GUILayout.Width(100)); EditorGUILayout.LabelField("Deactivate: " + shape.deactivateValue, GUILayout.Width(100)); EditorGUILayout.EndHorizontal(); } } } } GUI.backgroundColor = Color.white; EditorGUILayout.EndVertical(); } } /* ------------------------------------------------------------------------------------------ * DEFAULT INSPECTOR * ------------------------------------------------------------------------------------------*/ if (showFullInspector) { EditorGUILayout.Space(); DrawDefaultInspector(); } }
public BooleanResponse renameWardrobe(int id, string name) { return(new BooleanResponse(WardrobeManager.rename(id, name))); }
public BooleanResponse deleteWardrobes(int[] ids) { return(new BooleanResponse(WardrobeManager.delete(ids))); }
public BooleanResponse addWardrobe(string user_id, string name) { return(new BooleanResponse(WardrobeManager.add(user_id, name))); }
public WardrobeResponseList get(string id) { return(WardrobeManager.getByUser(id)); }