示例#1
0
        protected override void OnNodeGUI()
        {
            if (TargetNode.MaxChance <= 0)
            {
                TargetNode.UpdateMaxChance();
            }
            TargetNode.UpdateConnectedOutputSockets();

            DrawNodeBody();
            DrawSocketsList(Node.InputSockets);
            DrawSocketsList(Node.OutputSockets);
            DrawAddSocketButton(SocketDirection.Output, ConnectionMode.Override, typeof(WeightedConnection));
        }
示例#2
0
        private void DrawOutputSockets()
        {
            SerializedProperty        socketsProperty    = GetProperty(PropertyName.m_outputSockets);
            List <Socket>             sockets            = BaseNode.OutputSockets;
            ColorName                 directionColorName = OutputColorName;
            string                    directionTitle     = UILabels.OutputConnections;
            List <WeightedConnection> values             = OutputValues;
            GUIStyle                  directionIconStyle = OutputSocketIconStyle;

            if (socketsProperty.arraySize == 0)
            {
                return;
            }

            if (sockets.Count != values.Count)
            {
                UpdateNodeData();
                return;
            }

            DrawSmallTitleWithBackground(directionIconStyle, directionTitle, directionColorName);
            Color initialColor = GUI.color;

            GUILayout.Space(DGUI.Properties.Space());

            for (int i = 0; i < socketsProperty.arraySize; i++)
            {
                Socket socket = sockets[i];

                //                string socketName = socket.SocketName;
                float curveModifier    = socket.CurveModifier;
                int   connectionsCount = socket.Connections.Count;

                int weight = values[i].Weight;

                //                ColorName colorName = socket.IsConnected ? directionColorName : ColorName.White;

                GUILayout.Space(DGUI.Properties.Space());
                GUILayout.BeginHorizontal(GUILayout.Height(kNodeLineHeight));
                {
                    DrawSocketIndex(i, directionColorName);

                    GUILayout.BeginVertical();
                    {
                        GUILayout.BeginHorizontal(GUILayout.Height(kNodeLineHeight), GUILayout.ExpandWidth(true));
                        {
                            DGUI.Icon.Draw(socket.OverrideConnection
                                               ? Nody.Styles.GetStyle(Nody.Styles.StyleName.ConnectionPointOverrideConnected)
                                               : Nody.Styles.GetStyle(Nody.Styles.StyleName.ConnectionPointMultipleConnected),
                                           kConnectionTypeIconSize,
                                           kNodeLineHeight,
                                           connectionsCount > 0 ? ConnectionTypeIconColor(directionColorName) : NotConnectedIconColor()); //Draw socket connection type icon (Override / Multiple)

                            GUILayout.Space(kConnectionTypeIconPadding);

                            bool valueUpdated = false;

                            GUI.color = socket.IsConnected ? FieldsColor(directionColorName) : GUI.color;
                            GUILayout.Space(DGUI.Properties.Space(2));
                            DGUI.Label.Draw(UILabels.Weight, Size.M, kNodeLineHeight);
                            GUILayout.Space(DGUI.Properties.Space());
                            EditorGUI.BeginChangeCheck();
                            GUILayout.BeginVertical(GUILayout.Height(kNodeLineHeight));
                            {
                                GUILayout.Space((kNodeLineHeight - DGUI.Properties.SingleLineHeight) / 2);
                                weight = EditorGUILayout.IntSlider(GUIContent.none, weight, 0, 100, GUILayout.Height(DGUI.Properties.SingleLineHeight)); //Draw output connection weight
                            }
                            GUILayout.EndVertical();
                            if (EditorGUI.EndChangeCheck())
                            {
                                valueUpdated = true;
                            }
                            GUI.color = initialColor;


                            //                            DGUI.Icon.Draw(OutputSocketIconStyle, kConnectionTypeIconSize, kNodeLineHeight, connectionsCount > 0 ? TriggerTypeIconColor(directionColorName) : NotConnectedIconColor());

                            if (valueUpdated)
                            {
                                Undo.RecordObject(TargetNode, "Update Socket Value");
                                socket.CurveModifier = curveModifier;
                                values[i].Weight     = weight;
                                UpdateSocketValue(sockets[i], values[i]);
                                TargetNode.UpdateMaxChance();
                                NodeUpdated = true;
                            }
                        }
                        GUILayout.EndHorizontal();
                        if (DrawCurveModifier(TargetNode, socket, ShowCurveModifier))
                        {
                            NodeUpdated = true;
                        }
                    }
                    GUILayout.EndVertical();
                }
                GUILayout.EndHorizontal();

                GUILayout.Space(DGUI.Properties.Space());
            }

            GUI.color = initialColor;
        }