コード例 #1
0
    void OnGUI()
    {
        if (newProject == null)
        {
            Init();
        }
        GUI.Label(new Rect(0, 10, 150, 20), "Settings", EditorStyles.boldLabel);
        GUI.Label(new Rect(0, 30, 150, 20), "Project Name");
        newProject.Name = GUI.TextField(new Rect(150, 30, 300, 20), newProject.Name);
        GUI.Label(new Rect(0, 60, 150, 20), "Project Description");
        newProject.Description = GUI.TextField(new Rect(150, 60, 300, 20), newProject.Description);
        GUI.Label(new Rect(0, 140, 150, 20), "Location");
        GUI.enabled     = false;
        newProject.Path = GUI.TextField(new Rect(150, 140, 300, 20), newProject.Path);
        // Button to upload image
        GUI.enabled = true;
        browse      = GUI.Button(new Rect(150, 160, 150, 20), "Browse");
        err.ShowErrors();
        UpdateValidationVal();
        if (GUI.Button(new Rect(0, 200, 300, 20), "Create") && !err.CheckErrors())
        {
            if (ValidateInput())
            {
                newProject.CreateProject();
                this.Close();
            }
        }

        Texture Logo = Resources.Load <Texture>("LogoPUCMM");

        GUI.DrawTexture(new Rect(350, 200, Logo.width, Logo.height),
                        Logo);
    }
コード例 #2
0
    /// <summary>
    /// Llama la función de actualizar del Unity
    /// </summary>
    void Update()
    {
        //Si se crea un nuevo elemento
        if (CreateButton)
        {
            elementObject = NewGameObject();
            Creating      = true;
        }

        //Funcionamineto de guardado
        if (SaveButton && !err.CheckErrors())
        {
            SaveElement();
            elementObject = NewGameObject();
        }

        //Si se elimina un elemento
        if (DeleteButton)
        {
            Delete();
            ListObjects   = (Resources.LoadAll(Type, typeof(GameObject)));
            elementObject = NewGameObject();
        }

        if (SelectButton)
        {
            AssignElement();
            this.Close();
        }

        UpdateForm();
        UpdateValidations();
    }
コード例 #3
0
    /// <summary>
    /// Funcion que se llama cuando la ventana esta en focus
    /// </summary>
    void OnGUI()
    {
        if (err == null || obtype == null)
        {
            Init();
        }

        Rect LeftSide = new Rect(0, 0, 600, 300);

        GUILayout.BeginArea(LeftSide, "Settings", EditorStyles.helpBox);
        GUI.enabled = false;
        path        = GUI.TextField(new Rect(0, 0, 300, 20), path);
        if (path.Length != 0)
        {
            image.path = path;
        }
        GUI.enabled = true;
        upload      = GUI.Button(new Rect(300, 0, 100, 20), "Upload Photo");
        Texture     = new Texture2D(width, height);
        Texture.LoadImage(image.File);
        EditorGUI.LabelField(new Rect(0, 30, 100, 20), new GUIContent("Name:"));
        Name = EditorGUI.TextField(new Rect(90, 30, 200, 20), Name);
        EditorGUI.LabelField(new Rect(0, 70, 100, 20), new GUIContent("Sprite Type:"));
        Type = EditorGUI.Popup(new Rect(90, 70, 200, 10), Type, obtype);
        EditorGUI.LabelField(new Rect(0, 90, 100, 20), new GUIContent("Description:"));
        EditorGUI.TextField(new Rect(0, 110, 290, 120), ObjectTypes.GetDescription(obtype[Type]));
        EditorGUI.LabelField(new Rect(300, 70, 80, 20), new GUIContent("Sprite Sheet:"));
        spritesheet = EditorGUI.Toggle(new Rect(300, 90, 20, 20), spritesheet);
        EditorGUI.DrawPreviewTexture(new Rect(300, 110, width, height), Texture);
        UpdateValidationVal();
        import = GUI.Button(new Rect(60, 240, 300, 20), "Import Object");
        err.ShowErrors();
        if (!import && err.CheckErrors())
        {
            import = false;
        }
        GUILayout.EndArea();

        Texture Logo = Resources.Load <Texture>("LogoPUCMM");

        GUI.DrawTexture(new Rect(LeftSide.width - Logo.width, LeftSide.height, Logo.width, Logo.height),
                        Logo);
    }
