Exemple #1
0
        protected override void DrawAttachedObjects()
        {
            if (m_controllerTack == null)
            {
                m_controllerTack = target as TackRope;
            }

            //Attached Objects Properties
            Color v_oldColor = GUI.backgroundColor;

            DrawTitleText("Attached Objects Properties");
            GUILayout.Label("Attached Object A");
            GUILayout.BeginHorizontal();
            GUILayout.Space(20);
            GameObject v_attachedObjectA = EditorGUILayout.ObjectField(m_controllerTack.GetAttachedObjectA(), typeof(GameObject), true) as GameObject;

            if (v_attachedObjectA != m_controllerTack.GetAttachedObjectA())
            {
                m_controllerTack.ObjectA = v_attachedObjectA;
            }
            if (v_attachedObjectA != null)
            {
                TacksInventory v_tackController = v_attachedObjectA.GetNonMarkedComponentInChildren <TacksInventory>();
                if (v_tackController != null)
                {
                    v_tackController.FillWithChildrenTacks(true);
                    GUI.backgroundColor         = m_controllerTack.TackAIndex >= 0 && m_controllerTack.TackAIndex < v_tackController.TacksInObject.Count ? Color.green : Color.red;
                    m_controllerTack.TackAIndex = EditorGUILayout.Popup(m_controllerTack.TackAIndex, v_tackController.TacksInObject.GetStringList().ToArray());
                    GUI.backgroundColor         = v_oldColor;
                }
            }
            GUILayout.EndHorizontal();
            GUILayout.Label("Attached Object B");
            GUILayout.BeginHorizontal();
            GUILayout.Space(20);
            GameObject v_attachedObjectB = EditorGUILayout.ObjectField(m_controllerTack.GetAttachedObjectB(), typeof(GameObject), true) as GameObject;

            if (v_attachedObjectB != m_controllerTack.GetAttachedObjectB())
            {
                m_controllerTack.ObjectB = v_attachedObjectB;
            }
            if (v_attachedObjectB != null)
            {
                TacksInventory v_tackController = v_attachedObjectB.GetNonMarkedComponentInChildren <TacksInventory>();
                if (v_tackController != null)
                {
                    v_tackController.FillWithChildrenTacks(true);
                    GUI.backgroundColor         = m_controllerTack.TackBIndex >= 0 && m_controllerTack.TackBIndex < v_tackController.TacksInObject.Count ? Color.green : Color.red;
                    m_controllerTack.TackBIndex = EditorGUILayout.Popup(m_controllerTack.TackBIndex, v_tackController.TacksInObject.GetStringList().ToArray());
                    GUI.backgroundColor         = v_oldColor;
                }
            }
            GUILayout.EndHorizontal();
            EditorGUILayout.Separator();
        }
Exemple #2
0
    public int GetTackIndex()
    {
        TacksInventory v_controller = GetComponentInParent <TacksInventory>();
        int            v_index      = -1;

        if (v_controller != null)
        {
            v_index = v_controller.GetIndexOfTack(this);
        }
        return(v_index);
    }
    protected void HandleOnDrawElement(Rect p_rect, int p_index, bool p_isActive, bool p_isFocused)
    {
        Color v_oldColor = GUI.backgroundColor;
        AOTKeyValuePair <int, GameObject> v_currentObject = m_selectedObjects[p_index];

        if (v_currentObject != null)
        {
            Rect v_firstRect  = new Rect(p_rect.x, p_rect.y, p_rect.width - 60, p_rect.height);
            Rect v_secondRect = new Rect(p_rect.x + v_firstRect.width, p_rect.y, p_rect.width - v_firstRect.width, p_rect.height);
            GUI.enabled = m_windowInformation != null && !m_windowInformation.PickSelectedObjects;
            if (v_currentObject.Value == null)
            {
                GUI.backgroundColor = Color.red;
            }
            GameObject v_newGameObject = EditorGUI.ObjectField(v_firstRect, v_currentObject.Value, typeof(GameObject), true) as GameObject;
            GUI.backgroundColor = v_oldColor;
            GUI.enabled         = true;
            if (v_newGameObject != v_currentObject.Value)
            {
                v_currentObject.Value = v_newGameObject;
                _needFillSelected     = true;
            }
            //Draw Tack Selector
            if (v_currentObject != null)
            {
                TacksInventory v_controller = v_currentObject.Value != null?v_currentObject.Value.GetNonMarkedComponentInChildren <TacksInventory>() : null;

                if (v_controller != null)
                {
                    v_controller.FillWithChildrenTacks(true);
                }
                if (v_controller != null && v_controller.TacksInObject.Count > 0)
                {
                    GUI.backgroundColor = Color.green;
                    v_currentObject.Key = EditorGUI.Popup(v_secondRect, v_currentObject.Key, v_controller.TacksInObject.GetStringList().ToArray());
                }
                else
                {
                    GUI.enabled = false;
                    //if(v_currentObject.Value == null)
                    GUI.backgroundColor = Color.red;
                    v_currentObject.Key = EditorGUI.Popup(v_secondRect, v_currentObject.Key, new string[0]);
                    GUI.enabled         = true;
                }
                GUI.backgroundColor = v_oldColor;
            }
        }
    }
Exemple #4
0
    protected virtual void UpdateTackObjectsBeforeRopeCreated()
    {
        GameObject v_attachedObjectA = GetAttachedObjectA();
        GameObject v_attachedObjectB = GetAttachedObjectB();

        if (v_attachedObjectA != null)
        {
            TacksInventory v_tacksControllerA = v_attachedObjectA.GetNonMarkedComponentInChildren <TacksInventory>();
            if (v_tacksControllerA != null)
            {
                ObjectA = v_tacksControllerA.GetTackObjectWithIndex(TackAIndex);
            }
        }
        if (v_attachedObjectB != null)
        {
            TacksInventory v_tacksControllerB = v_attachedObjectB.GetNonMarkedComponentInChildren <TacksInventory>();
            if (v_tacksControllerB != null)
            {
                ObjectB = v_tacksControllerB.GetTackObjectWithIndex(TackBIndex);
            }
        }
        _tackUpdated = false;
    }