Пример #1
0
        protected override void OnEnable()
        {
            base.OnEnable();

            m_window = NodyWindow.Instance;

            m_switchBackNode = (SwitchBackNode)target;

            m_infoMessageUnnamedNodeName        = new InfoMessage(InfoMessage.MessageType.Error, UILabels.UnnamedNodeTitle, UILabels.UnnamedNodeMessage);
            m_infoMessageDuplicateNodeName      = new InfoMessage(InfoMessage.MessageType.Error, UILabels.DuplicateNodeTitle, UILabels.DuplicateNodeMessage);
            m_infoMessageErrorNoTargetConnected = new InfoMessage(InfoMessage.MessageType.Error, UILabels.NoTargetConnectedTitle, UILabels.NoTargetConnectedMessage);
            m_infoMessageErrorNoSourceConnected = new InfoMessage(InfoMessage.MessageType.Error, UILabels.NoSourceConnectedTitle, UILabels.NoSourceConnectedMessage);
        }
Пример #2
0
        protected override void OnNodeGUI()
        {
            Color color = GUI.color;

            DrawNodeBody();

            float x     = DrawRect.x + 6;
            float width = DrawRect.width - 12;


            DynamicHeight += TitleVerticalSpacing;

            //Draw Target
            var targetIconRect = new Rect(x + width / 2 - TITLE_ICON_SIZE / 2, DynamicHeight, TITLE_ICON_SIZE, TITLE_ICON_SIZE);

            DynamicHeight += targetIconRect.height;
            DynamicHeight += DGUI.Properties.Space();
            Vector2 targetContentSize = TargetContentSize;
            var     targetTextRect    = new Rect(x + width / 2 - targetContentSize.x / 2, DynamicHeight, targetContentSize.x, targetContentSize.y);

            DynamicHeight += targetTextRect.height;
            DynamicHeight += TitleVerticalSpacing;
            {
                GUI.color = GUI.color.WithAlpha(TITLE_ALPHA * color.a);
                DGUI.Icon.Draw(targetIconRect, TargetIconStyle, TitleIconColorName);
                DGUI.Label.Draw(targetTextRect, TargetContent, TitleSize, TitleTextAlign, TitleIconColorName);
                GUI.color = color;
            }
            DynamicHeight += DrawSocket(SwitchBackNode.TargetInputSocket).height;
            DynamicHeight += DrawSocket(SwitchBackNode.TargetOutputSocket).height;

            DynamicHeight += DGUI.Properties.Space(24);
            DynamicHeight += TitleVerticalSpacing;

            //Draw Sources
            var sourcesIconRect = new Rect(x + width / 2 - TITLE_ICON_SIZE / 2, DynamicHeight, TITLE_ICON_SIZE, TITLE_ICON_SIZE);

            DynamicHeight += sourcesIconRect.height;
            DynamicHeight += DGUI.Properties.Space();
            Vector2 sourcesContentSize = SourcesContentSize;
            var     sourcesTextRect    = new Rect(x + width / 2 - sourcesContentSize.x / 2, DynamicHeight, sourcesContentSize.x, sourcesContentSize.y);

            DynamicHeight += targetTextRect.height;
            DynamicHeight += TitleVerticalSpacing;
            {
                GUI.color = GUI.color.WithAlpha(TITLE_ALPHA * color.a);
                DGUI.Icon.Draw(sourcesIconRect, SourcesIconStyle, TitleIconColorName);
                DGUI.Label.Draw(sourcesTextRect, SourcesContent, TitleSize, TitleTextAlign, TitleIconColorName);
                GUI.color = color;
            }

            foreach (SwitchBackNode.SourceInfo source in SwitchBackNode.Sources)
            {
                var     sourceNameContent     = new GUIContent(source.SourceName);
                Vector2 sourceNameContentSize = SourceNameStyle.CalcSize(sourceNameContent);
                var     sourceNameRect        = new Rect(x + width / 2 - sourceNameContentSize.x / 2, DynamicHeight + (DGUI.Properties.SingleLineHeight - sourcesContentSize.y) / 2, sourceNameContentSize.x, sourceNameContentSize.y);


                if (!string.IsNullOrEmpty(SwitchBackNode.ReturnSourceOutputSocketId) && SwitchBackNode.ReturnSourceOutputSocketId == source.OutputSocketId)
                {
                    float chevronHeight    = sourceNameRect.height;
                    float chevronWidth     = sourceNameRect.height * 0.63f;
                    var   leftChevronRect  = new Rect(sourceNameRect.xMin - chevronWidth - DGUI.Properties.Space(2), sourceNameRect.y, chevronWidth, chevronHeight);
                    var   rightChevronRect = new Rect(sourceNameRect.xMax + DGUI.Properties.Space(2), sourceNameRect.y, chevronWidth, chevronHeight);
                    DGUI.Icon.Draw(leftChevronRect, Doozy.Editor.Styles.GetStyle(Doozy.Editor.Styles.StyleName.IconFaChevronLeft), DGUI.Colors.ActionColorName);
                    DGUI.Icon.Draw(rightChevronRect, Doozy.Editor.Styles.GetStyle(Doozy.Editor.Styles.StyleName.IconFaChevronRight), DGUI.Colors.ActionColorName);
                    GUI.color = DGUI.Colors.IconColor(DGUI.Colors.ActionColorName);
                }

                GUI.Label(sourceNameRect, source.SourceName, SourceNameStyle);
                GUI.color = color;

                DynamicHeight += DGUI.Properties.SingleLineHeight;

                Socket inputSocket  = Node.GetSocketFromId(source.InputSocketId);
                Socket outputSocket = Node.GetSocketFromId(source.OutputSocketId);
                if (inputSocket == null || outputSocket == null)
                {
                    SwitchBackNode.RegenerateSourcesSocketIds();
                    DynamicHeight += NodySettings.Instance.SocketHeight;
                    DynamicHeight += NodySettings.Instance.SocketHeight;
                }
                else
                {
                    DynamicHeight += DrawSocket(Node.GetSocketFromId(source.InputSocketId)).height;
                    DynamicHeight += DrawSocket(Node.GetSocketFromId(source.OutputSocketId)).height;
                }
                DynamicHeight += DGUI.Properties.Space(12);
            }

            DynamicHeight += DGUI.Properties.Space(2);

            GUI.color = color;
        }