Exemplo n.º 1
0
 private static EditorTexture GetIcon(IUnitPort port)
 {
     if (port is IUnitControlPort)
     {
         return(typeof(Flow).Icon());
     }
     else if (port is IUnitValuePort)
     {
         return(Icons.Type(((IUnitValuePort)port).type));
     }
     else if (port is IUnitInvalidPort)
     {
         return(BoltCore.Resources.icons.errorState);
     }
     else
     {
         throw new NotSupportedException();
     }
 }
        public override void DrawForeground()
        {
            base.DrawForeground();

            if (BoltFlow.Configuration.showConnectionValues)
            {
                var showLastValue      = EditorApplication.isPlaying && ConnectionDebugData.assignedLastValue;
                var showPredictedvalue = BoltFlow.Configuration.predictConnectionValues && !EditorApplication.isPlaying && Flow.CanPredict(connection.source, reference);

                if (showLastValue || showPredictedvalue)
                {
                    var previousIconSize = EditorGUIUtility.GetIconSize();
                    EditorGUIUtility.SetIconSize(new Vector2(IconSize.Small, IconSize.Small));

                    object value;

                    if (showLastValue)
                    {
                        value = ConnectionDebugData.lastValue;
                    }
                    else // if (showPredictedvalue)
                    {
                        value = Flow.Predict(connection.source, reference);
                    }

                    var label         = new GUIContent(value.ToShortString(), Icons.Type(value?.GetType())?[IconSize.Small]);
                    var labelSize     = Styles.prediction.CalcSize(label);
                    var labelPosition = new Rect(position.position - labelSize / 2, labelSize);

                    BeginDim();

                    GUI.Label(labelPosition, label, Styles.prediction);

                    EndDim();

                    EditorGUIUtility.SetIconSize(previousIconSize);
                }
            }
        }
Exemplo n.º 3
0
 private BoltFlowResources(BoltFlow plugin) : base(plugin)
 {
     icons = new Icons(this);
 }