// ReSharper disable once InconsistentNaming // ReSharper disable once UnusedMember.Global public void OnGUI() { EditorContent.Space(); EditorContent.BeginObjectChanged(); _tabMode = (TabMode) EditorContent.Tab((int) _tabMode, "Create Preset", "Apply Preset"); if (EditorContent.IsObjectChanged()) { _gameObject = null; _enabledComponents.Clear(); _configurations.Clear(); _preset = null; } EditorContent.Space(); switch (_tabMode) { case TabMode.Save: CreatePresetLayout(); break; case TabMode.Restore: ApplyPresetLayout(); break; } }
private void ApplyPresetLayout() { EditorContent.Label("Apply DynamicBone preset to existing GameObject tree."); _gameObject = EditorContent.ObjectPicker<GameObject>("Root GameObject", _gameObject, true); _preset = EditorContent.ObjectPicker<DynamicBonePreset>("Preset", _preset, false); using (EditorContent.DisabledGroup(_gameObject == null || _preset == null)) if (EditorContent.Button("Apply DynamicBone Preset")) ApplyPreset(); }
public void ApplyDynamicBones(DynamicBonePreset preset) { var dynamicBones = GetComponentsInChildren <DynamicBone>(); foreach (var dynamicBone in dynamicBones) { preset.Apply(dynamicBone); } }
private void CreatePreset() { var preset = new DynamicBonePreset(); foreach (var configuration in _configurations) { configuration.StoreConfiguration(); preset.Configs.Add(configuration); } if (!Directory.Exists("Assets/DynamicBonePresets")) AssetDatabase.CreateFolder("Assets", "DynamicBonePresets"); AssetDatabase.CreateAsset(preset, string.Format("Assets/DynamicBonePresets/{0}.asset", _name)); }