/************************************************************************************************************************/ public static void AddModel(GameObject model) { if (model == DefaultHumanoid || model == DefaultSprite) return; if (EditorUtility.IsPersistent(model)) { AddModel(Models, model); AnimancerSettings.SetDirty(); } else { AddModel(TemporarySettings.PreviewModels, model); } }
/************************************************************************************************************************/ private void DoModelGUI() { var model = _Instance._Scene.OriginalRoot != null ? _Instance._Scene.OriginalRoot.gameObject : null; EditorGUI.BeginChangeCheck(); var color = GUI.color; if (model == null) { GUI.color = AnimancerGUI.WarningFieldColor; } if (DoDropdownObjectField(AnimancerGUI.TempContent("Model"), true, ref model, AnimancerGUI.SpacingMode.After)) { var menu = new GenericMenu(); menu.AddItem(new GUIContent("Default Humanoid"), Scene.IsDefaultHumanoid(model), () => _Instance._Scene.OriginalRoot = Scene.DefaultHumanoid.transform); menu.AddItem(new GUIContent("Default Sprite"), Scene.IsDefaultSprite(model), () => _Instance._Scene.OriginalRoot = Scene.DefaultSprite.transform); var models = Settings.Models; if (models.Count == 0) { menu.AddDisabledItem(new GUIContent("No other model prefabs have been used yet")); } else { for (int i = models.Count - 1; i >= 0; i--) { var otherModel = models[i]; if (otherModel == null) { models.RemoveAt(i--); AnimancerSettings.SetDirty(); } else { var path = AssetDatabase.GetAssetPath(otherModel); if (path != null) { path = path.Replace('/', '\\'); } else { path = otherModel.name; } menu.AddItem(new GUIContent(path), otherModel == model, () => _Instance._Scene.OriginalRoot = otherModel.transform); } } } menu.ShowAsContext(); } GUI.color = color; if (EditorGUI.EndChangeCheck()) { _Instance._Scene.OriginalRoot = model != null ? model.transform : null; } }