コード例 #1
0
    /// <summary>
    /// Renders the currently selected step
    /// </summary>
    /// <param name="rStep"></param>
    private bool DrawReactorDetailItem(ReactorAction rItem)
    {
        bool lIsDirty = false;

        if (rItem == null)
        {
            EditorGUILayout.LabelField("NULL");
            return(false);
        }

        if (rItem.Name.Length > 0)
        {
            EditorHelper.DrawSmallTitle(rItem.Name.Length > 0 ? rItem.Name : "Actor Core Reactor");
        }
        else
        {
            string lName = BaseNameAttribute.GetName(rItem.GetType());
            EditorHelper.DrawSmallTitle(lName.Length > 0 ? lName : "Actor Core Reactor");
        }

        string lDescription = BaseDescriptionAttribute.GetDescription(rItem.GetType());

        if (lDescription.Length > 0)
        {
            EditorHelper.DrawInspectorDescription(lDescription, MessageType.None);
        }

        if (EditorHelper.TextField("Name", "Friendly name of the reactor", rItem.Name, mTarget))
        {
            lIsDirty   = true;
            rItem.Name = EditorHelper.FieldStringValue;
        }

        // Render out the Reactor specific inspectors
        bool lIsReactorDirty = rItem.OnInspectorGUI(mTargetSO, mTarget);

        if (lIsReactorDirty)
        {
            lIsDirty = true;
        }

        if (lIsDirty)
        {
            mTarget._ReactorDefinitions[mReactorList.index] = rItem.Serialize();
        }

        return(lIsDirty);
    }
コード例 #2
0
    /// <summary>
    /// Allows us to draw each item in the list
    /// </summary>
    /// <param name="rRect"></param>
    /// <param name="rIndex"></param>
    /// <param name="rIsActive"></param>
    /// <param name="rIsFocused"></param>
    private void DrawReactorListItem(Rect rRect, int rIndex, bool rIsActive, bool rIsFocused)
    {
        if (rIndex < mTarget._Reactors.Count)
        {
            ReactorAction lItem = mTarget._Reactors[rIndex];
            if (lItem == null)
            {
                EditorGUI.LabelField(rRect, "NULL");
                return;
            }

            rRect.y += 2;

            bool  lIsDirty    = false;
            float lHSpace     = 5f;
            float lFlexVSpace = rRect.width - lHSpace - lHSpace - 40f - lHSpace - 16f;

            string lType = BaseNameAttribute.GetName(lItem.GetType());

            EditorGUILayout.BeginHorizontal();

            Rect lTypeRect = new Rect(rRect.x, rRect.y, lFlexVSpace / 2f, EditorGUIUtility.singleLineHeight);
            EditorGUI.LabelField(lTypeRect, lType);

            Rect   lNameRect = new Rect(lTypeRect.x + lTypeRect.width + lHSpace, lTypeRect.y, lFlexVSpace / 2f, EditorGUIUtility.singleLineHeight);
            string lNewName  = EditorGUI.TextField(lNameRect, lItem.Name);
            if (lNewName != lItem.Name)
            {
                lIsDirty   = true;
                lItem.Name = lNewName;
            }

            Rect  lPriorityRect = new Rect(lNameRect.x + lNameRect.width + lHSpace, lNameRect.y, 40f, EditorGUIUtility.singleLineHeight);
            float lNewPriority  = EditorGUI.FloatField(lPriorityRect, lItem.Priority);
            if (lNewPriority != lItem.Priority)
            {
                lIsDirty       = true;
                lItem.Priority = lNewPriority;
            }

            Rect lIsEnabledRect = new Rect(lPriorityRect.x + lPriorityRect.width + lHSpace, lPriorityRect.y, 16f, 16f);
            bool lNewIsEnabled  = EditorGUI.Toggle(lIsEnabledRect, lItem.IsEnabled);
            if (lNewIsEnabled != lItem.IsEnabled)
            {
                lIsDirty        = true;
                lItem.IsEnabled = lNewIsEnabled;
            }

            EditorGUILayout.EndHorizontal();

            // Update the item if there's a change
            if (lIsDirty)
            {
                mIsDirty = true;
                mTarget._ReactorDefinitions[rIndex] = lItem.Serialize();
            }
        }
    }