public override void OnInspectorGUI()
        {
            //base.OnInspectorGUI();

            if (!UdonSharpEditorUtility.IsProxyBehaviour(body))
            {
                UdonSharpGUI.DrawConvertToUdonBehaviourButton(body);
                return;
            }

            serializedObject.Update();

            T23_EditorUtility.ShowTitle("Option");
            GUILayout.Box("CommonBuffer", T23_EditorUtility.HeadlineStyle());

            UdonSharpProgramAsset programAsset = UdonSharpEditorUtility.GetUdonSharpProgramAsset((UdonSharpBehaviour)target);

            UdonSharpGUI.DrawCompileErrorTextArea(programAsset);

            if (GUILayout.Button("Set Broadcasts"))
            {
                body.broadcasts = T23_EditorUtility.TakeCommonBuffersRelate(body);
            }
            if (GUILayout.Button("Join Empty Broadcasts"))
            {
                T23_EditorUtility.JoinAllBufferingBroadcasts(body);
            }
            prop = serializedObject.FindProperty("autoJoin");
            EditorGUILayout.PropertyField(prop);

            prop = serializedObject.FindProperty("broadcasts");
            EditorGUILayout.PropertyField(prop);

            serializedObject.ApplyModifiedProperties();
        }
Beispiel #2
0
        public override void OnInspectorGUI()
        {
            //base.OnInspectorGUI();

            if (!T23_EditorUtility.GuideJoinMaster(master, body, body.groupID, 2))
            {
                return;
            }

            serializedObject.Update();

            T23_EditorUtility.ShowTitle("Action");

            UdonSharpProgramAsset programAsset = UdonSharpEditorUtility.GetUdonSharpProgramAsset((UdonSharpBehaviour)target);

            UdonSharpGUI.DrawCompileErrorTextArea(programAsset);

            if (master)
            {
                GUILayout.Box("[#" + body.groupID.ToString() + "] " + body.title, T23_EditorUtility.HeadlineStyle());
                T23_EditorUtility.ShowSwapButton(master, body.title);
                body.priority = master.actionTitles.IndexOf(body.title);
            }
            else
            {
                body.groupID  = EditorGUILayout.IntField("Group ID", body.groupID);
                body.priority = EditorGUILayout.IntField("Priority", body.priority);
            }

            SerializedProperty recieverProp = serializedObject.FindProperty("recievers");

            if (recieverReorderableList == null)
            {
                recieverReorderableList                     = new ReorderableList(serializedObject, recieverProp);
                recieverReorderableList.draggable           = true;
                recieverReorderableList.displayAdd          = true;
                recieverReorderableList.drawHeaderCallback  = rect => EditorGUI.LabelField(rect, "Recievers");
                recieverReorderableList.drawElementCallback = (rect, index, isActive, isFocused) =>
                {
                    rect.height           = EditorGUIUtility.singleLineHeight;
                    body.recievers[index] = (Animator)EditorGUI.ObjectField(rect, body.recievers[index], typeof(Animator), true);
                };
            }
            recieverReorderableList.DoLayoutList();

            EditorGUI.BeginChangeCheck();
            operation = (ToggleOperation)EditorGUILayout.EnumPopup("Operation", GetOperation());
            if (EditorGUI.EndChangeCheck())
            {
                SelectOperation();
            }

            if (!master || master.randomize)
            {
                prop = serializedObject.FindProperty("randomAvg");
                EditorGUILayout.PropertyField(prop);
            }

            serializedObject.ApplyModifiedProperties();
        }
Beispiel #3
0
 internal void DrawErrorTextAreas()
 {
     UdonSharpGUI.DrawCompileErrorTextArea(this);
     DrawAssemblyErrorTextArea();
 }
