/// <summary> /// 概要を表示します. /// </summary> protected void OnDrawSummary() { serializedObject.Update(); //グループに所属している場合、パラメータを規定のものに変更. int indexInGroup = current.indexInGroup; if (0 <= indexInGroup) { spValueType.intValue = (int)ValueType.Boolean; spIgnoreParentToggle.boolValue = true; spResetValueOnAwake.boolValue = false; spSyncedToggles.ClearArray(); if (serializedObject.ApplyModifiedProperties()) { current.OnTransformParentChanged(); } return; } using (new EditorGUILayout.VerticalScope("box")) { //トグルタイプポップアップを描画します. EditorGUILayout.PropertyField(spValueType); EditorGUILayout.PropertyField(spIgnoreParentToggle); EditorGUILayout.PropertyField(spResetValueOnAwake); //自分の値が変更されたときに通知するトグルリストを描画します. bool hasSyncToggles = 0 < roSyncToggles.count; if (EditorGUILayout.Toggle("Sync Other Toggles", hasSyncToggles) != hasSyncToggles) { hasSyncToggles = !hasSyncToggles; if (hasSyncToggles) { roSyncToggles.serializedProperty.InsertArrayElementAtIndex(0); } else { roSyncToggles.serializedProperty.ClearArray(); } } if (hasSyncToggles) { GUILayout.Space(-2); roSyncToggles.DoLayoutList(); } } if (serializedObject.ApplyModifiedProperties()) { current.OnTransformParentChanged(); current.Reflesh(); ResetToggleValue(); serializedObject.Update(); UpdateMultipleRelations(); } }
protected void OnEnable() { // rec = false; RefleshAllToggles(); roSyncToggles = new ReorderableList(serializedObject, serializedObject.FindProperty("m_SyncedToggles"), false, false, true, true); roSyncToggles.drawElementCallback = (rect, index, isActive, isFocus) => { var sp = roSyncToggles.serializedProperty.GetArrayElementAtIndex(index); EditorGUI.PropertyField(rect, sp, GetLabelWithWarning("Notifiy Target", sp.objectReferenceValue as CompositeToggle)); }; roSyncToggles.elementHeight = 16; roSyncToggles.headerHeight = 0; current = target as CompositeToggle; current.Reflesh(); spComments = serializedObject.FindProperty("m_Comments"); spActions = serializedObject.FindProperty("m_Actions"); spGroupToggles = serializedObject.FindProperty("m_GroupedToggles"); spActivations = serializedObject.FindProperty("m_ActivateObjects"); spOnValueChanged = serializedObject.FindProperty("m_OnValueChanged"); spValueType = serializedObject.FindProperty("m_ValueType"); spIgnoreParentToggle = serializedObject.FindProperty("m_IgnoreParent"); spResetValueOnAwake = serializedObject.FindProperty("m_ResetValueOnAwake"); spSyncedToggles = serializedObject.FindProperty("m_SyncedToggles"); s_AvailableReflectedTypes = new HashSet <Type>(current.GetComponents <Component>().Where(x => x != null).Select(x => x.GetType())); s_AvailableReflectedTypes.Add(typeof(GameObject)); syncedByOtherToggles.Clear(); foreach (var toggle in Resources.FindObjectsOfTypeAll <CompositeToggle>()) { if (toggle == current) { continue; } var sp = new SerializedObject(toggle).FindProperty("m_SyncedToggles"); if (Enumerable.Range(0, sp.arraySize).Any(i => sp.GetArrayElementAtIndex(i).objectReferenceValue == current)) { syncedByOtherToggles.Add(toggle); } } UpdateMultipleRelations(); }