private void DrawNodeGUI(HashSet <CommandNode> setNode)
        {
            if (setNode.Count == 0)
            {
                GUILayout.Label("-");
            }
            foreach (CommandNode node in setNode)
            {
                GUILayout.BeginHorizontal();
                Rect boxRect   = GUILayoutUtility.GetRect(new GUIContent(""), EditorStyles.textField, GUILayout.ExpandWidth(true));
                Rect labelRect = new Rect(boxRect.xMin + 5, boxRect.yMin, boxRect.width * 0.75f - 5, boxRect.height);
                GUI.Box(labelRect, "");
                GUI.Label(labelRect, node.Name);
                Rect buttonRect = new Rect(labelRect.xMax + 10, boxRect.yMin, boxRect.width * 0.25f - 15, boxRect.height);

                if (GUI.Button(buttonRect, "Select", EditorStyles.miniButton))
                {
                    window_ = (CarManagerEditor)CarManagerEditor.Init();
                    hierarchy_.FocusAndSelect(node);
                    window_.Repaint();
                }

                GUILayout.EndHorizontal();
            }
        }
Example #2
0
        public override void OnInspectorGUI()
        {
            Rect rect = GUILayoutUtility.GetRect(80f, 80f);

            GUI.DrawTexture(rect, ic_logoCaronte_, ScaleMode.ScaleToFit);
            CarGUIUtils.Splitter();

            EditorGUILayout.Space();
            EditorGUILayout.Space();
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();

            if (GUILayout.Button("Open in CaronteFX Editor", GUILayout.Height(30f)))
            {
                CarManagerEditor editor = (CarManagerEditor)CarManagerEditor.Init();
                editor.Controller.SetFxDataActive(fxData_);
            }
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
            EditorGUILayout.Space();
            EditorGUILayout.Space();
        }
        public override void OnInspectorGUI()
        {
            serializedObject.Update();
            bool isEditing = false;

            if (CarManagerEditor.IsOpen)
            {
                window_              = CarManagerEditor.Instance;
                window_.WantRepaint -= Repaint;
                window_.WantRepaint += Repaint;
            }

            if (CarManager.IsInitedStatic)
            {
                manager_   = CarManager.Instance;
                hierarchy_ = manager_.Hierarchy;
                manager_.GetBodiesData(listBodyData_);

                isEditing = manager_.Player.IsEditing;
            }
            else
            {
                listBodyData_.Clear();
            }

            CRBodyData bdData = null;
            uint       idBody = uint.MaxValue;

            int nBodyData = listBodyData_.Count;

            BodyType bodyType;
            string   bodyTypeText;
            string   bodyIdText;

            if (nBodyData == 0)
            {
                bodyType     = BodyType.None;
                bodyTypeText = "-";
                bodyIdText   = "-";
            }
            else
            {
                bdData = listBodyData_[0];

                bodyType     = bdData.bodyType_;
                bodyTypeText = GetBodyTypeString(bdData.bodyType_);
                idBody       = bdData.idBody_;

                for (int i = 1; i < nBodyData; i++)
                {
                    bdData = listBodyData_[i];

                    if (bdData.bodyType_ != bodyType)
                    {
                        bodyType     = BodyType.None;
                        bodyTypeText = "-";
                        bodyIdText   = "-";
                        break;
                    }
                }

                if (idBody == uint.MaxValue || nBodyData > 1)
                {
                    bodyIdText = "-";
                }
                else
                {
                    bodyIdText = idBody.ToString();
                }
            }

            HashSet <CommandNode> setBodyDefinition = new HashSet <CommandNode>();
            HashSet <CommandNode> setBodyReference  = new HashSet <CommandNode>();

            for (int i = 0; i < nBodyData; i++)
            {
                bdData = listBodyData_[i];
                List <CommandNode> bdDataNodes = bdData.listNode_;
                int nDataNodes = bdDataNodes.Count;
                for (int j = 0; j < nDataNodes; j++)
                {
                    CommandNode node = bdDataNodes[j];
                    if (j == 0)
                    {
                        setBodyDefinition.Add(node);
                    }
                    else
                    {
                        setBodyReference.Add(node);
                    }
                }
            }

            EditorGUILayout.Space();

            EditorGUILayout.LabelField("Body type: ", bodyTypeText);
            EditorGUILayout.LabelField("Body id:", bodyIdText);

            EditorGUILayout.Space();

            if (bodyType == BodyType.None)
            {
                DrawFullBodySection();
            }
            else if (bodyType == BodyType.Ropebody)
            {
                DrawRopeColliderSection(isEditing);
            }
            else if (IsNotBodyMesh(bodyType))
            {
                DrawBodyColliderSection();
            }

            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Body Definition: ");

            scrollVecDefinition_ = GUILayout.BeginScrollView(scrollVecDefinition_, GUILayout.ExpandHeight(false));

            DrawNodeGUI(setBodyDefinition);
            GUILayout.EndScrollView();

            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Referenced in: ");

            scrollVecReferenced_ = GUILayout.BeginScrollView(scrollVecReferenced_, GUILayout.ExpandHeight(false));
            DrawNodeGUI(setBodyReference);
            GUILayout.EndScrollView();
            CarGUIUtils.Splitter();

            if (!CarManagerEditor.IsOpen)
            {
                EditorGUILayout.Space();
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.Space();

                if (GUILayout.Button("Open CaronteFx Editor", GUILayout.Height(30f)))
                {
                    window_ = (CarManagerEditor)CarManagerEditor.Init();
                }

                EditorGUILayout.Space();
                EditorGUILayout.EndHorizontal();
                EditorGUILayout.Space();
            }

            serializedObject.ApplyModifiedProperties();
        }