Ejemplo n.º 1
0
 private void SetObjectDrawing(bool value)
 {
     try
     {
         GameObject       containerBase = selectedObject.GetOrAddVisualBase(BaseType.Object);
         DrawObjectBounds dob           = containerBase.GetOrAddComponent <DrawObjectBounds>();
         dob.IsDraw(value);
     }
     catch
     {
         string component = typeof(DrawObjectBounds).ToString().Split('.').GetLast();
         OutputWindow_Log(ERROR_TEXT[ERRORS.GET_OR_ADD_COMPONENT_ERROR], LogType.Exception, component, selectedObject.name);
     }
 }
Ejemplo n.º 2
0
        private void OnGUI()
        {
            if (isDirty)
            {
                return;
            }

            SafetyCheck();

            Rect windowRect = SNWindow.CreateWindow(new Rect(0, 30, 298, 700), RuntimeHelper_Config.TitleText);

            GUI.Label(new Rect(windowRect.x + 5, windowRect.y, 290, 25), $"Base : {baseObject.name}", SNStyles.GetGuiItemStyle(GuiItemType.LABEL, GuiColor.Green, TextAnchor.MiddleLeft));

            ScrollView_transforms_event = SNScrollView.CreateScrollView(new Rect(windowRect.x + 5, windowRect.y + 22, windowRect.width - 10, 212), ref scrollpos_transforms, ref guiItems_transforms, isRootList ? "Active Scenes Root Game Objects" : "Childs of", isRootList ? string.Empty : baseObject.name, 10);

            GUI.Label(new Rect(windowRect.x + 5, windowRect.y + 300, 40, 22), "Base :", SNStyles.GetGuiItemStyle(GuiItemType.LABEL, GuiColor.Green, TextAnchor.MiddleLeft));


            if (GUI.Button(new Rect(windowRect.x + 60, windowRect.y + 300, 60, 22), MainWindow[0], SNStyles.GetGuiItemStyle(GuiItemType.NORMALBUTTON, GuiColor.Gray)))
            {
                OnBaseObjectChange(selectedObject);
            }

            if (GUI.Button(new Rect(windowRect.x + 125, windowRect.y + 300, 60, 22), MainWindow[1], SNStyles.GetGuiItemStyle(GuiItemType.NORMALBUTTON, GuiColor.Gray)))
            {
                OnRefreshBase();
            }

            if (GUI.Button(new Rect(windowRect.x + 190, windowRect.y + 300, 103, 22), MainWindow[2], SNStyles.GetGuiItemStyle(GuiItemType.NORMALBUTTON, GuiColor.Gray)))
            {
                GetRoots();
            }

            GUI.Label(new Rect(windowRect.x + 5, windowRect.y + 325, 40, 22), "Object :", SNStyles.GetGuiItemStyle(GuiItemType.LABEL, GuiColor.Green, TextAnchor.MiddleLeft));

            if (GUI.Button(new Rect(windowRect.x + 60, windowRect.y + 325, 30, 22), selectedObject.activeSelf ? MainWindow[4] : MainWindow[3], SNStyles.GetGuiItemStyle(GuiItemType.NORMALBUTTON, GuiColor.Gray)))
            {
                if (selectedObject == gameObject)
                {
                    OutputWindow_Log(WARNING_TEXT[WARNINGS.OBJECT_STATE_CANNOT_MODIFIED], LogType.Warning, selectedObject.name);
                    return;
                }

                selectedObject.SetActive(!selectedObject.activeSelf);
                OutputWindow_Log(MESSAGE_TEXT[MESSAGES.ACTIVE_STATE_CHANGE], selectedObject.name, selectedObject.activeSelf.ToString());
            }

            if (GUI.Button(new Rect(windowRect.x + 95, windowRect.y + 325, 40, 22), MainWindow[17], SNStyles.GetGuiItemStyle(GuiItemType.NORMALBUTTON, GuiColor.Gray)))
            {
                AddToMarkList(selectedObject);
            }

            if (GUI.Button(new Rect(windowRect.x + 140, windowRect.y + 325, 40, 22), MainWindow[5], SNStyles.GetGuiItemStyle(GuiItemType.NORMALBUTTON, GuiColor.Gray)))
            {
                if (selectedObject == gameObject)
                {
                    OutputWindow_Log(WARNING_TEXT[WARNINGS.OBJECT_CANNOT_COPIED], LogType.Warning, selectedObject.name);
                }
                else
                {
                    if (tempObject)
                    {
                        DestroyImmediate(tempObject);
                    }

                    selectedObject.CopyObject(out tempObject);
                    OutputWindow_Log(MESSAGE_TEXT[MESSAGES.OBJECT_COPIED], tempObject.name);
                }
            }


            if (GUI.Button(new Rect(windowRect.x + 185, windowRect.y + 325, 45, 22), MainWindow[6], SNStyles.GetGuiItemStyle(GuiItemType.NORMALBUTTON, GuiColor.Gray)))
            {
                if (tempObject)
                {
                    OnPasteObject();
                }
                else
                {
                    OutputWindow_Log(WARNING_TEXT[WARNINGS.TEMP_OBJECT_EMPTY], LogType.Warning);
                }
            }

            if (GUI.Button(new Rect(windowRect.x + 235, windowRect.y + 325, 58, 22), MainWindow[7], SNStyles.GetGuiItemStyle(GuiItemType.NORMALBUTTON, GuiColor.Gray)))
            {
                if (selectedObject == gameObject)
                {
                    OutputWindow_Log(WARNING_TEXT[WARNINGS.PROGRAM_OBJECT_CANNOT_DESTROY], LogType.Warning, selectedObject.name);
                }

                /*
                 * else if (selectedObject.IsRoot())
                 * {
                 *  OutputWindow_Log(WARNING_TEXT[WARNINGS.ROOT_OBJECT_CANNOT_DESTROY], LogType.Warning);
                 * }*/
                else
                {
                    DestroyObject(true);
                }
            }

            GUI.TextArea(new Rect(windowRect.x + 5, windowRect.y + 355, windowRect.width - 10, 100), OBJECTINFO);

            if (isColliderSelected)
            {
                GUI.TextArea(new Rect(windowRect.x + 5, windowRect.y + 465, windowRect.width - 10, 72), COLLIDERINFO);
            }

            GUI.Label(new Rect(windowRect.x + 5, windowRect.y + 542, 145, 22), "Transform shorthands:", SNStyles.GetGuiItemStyle(GuiItemType.LABEL, GuiColor.Green, TextAnchor.MiddleLeft));

            if (GUI.Button(new Rect(windowRect.x + 150, windowRect.y + 542, 140, 22), showLocal ? MainWindow[8] : MainWindow[9], SNStyles.GetGuiItemStyle(GuiItemType.NORMALBUTTON, GuiColor.Gray)))
            {
                showLocal = !showLocal;

                if (showLocal)
                {
                    OutputWindow_Log(MESSAGE_TEXT[MESSAGES.TRANSFORM_TO_LOCAL]);
                }
                else
                {
                    OutputWindow_Log(MESSAGE_TEXT[MESSAGES.TRANSFORM_TO_WORLD]);
                }
            }

            if (GUI.Button(new Rect(windowRect.x + 5, windowRect.y + 567, 140, 22), MainWindow[10], SNStyles.GetGuiItemStyle(GuiItemType.NORMALBUTTON, GuiColor.Gray)))
            {
                if (showLocal)
                {
                    selectedObject.transform.SetLocalsToZero();
                    OutputWindow_Log(MESSAGE_TEXT[MESSAGES.LOCALS_TO_ZERO], selectedObject.name);
                }
                else
                {
                    selectedObject.transform.SetWorldToZero();
                    OutputWindow_Log(MESSAGE_TEXT[MESSAGES.WORLD_TO_ZERO], selectedObject.name);
                }
            }

            if (GUI.Button(new Rect(windowRect.x + 150, windowRect.y + 567, 140, 22), MainWindow[11], SNStyles.GetGuiItemStyle(GuiItemType.NORMALBUTTON, GuiColor.Gray)))
            {
                if (showLocal)
                {
                    selectedObject.transform.SetLocalPositionToZero();
                    OutputWindow_Log(MESSAGE_TEXT[MESSAGES.LOCAL_POS_TO_ZERO], selectedObject.name);
                }
                else
                {
                    selectedObject.transform.SetPositionToZero();
                    OutputWindow_Log(MESSAGE_TEXT[MESSAGES.WORLD_POS_TO_ZERO], selectedObject.name);
                }
            }

            if (GUI.Button(new Rect(windowRect.x + 5, windowRect.y + 592, 140, 22), MainWindow[12], SNStyles.GetGuiItemStyle(GuiItemType.NORMALBUTTON, GuiColor.Gray)))
            {
                if (showLocal)
                {
                    selectedObject.transform.SetLocalRotationToZero();
                    OutputWindow_Log(MESSAGE_TEXT[MESSAGES.LOCAL_ROT_TO_ZERO], selectedObject.name);
                }
                else
                {
                    selectedObject.transform.SetRotationToZero();
                    OutputWindow_Log(MESSAGE_TEXT[MESSAGES.WORLD_ROT_TO_ZERO], selectedObject.name);
                }
            }

            if (GUI.Button(new Rect(windowRect.x + 150, windowRect.y + 592, 140, 22), MainWindow[13], SNStyles.GetGuiItemStyle(GuiItemType.NORMALBUTTON, GuiColor.Gray)))
            {
                selectedObject.transform.SetLocalScaleToOne();
                OutputWindow_Log(MESSAGE_TEXT[MESSAGES.LOCAL_SCALE_TO_ONE], selectedObject.name);
            }

            if (GUI.Button(new Rect(windowRect.x + 5, windowRect.y + 617, 140, 22), MainWindow[14], SNStyles.GetGuiItemStyle(GuiItemType.NORMALBUTTON, GuiColor.Gray)))
            {
                DrawObjectBounds dob = selectedObject.GetOrAddVisualBase(BaseType.Object).GetComponent <DrawObjectBounds>();
                selectedObject.transform.SetTransformInfo(ref dob.transformBase);
                OutputWindow_Log(MESSAGE_TEXT[MESSAGES.TRANSFORM_TO_ORIGINAL], selectedObject.name);
            }

            if (isColliderSelected)
            {
                if (GUI.Button(new Rect(windowRect.x + 150, windowRect.y + 617, 140, 22), MainWindow[15], SNStyles.GetGuiItemStyle(GuiItemType.NORMALBUTTON, GuiColor.Gray)))
                {
                    DrawColliderControl dcc = selectedObject.GetComponentInChildren <DrawColliderControl>();

                    int colliderID = objects[selected_component].GetInstanceID();

                    selectedObject.ResetCollider(dcc.ColliderBases[colliderID].ColliderBase, colliderID);

                    GetColliderInfo();

                    OutputWindow_Log(MESSAGE_TEXT[MESSAGES.COLLIDER_TO_ORIGINAL], dcc.ColliderBases[colliderID].ColliderBase.ColliderType.ToString());
                }
            }

            if (GUI.Button(new Rect(windowRect.x + 5, (windowRect.y + windowRect.height) - 27, windowRect.width - 10, 22), MainWindow[16], SNStyles.GetGuiItemStyle(GuiItemType.NORMALBUTTON, GuiColor.Gray)))
            {
                OnDestroy();
            }

            OutputWindow_OnGUI();

            EditWindow_OnGUI();

            ObjectWindow_OnGUI();

            ComponentWindow_OnGUI();

            RendererWindow_OnGUI();

            ObjectInfoWindow_OnGUI();

            AddComponentWindow_OnGUI();

            MarkWindow_OnGUI();


            if (GUI.tooltip != "")
            {
                GUIStyle gUIStyle = SNStyles.GetGuiItemStyle(GuiItemType.TEXTAREA, GuiColor.Green, TextAnchor.MiddleLeft);

                Vector2 vector2 = gUIStyle.CalcSize(new GUIContent(GUI.tooltip));

                GUI.Label(new Rect(Event.current.mousePosition.x + 10, Event.current.mousePosition.y + 10, vector2.x, vector2.y), GUI.tooltip, gUIStyle);
            }
        }