Ejemplo n.º 1
0
        public override void DrawProperties()
        {
            base.DrawProperties();
            EditorGUILayout.BeginVertical();
            {
                if (m_freeInputCountNb)
                {
                    EditorGUILayout.LabelField(_inputAmountStr);
                    m_inputCount = EditorGUILayoutIntField(m_inputCount);
                }

                EditorGUILayout.LabelField(_inputTypeStr);
                m_selectedType = ( WirePortDataType )EditorGUILayoutEnumPopup(m_selectedType);
            }
            EditorGUILayout.EndVertical();
            if (m_inputCount != m_lastInputCount)
            {
                if (m_inputCount > m_lastInputCount)
                {
                    int newPortsAmount = (m_inputCount - m_lastInputCount);
                    for (int i = 0; i < newPortsAmount; i++)
                    {
                        AddInputPort(m_selectedType, false, (i + m_lastInputCount).ToString());
                    }
                }
                else
                {
                    int newPortsAmount = (m_lastInputCount - m_inputCount);
                    for (int i = 0; i < newPortsAmount; i++)
                    {
                        DeleteInputPortByArrayIdx(m_inputPorts.Count - 1);
                    }
                }

                m_lastInputCount = m_inputCount;
                m_sizeIsDirty    = true;
                m_isDirty        = true;
                SetSaveIsDirty();
                OnInputChange();
            }

            if (m_selectedType != m_lastSelectedType)
            {
                if (UIUtils.CanCast(m_lastSelectedType, m_selectedType))
                {
                    ChangeInputType(m_selectedType, false);
                    ChangeOutputType(m_selectedType, false);
                }
                else
                {
                    DeleteAllInputConnections(false);
                    DeleteAllOutputConnections(false);
                    ChangeInputType(m_selectedType, true);
                    ChangeOutputType(m_selectedType, true);
                }
                SetSaveIsDirty();
                m_isDirty          = true;
                m_lastSelectedType = m_selectedType;
                OnTypeChange();
            }
        }