コード例 #4
0
    /// <summary>
    /// Funcion que se llama cuando la ventana esta en focus
    /// </summary>
    void OnGUI()
    {
        Rect LeftSide = new Rect(0, 0, 500, 300);

        GUILayout.BeginArea(LeftSide, "Settings", EditorStyles.helpBox);
        GUILayout.Space(15);

        //err.ShowErrorsLayout();

        GUILayout.BeginHorizontal();
        GUI.enabled = false;
        EditorGUILayout.TextField("", sound.path);
        GUI.enabled = true;
        upload      = GUILayout.Button("Upload Sound");
        GUILayout.EndHorizontal();

        GUILayout.Space(30);
        Name = EditorGUILayout.TextField("Name:", Name);
        Type = (Constant.AudioType)EditorGUILayout.EnumPopup("Type:", Type);

        GUI.enabled = false;
        EditorGUILayout.TextArea(GetDescription());
        GUI.enabled = true;

        GUILayout.Space(15);
        import = GUILayout.Button("Import Audio");
        GUILayout.EndArea();

        Texture Logo = Resources.Load <Texture>("LogoPUCMM");

        GUI.DrawTexture(new Rect(LeftSide.width - Logo.width, LeftSide.height, Logo.width, Logo.height),
                        Logo);

        if (!import && err.CheckErrors())
        {
            import = false;
        }

        //UpdateValidationVal();
    }
コード例 #5
0
    /// <summary>
    /// Funcion que se llama cuando la ventana esta abierta. dibuja los objetos de la ventana.
    /// </summary>
    void OnGUI()
    {
        RenderLeftSide();
        if (selectMode)
        {
            GUI.enabled = false;
        }

        GUILayout.BeginArea(new Rect((float)(this.position.width * 0.3), 0, (float)(this.position.width * 0.7), this.position.height - 20), EditorStyles.helpBox);
        err.ShowErrorsLayout();
        GUILayout.Label("Settings", EditorStyles.boldLabel);
        map.Data.Name   = EditorGUILayout.TextField("Map Name", map.Data.Name);
        map.Data.Width  = EditorGUILayout.IntField("Width", map.Data.Width);
        map.Data.Heigth = EditorGUILayout.IntField("Heigth", map.Data.Heigth);
        GUILayout.Label("Starting position (Player)", EditorStyles.boldLabel);

        GUILayout.BeginHorizontal();
        string audioname = map.Data.Background != null ? map.Data.Background.name : string.Empty;

        GUI.enabled = false;
        EditorGUILayout.TextField(audioname);
        GUI.enabled = true;
        if (GUILayout.Button("Select Audio"))
        {
            EditorGUIUtility.ShowObjectPicker <AudioClip>(null, false, "Background_", 1);
        }
        GUILayout.EndHorizontal();

        UpdateValidationVal();
        GUILayout.EndArea();

        errores = err.CheckErrors();
        if (!selectMode)
        {
            if (GUI.Button(new Rect((float)(this.position.width * 0.3), this.position.height - 20, 100, 20), "Save") && !errores)
            {
                if (Selected != null)
                {
                    SaveSelected();
                }
                else
                {
                    CreateNew();
                }
                ClearFields();
            }
            if (Selected != null)
            {
                GUI.enabled = true;
            }
            else
            {
                GUI.enabled = false;
            }
            if (GUI.Button(new Rect((float)(this.position.width * 0.3) + 100, this.position.height - 20, 100, 20), "Delete"))
            {
                DeleteSelected();
                ClearFields();
            }

            GUI.enabled = true;
        }
        else
        {
            GUI.enabled  = true;
            SelectButton = GUI.Button(new Rect((float)(this.position.width * 0.3), this.position.height - 20, 100, 20), "Select");
        }

        AddObject();
    }