public static void ShowSwapButton(T23_Master master, string currentTitle) { List <string> titles = master.actionTitles; int c = titles.IndexOf(currentTitle); if (c == -1) { return; } EditorGUILayout.BeginHorizontal(); GUILayout.Space(EditorGUIUtility.currentViewWidth - 100); EditorGUI.BeginDisabledGroup(c == 0); if (GUILayout.Button("↑")) { string swapTitle = titles[c - 1]; titles[c - 1] = currentTitle; titles[c] = swapTitle; master.OrderComponents(); master.shouldMoveComponents = true; } EditorGUI.EndDisabledGroup(); EditorGUI.BeginDisabledGroup(c == titles.Count - 1); if (GUILayout.Button("↓")) { string swapTitle = titles[c + 1]; titles[c + 1] = currentTitle; titles[c] = swapTitle; master.OrderComponents(); master.shouldMoveComponents = true; } EditorGUI.EndDisabledGroup(); EditorGUILayout.EndHorizontal(); }
public override void OnInspectorGUI() { //base.OnInspectorGUI(); if (!T23_EditorUtility.GuideJoinMaster(master, body, body.groupID, 1)) { return; } serializedObject.Update(); T23_EditorUtility.ShowTitle("Trigger"); if (master) { GUILayout.Box("[#" + body.groupID.ToString() + "] " + body.title, T23_EditorUtility.HeadlineStyle()); } else { body.groupID = EditorGUILayout.IntField("Group ID", body.groupID); } EditorGUI.BeginChangeCheck(); UdonSharpProgramAsset programAsset = UdonSharpEditorUtility.GetUdonSharpProgramAsset((UdonSharpBehaviour)target); UdonSharpGUI.DrawInteractSettings(target); if (EditorGUI.EndChangeCheck()) { if (master) { UdonBehaviour behaviour = UdonSharpEditorUtility.GetBackingUdonBehaviour((UdonSharpBehaviour)target); master.interactText = behaviour.interactText; master.proximity = behaviour.proximity; master.OrderComponents(); } } serializedObject.ApplyModifiedProperties(); }
public override void OnInspectorGUI() { //base.OnInspectorGUI(); master.CheckComponents(); serializedObject.Update(); T23_EditorUtility.ShowTitle("Master"); GUILayout.Box("Group #" + master.groupID.ToString(), T23_EditorUtility.HeadlineStyle(true)); GUILayout.Space(10); SerializedProperty broadcastProp = serializedObject.FindProperty("broadcastTitles"); if (broadcastReorderableList == null) { broadcastReorderableList = new ReorderableList(serializedObject, broadcastProp); broadcastReorderableList.draggable = true; broadcastReorderableList.drawHeaderCallback = rect => EditorGUI.LabelField(rect, "Broadcast"); broadcastReorderableList.drawElementCallback = (rect, index, isActive, isFocused) => { rect.height = EditorGUIUtility.singleLineHeight; EditorGUI.LabelField(rect, master.broadcastTitles[index]); }; broadcastReorderableList.onAddDropdownCallback = (Rect buttonRect, ReorderableList list) => { var menu = new GenericMenu(); var assetList = T23_EditorUtility.GetProgramAssets("Broadcast"); foreach (var pair in assetList) { menu.AddItem(new GUIContent(pair.Key), false, () => { master.SetBroadcast(pair.Value); }); } menu.DropDown(buttonRect); }; broadcastReorderableList.onChangedCallback = ChangeBroadcast; } broadcastReorderableList.DoLayoutList(); /* * EditorGUILayout.BeginHorizontal(); * setBroadcast = (UdonSharpProgramAsset)EditorGUILayout.ObjectField("New Broadcast", setBroadcast, typeof(UdonSharpProgramAsset), false); * if (GUILayout.Button("Set")) * { * EditorApplication.delayCall += () => SetBroadcast(); * } * EditorGUILayout.EndHorizontal(); */ GUILayout.Space(10); SerializedProperty triggerProp = serializedObject.FindProperty("triggerTitles"); if (triggerReorderableList == null) { triggerReorderableList = new ReorderableList(serializedObject, triggerProp); triggerReorderableList.draggable = true; triggerReorderableList.drawHeaderCallback = rect => EditorGUI.LabelField(rect, "Trigger"); triggerReorderableList.drawElementCallback = (rect, index, isActive, isFocused) => { rect.height = EditorGUIUtility.singleLineHeight; EditorGUI.LabelField(rect, master.triggerTitles[index]); }; triggerReorderableList.onAddDropdownCallback = (Rect buttonRect, ReorderableList list) => { var menu = new GenericMenu(); var assetList = T23_EditorUtility.GetProgramAssets("Trigger"); foreach (var pair in assetList) { menu.AddItem(new GUIContent(pair.Key), false, () => { master.AddTrigger(pair.Value); }); } menu.DropDown(buttonRect); }; triggerReorderableList.onChangedCallback = ChangeTrigger; } triggerReorderableList.DoLayoutList(); /* * EditorGUILayout.BeginHorizontal(); * addTrigger = (UdonSharpProgramAsset)EditorGUILayout.ObjectField("New Trigger", addTrigger, typeof(UdonSharpProgramAsset), false); * if (GUILayout.Button("Add")) * { * AddTrigger(); * } * EditorGUILayout.EndHorizontal(); */ GUILayout.Space(10); SerializedProperty actionProp = serializedObject.FindProperty("actionTitles"); if (actionReorderableList == null) { actionReorderableList = new ReorderableList(serializedObject, actionProp); actionReorderableList.draggable = true; actionReorderableList.drawHeaderCallback = rect => EditorGUI.LabelField(rect, "Action"); actionReorderableList.drawElementCallback = (rect, index, isActive, isFocused) => { rect.height = EditorGUIUtility.singleLineHeight; EditorGUI.LabelField(rect, master.actionTitles[index]); }; actionReorderableList.onAddDropdownCallback = (Rect buttonRect, ReorderableList list) => { var menu = new GenericMenu(); var assetList = T23_EditorUtility.GetProgramAssets("Action"); foreach (var pair in assetList) { menu.AddItem(new GUIContent(pair.Key), false, () => { master.AddAction(pair.Value); }); } menu.DropDown(buttonRect); }; actionReorderableList.onChangedCallback = ChangeAction; } actionReorderableList.DoLayoutList(); /* * EditorGUILayout.BeginHorizontal(); * addAction = (UdonSharpProgramAsset)EditorGUILayout.ObjectField("New Action", addAction, typeof(UdonSharpProgramAsset), false); * if (GUILayout.Button("Add")) * { * AddAction(); * } * EditorGUILayout.EndHorizontal(); */ GUILayout.Space(10); EditorGUI.BeginChangeCheck(); EditorGUI.BeginDisabledGroup(master.hasObjectSync); serializedObject.FindProperty("reliable").boolValue = EditorGUILayout.Toggle("SyncMethod Manual", master.reliable); EditorGUI.EndDisabledGroup(); if (EditorGUI.EndChangeCheck()) { serializedObject.ApplyModifiedProperties(); master.OrderComponents(); serializedObject.Update(); } if (master.hasObjectSync) { EditorGUILayout.HelpBox("VRC_ObjectSync が存在するため、Synchronize Method は Continuous に設定されています。", MessageType.Info); } if (master.shouldMoveComponents) { Object prefab = PrefabUtility.GetCorrespondingObjectFromSource(master.gameObject); string msg = ""; if (prefab == null) { if (master.MoveComponents()) { master.shouldMoveComponents = false; } else { msg = "コンポーネントが正しく整列できません。"; } } else { msg = "コンポーネントがPrefab内にある場合、整列できません。"; } if (msg != "") { EditorGUILayout.BeginHorizontal(); EditorGUILayout.HelpBox(msg, MessageType.Warning); if (GUILayout.Button("Clear")) { master.shouldMoveComponents = false; } EditorGUILayout.EndHorizontal(); } } serializedObject.ApplyModifiedProperties(); }