Beispiel #4
0
        public override void OnInspectorGUI()
        {
            //base.OnInspectorGUI();

            if (!UdonSharpEditorUtility.IsProxyBehaviour(body))
            {
                UdonSharpGUI.DrawConvertToUdonBehaviourButton(body);
                return;
            }

            T23_EditorUtility.ShowTitle("Option");
            GUILayout.Box("PropertyBox", T23_EditorUtility.HeadlineStyle());

            UdonSharpProgramAsset programAsset = UdonSharpEditorUtility.GetUdonSharpProgramAsset((UdonSharpBehaviour)target);

            UdonSharpGUI.DrawCompileErrorTextArea(programAsset);

            serializedObject.Update();

            serializedObject.FindProperty("valueType").intValue = (int)(ValueType)EditorGUILayout.EnumPopup("Value Type", (ValueType)body.valueType);
            if (body.valueType == 0)
            {
                serializedObject.FindProperty("value_b").boolValue = EditorGUILayout.Toggle("Value", body.value_b);
            }
            else if (body.valueType == 1)
            {
                serializedObject.FindProperty("value_i").intValue = EditorGUILayout.IntField("Value", body.value_i);
            }
            else if (body.valueType == 2)
            {
                serializedObject.FindProperty("value_f").floatValue = EditorGUILayout.FloatField("Value", body.value_f);
            }
            else if (body.valueType == 3)
            {
                serializedObject.FindProperty("value_v3").vector3Value = EditorGUILayout.Vector3Field("Value", body.value_v3);
            }
            else if (body.valueType == 4)
            {
                serializedObject.FindProperty("value_s").stringValue = EditorGUILayout.TextField("Value", body.value_s);
            }

            UdonSharpGUI.DrawUILine(Color.gray);

            serializedObject.FindProperty("trackType").intValue = (int)(TrackType)EditorGUILayout.EnumPopup("Track Type", (TrackType)body.trackType);
            if (body.trackType != 0)
            {
                List <string> spotList = new List <string>();
                if (body.trackType == 1)
                {
                    serializedObject.FindProperty("targetPlayer").intValue = (int)(TargetPlayer)EditorGUILayout.EnumPopup("Target Player", (TargetPlayer)body.targetPlayer);

                    if (body.targetPlayer == 1 || body.targetPlayer == 2)
                    {
                        prop = serializedObject.FindProperty("targetObject");
                        EditorGUILayout.PropertyField(prop);
                    }

                    if (body.targetPlayer == 2)
                    {
                        List <string>             triggerList = new List <string>();
                        List <UdonSharpBehaviour> usharpList  = new List <UdonSharpBehaviour>();
                        if (body.targetObject)
                        {
                            var udons = body.targetObject.GetComponents <UdonBehaviour>();
                            foreach (var udon in udons)
                            {
                                UdonSharpBehaviour usharp = UdonSharpEditorUtility.FindProxyBehaviour(udon);
                                if (usharp)
                                {
                                    var groupIDField       = usharp.GetProgramVariable("groupID") as int?;
                                    var titleField         = usharp.GetProgramVariable("title") as string;
                                    var playerTriggerField = usharp.GetProgramVariable("playerTrigger") as bool?;
                                    if (groupIDField != null && titleField != null && playerTriggerField == true)
                                    {
                                        if (titleField != "")
                                        {
                                            usharpList.Add(usharp);
                                            triggerList.Add($"[#{groupIDField}] {titleField}");
                                        }
                                    }
                                }
                            }
                        }
                        var triggerIndex = EditorGUILayout.Popup("Target Trigger", usharpList.IndexOf(body.targetTrigger), triggerList.ToArray());
                        serializedObject.FindProperty("targetTrigger").objectReferenceValue = triggerIndex >= 0 ? usharpList[triggerIndex] : null;
                    }

                    if (body.targetPlayer == 3)
                    {
                        prop = serializedObject.FindProperty("index");
                        EditorGUILayout.PropertyField(prop);
                    }

                    if (body.valueType == 0)
                    {
                        spotList.AddRange(PlayerSpot_b);
                    }
                    else if (body.valueType == 2 || body.valueType == 3)
                    {
                        spotList.AddRange(PlayerSpot_v3);
                    }
                    else if (body.valueType == 4)
                    {
                        spotList.AddRange(PlayerSpot_s);
                    }
                }

                if (body.trackType == 2)
                {
                    prop = serializedObject.FindProperty("targetObject");
                    EditorGUILayout.PropertyField(prop);
                    if (body.valueType == 0)
                    {
                        spotList.AddRange(ObjectSpot_b);
                    }
                    else if (body.valueType == 2 || body.valueType == 3)
                    {
                        spotList.AddRange(ObjectSpot_v3);
                    }
                }

                if (body.trackType == 3)
                {
                    if (body.valueType == 1 || body.valueType == 2)
                    {
                        spotList.AddRange(WorldSpot_if);
                    }
                }

                if (body.trackType == 4)
                {
                    prop = serializedObject.FindProperty("targetObject");
                    EditorGUILayout.PropertyField(prop);
                    if (body.targetObject)
                    {
                        body.targetComponent = null;
                        serializedObject.FindProperty("spot").stringValue = "";
                        if (body.valueType == 0)
                        {
                            body.targetComponent = body.targetObject.GetComponent <Toggle>();
                            if (body.targetComponent != null)
                            {
                                serializedObject.FindProperty("spot").stringValue = "Toggle";
                            }
                        }
                        if (body.valueType == 1)
                        {
                            body.targetComponent = body.targetObject.GetComponent <Text>();
                            if (body.targetComponent != null)
                            {
                                serializedObject.FindProperty("spot").stringValue = "Text";
                            }
                            else
                            {
                                body.targetComponent = body.targetObject.GetComponent <InputField>();
                                if (body.targetComponent != null)
                                {
                                    serializedObject.FindProperty("spot").stringValue = "InputField";
                                }
                            }
                        }
                        if (body.valueType == 2)
                        {
                            body.targetComponent = body.targetObject.GetComponent <Slider>();
                            if (body.targetComponent != null)
                            {
                                serializedObject.FindProperty("spot").stringValue = "Slider";
                            }
                            else
                            {
                                body.targetComponent = body.targetObject.GetComponent <Scrollbar>();
                                if (body.targetComponent != null)
                                {
                                    serializedObject.FindProperty("spot").stringValue = "Scrollbar";
                                }
                                else
                                {
                                    body.targetComponent = body.targetObject.GetComponent <Text>();
                                    if (body.targetComponent != null)
                                    {
                                        serializedObject.FindProperty("spot").stringValue = "Text";
                                    }
                                    else
                                    {
                                        body.targetComponent = body.targetObject.GetComponent <InputField>();
                                        if (body.targetComponent != null)
                                        {
                                            serializedObject.FindProperty("spot").stringValue = "InputField";
                                        }
                                    }
                                }
                            }
                        }
                        if (body.valueType == 4)
                        {
                            body.targetComponent = body.targetObject.GetComponent <Text>();
                            if (body.targetComponent != null)
                            {
                                serializedObject.FindProperty("spot").stringValue = "Text";
                            }
                            else
                            {
                                body.targetComponent = body.targetObject.GetComponent <InputField>();
                                if (body.targetComponent != null)
                                {
                                    serializedObject.FindProperty("spot").stringValue = "InputField";
                                }
                            }
                        }
                        if (body.targetComponent == null)
                        {
                            EditorGUILayout.HelpBox($"{(ValueType)body.valueType} で取得可能な UI コンポーネントがありません。", MessageType.Error);
                        }
                        else
                        {
                            EditorGUI.BeginDisabledGroup(true);
                            prop = serializedObject.FindProperty("targetComponent");
                            EditorGUILayout.PropertyField(prop);
                            EditorGUI.EndDisabledGroup();
                        }
                    }
                }

                if (body.trackType == 5)
                {
                    prop = serializedObject.FindProperty("targetComponent");
                    prop.objectReferenceValue = EditorGUILayout.ObjectField("Animator", prop.objectReferenceValue, typeof(Animator), true);
                    if (prop.objectReferenceValue != null)
                    {
                        Animator animator = prop.objectReferenceValue as Animator;
                        if (animator)
                        {
                            animator.Update(0);
                            for (int i = 0; i < animator.parameters.Length; i++)
                            {
                                var paramType = animator.GetParameter(i).type;
                                if (body.valueType == 0 && paramType == AnimatorControllerParameterType.Bool)
                                {
                                    spotList.Add(animator.GetParameter(i).name);
                                }
                                if (body.valueType == 1 && paramType == AnimatorControllerParameterType.Int)
                                {
                                    spotList.Add(animator.GetParameter(i).name);
                                }
                                if (body.valueType == 2 && paramType == AnimatorControllerParameterType.Float)
                                {
                                    spotList.Add(animator.GetParameter(i).name);
                                }
                            }
                        }
                    }
                }

                if (body.trackType == 6)
                {
                    if (body.valueType == 2)
                    {
                        spotList.AddRange(ControllerSpot_f);
                    }
                }

                if (spotList.Count > 0)
                {
                    var spotIndex = EditorGUILayout.Popup("Spot", spotList.IndexOf(body.spot), spotList.ToArray());
                    serializedObject.FindProperty("spot").stringValue = spotIndex >= 0 ? spotList[spotIndex] : "";
                }

                if (body.valueType == 2)
                {
                    List <string> changeable = new List <string>();
                    changeable.AddRange(PlayerSpot_v3);
                    changeable.AddRange(ObjectSpot_v3);
                    if (changeable.Contains(body.spot))
                    {
                        List <string> detailList  = new List <string>(SpotDetail_v3_f);
                        var           detailIndex = EditorGUILayout.Popup("Spot Detail", detailList.IndexOf(body.spotDetail), SpotDetail_v3_f);
                        serializedObject.FindProperty("spotDetail").stringValue = detailIndex >= 0 ? SpotDetail_v3_f[detailIndex] : "";
                    }
                }

                if (body.valueType == 4)
                {
                    List <string> detailList  = new List <string>(SpotDetail_s);
                    var           detailIndex = EditorGUILayout.Popup("Spot Detail", detailList.IndexOf(body.spotDetail), SpotDetail_s);
                    serializedObject.FindProperty("spotDetail").stringValue = detailIndex >= 0 ? SpotDetail_s[detailIndex] : "";
                    if (serializedObject.FindProperty("spotDetail").stringValue == "OneLetter")
                    {
                        prop = serializedObject.FindProperty("index");
                        EditorGUILayout.PropertyField(prop);
                    }
                }

                if (body.spot.Contains("Position"))
                {
                    prop = serializedObject.FindProperty("positionTracking");
                    EditorGUILayout.PropertyField(prop);
                }
                else
                {
                    serializedObject.FindProperty("positionTracking").boolValue = false;
                }

                bool constAlways = body.trackType == 6 && body.valueType == 2;
                EditorGUI.BeginDisabledGroup(constAlways);
                prop = serializedObject.FindProperty("updateEveryFrame");
                EditorGUILayout.PropertyField(prop);
                EditorGUI.EndDisabledGroup();
                if (constAlways)
                {
                    serializedObject.FindProperty("updateEveryFrame").boolValue = true;
                }
            }

            serializedObject.ApplyModifiedProperties();
        }
        public override void OnInspectorGUI()
        {
            //base.OnInspectorGUI();

            if (!T23_EditorUtility.GuideJoinMaster(master, body, body.groupID, 1))
            {
                return;
            }

            UdonSharpProgramAsset programAsset = UdonSharpEditorUtility.GetUdonSharpProgramAsset((UdonSharpBehaviour)target);

            UdonSharpGUI.DrawCompileErrorTextArea(programAsset);

            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);
            }

            prop = serializedObject.FindProperty("passive");
            EditorGUILayout.PropertyField(prop);
            if (!body.passive)
            {
                prop = serializedObject.FindProperty("allowContinuity");
                EditorGUILayout.PropertyField(prop);
            }

            GUILayout.Space(10);
            EditorGUILayout.LabelField("Base", EditorStyles.boldLabel);
            serializedObject.FindProperty("basePropertyBox").objectReferenceValue = EditorGUILayout.ObjectField("PropertyBox", body.basePropertyBox, typeof(T23_PropertyBox), true);

            if (body.basePropertyBox)
            {
                GUILayout.Space(10);
                EditorGUILayout.LabelField("Comparison", EditorStyles.boldLabel);
                serializedObject.FindProperty("compOperator").intValue      = EditorGUILayout.Popup("Operator", body.compOperator, (body.basePropertyBox.valueType == 1 || body.basePropertyBox.valueType == 2) ? CompOperator_a : CompOperator_b);
                serializedObject.FindProperty("compParameterType").intValue = (int)(CompParameterType)EditorGUILayout.EnumPopup("Parameter Type", (CompParameterType)body.compParameterType);
                if (body.compParameterType == 0)
                {
                    switch (body.basePropertyBox.valueType)
                    {
                    case 0:
                        serializedObject.FindProperty("comp_b").boolValue = EditorGUILayout.Toggle("Value", body.comp_b);
                        break;

                    case 1:
                        serializedObject.FindProperty("comp_i").intValue = EditorGUILayout.IntField("Value", body.comp_i);
                        break;

                    case 2:
                        serializedObject.FindProperty("comp_f").floatValue = EditorGUILayout.FloatField("Value", body.comp_f);
                        break;

                    case 4:
                        serializedObject.FindProperty("comp_s").stringValue = EditorGUILayout.TextField("Value", body.comp_s);
                        break;
                    }
                }
                if (body.compParameterType == 1)
                {
                    serializedObject.FindProperty("compPropertyBox").objectReferenceValue = EditorGUILayout.ObjectField("PropertyBox", body.compPropertyBox, typeof(T23_PropertyBox), true);
                    if (body.compPropertyBox)
                    {
                        if (body.compPropertyBox.valueType != body.basePropertyBox.valueType)
                        {
                            EditorGUILayout.HelpBox("PropertyBox の ValueType が不適合です", MessageType.Error);
                        }
                    }
                }
            }

            serializedObject.ApplyModifiedProperties();
        }