1 (edited by roswell108 2015-07-08 12:05:54)

Topic: Collection of UFE Mods and Improvements

1.6 Engine Modifications

1.5 Engine Modifications:

This post will attempt to provide some improvements to the engine. I have only been using Unity for about 6 months, so I apologize if some of the code is not the most optimized.

Mobile Improvements:

Keep mobile devices awake while the game is running

First off, Open up UFE.cs and find Awake() on line 725 and insert
Screen.sleepTimeout = SleepTimeout.NeverSleep; after

Prevent the popup menus from being tiny when viewed on tablets
  - Instead of altering resolution, you can add a scalable matrix that will stretch the entire view as a whole.

Open IntroScript.cs and add the following variables

private float originalWidth = 1280.0f;
private float originalHeight = 720.0f;
private Vector3 scale;

Scroll down and find if (hostGameIsOpen) in the OnGUI and above it insert

scale.x = Screen.width / originalWidth; 
scale.y = Screen.height / originalHeight;
scale.z = 1f;
Matrix4x4 svMat = GUI.matrix;
GUI.matrix = Matrix4x4.TRS (Vector3.zero, Quaternion.identity, scale);

For every instance of Screen.width and Screen.height below this, replace them with originalWidth and originalHeight respectively

At the end of the conditionals (if, else if, else, etc) add

GUI.matrix = svMat;

just above the last two }'s

Open GUIScript.cs and add the same variables at the top

private float originalWidth = 1280.0f;
private float originalHeight = 720.0f;
private Vector3 scale;

Scroll down the OnGUI function and below GUI.skin = customSkin add

scale.x = Screen.width / originalWidth; 
scale.y = Screen.height / originalHeight;
scale.z = 1f;
Matrix4x4 svMat = GUI.matrix;
GUI.matrix = Matrix4x4.TRS (Vector3.zero, Quaternion.identity, scale);

For every instance of Screen.width and Screen.height below this, replace them with originalWidth and originalHeight respectively until you reach if (!isRunning || UFE.config.player1Character == null) return; and above it insert
GUI.matrix = svMat;

Standard Improvements:

Adding a background for 3D character selection

Create a plane in Unity (under Gameobject, 3D Object)
Set the position as 0, 4, 1 and rotation as 90, 180, 0 with a scale of 2.5, 0.01, 1.3
Next, you will need a material (Assets, Create, Material) and attach this material to the plane
Add the wallpaper you would like to this material (Do not include the text or icons)

Open UFE.cs and below the variable private static GameObject currentScreen; add

private static GameObject supportScreen;

After every instance of Destroy(currentScreen); add

if (supportScreen != null) {
    Destroy (supportScreen);
}

In private static void _StartCharacterSelect(float fadeTime) and private static void _StartStageSelect(float fadeTime), find the currentScreen = (GameObject) Instantiate... and below it add

if (config.persistentScreen != null) {
    supportScreen = (GameObject) Instantiate(config.persistentScreen);
}

Now you will want to set the background image for both the character select and stage select screen to an image with no background, just the text and icons.

An example of the Character Selection Screen background would be
https://www.dropbox.com/s/nwfrksechyurfn1/Background.png?dl=1

Follow the tutorial at http://www.ufe3d.com/forum/viewtopic.php?id=289 but add the p1/p2SelectInstance variables to UFE.cs as public static

Now open up the GlobalInfo.cs and find public GameObject characterSelectionScreen and below it add

public bool modelSelection;
public GameObject persistentScreen;

Open GlobalEditorWindow.cs (in the UFE/Editor folder) and find globalInfo.inroMusic = ... and below it add

globalInfo.persistentScreen = (GameObject) EditorGUILayout.ObjectField("Persistent Menu Background:", globalInfo.persistentScreen, typeof(UnityEngine.GameObject), true);
globalInfo.modelSelection = EditorGUILayout.Toggle("3D Character Selection:", globalInfo.modelSelection);

Open CharacterSelectionScript and scroll down to the Start() function and find where you added the OnCharacterHighlighted call and wrap it with

if (UFE.config.modelSelection) {

}

Scroll down to the DoFixedUpdate() section and for all of the if's that OnCharacterHighlighted was added to, add

UFE.config.modelSelection && 

at the beginning of the conditions in the if

Scroll down to the OnGUI section and uncomment the p1/p2SelectBig code and instead wrap both with

if (!UFE.config.modelSelection) {

}

Open StageSelectionScript.cs and find if (GUI.Button(returnButtonRect, "", returnButtonStyle)) UFE.StartCharacterSelect(2); in the OnGUI() section. Below this, wrap the two profilePictureBig if's with

if (!UFE.config.modelSelection) {

}

Find the void StartGame() function and above the UFE.StartGame(3); add

if (UFE.config.modelSelection) {
    if (UFE.p1SelectInstance != null) {
        Destroy(UFE.p1SelectInstance);
    }
    if (UFE.p2SelectInstance != null) {
        Destroy(UFE.p2SelectInstance);
    }
}

Finally, open the UFE.cs and after the public static void StartCharacterSelect(float fadeTime){ add

if (UFE.config.modelSelection && Camera.main.transform.rotation != Quaternion.identity) {
    Camera.main.transform.localPosition = new Vector3 (-0.2f, 4.0f, -42.0f);
    Camera.main.transform.localRotation = Quaternion.identity;
}

Note: You should set the MainCamera default position to 0, 4, -10 as the UFE tutorial suggested for this to work

You now have the option to click 3D Character Selection in the UFE Global Config under Screen Options
You will want to drag the Plane prefab you made above to the newly added "Persistent Menu Background" UFE Global Config option under Screen Options if you enable the 3D Character Selection. This will give you 3D selection with a background.

Arcade Mode with GUI option and random character selection:
* NEW / UPDATED

Open up the IntroScript.cs and add the following variables

public GUIStyle arcadeButtonStyle;
private Rect arcadeButtonRect;

In the Start() function, add

arcadeButtonRect = new Rect(0, 0, arcadeButtonStyle.normal.background.width, arcadeButtonStyle.normal.background.height);

In the same function, find if (UFE.isNetworkAddonInstalled){ and add

arcadeButtonRect = SetResolution(arcadeButtonRect, 380);

then in the else from the same conditional add

arcadeButtonRect = SetResolution(arcadeButtonRect, 340);

Scroll down to the OnGUI function and find the first if (startingCharacterSelect... and above it add

if (startingCharacterSelect && UFE.config.arcadeMode) GUI.color = new Color(1,1,1,(Mathf.PingPong(Time.time * 15, 1))/ 2);
if (GUI.Button(arcadeButtonRect, "", arcadeButtonStyle) && !startingCharacterSelect) {
    UFE.PlaySound(selectSound);
    UFE.config.arcadeMode = true;
    UFE.DelayAction(this.StartCharacterSelect, 0.5f);
    startingCharacterSelect = true;
}
GUI.color = Color.white;

then inside the original if (startingCharacterSelect) statement add

&& UFE.config.arcadeMode

and below UFE.PlaySound(selectSound); add

UFE.config.arcadeMode = false;

Now open the GlobaInfo.cs, find public class GlobalInfo: ScriptableObject and at the bottom of that list add

public bool arcadeMode;

This sets up the GUI for arcade mode and now you can go to the IntroScreen.prefab and in the Editor set the off image for the Normal background of Arcade Button Style and the on image for the Hover and Active.

Open the CharacterSelectionScript. Find the Start() function and at the bottom of it add

        if (UFE.config.arcadeMode) {
            UFE.SetCPU (1, false);
            p1PlayerSelected = true;
            p1AISelected = false;
            UFE.SetCPU (2, true);
            p2PlayerSelected = false;
            p2AISelected = true;
            int aIndex = UnityEngine.Random.Range(0, UFE.config.characters.Length);
            this.SelectCharacter(2, aIndex);
            OnCharacterHighlighted(2, aIndex);
        }

Now scroll down to the OnGUI() and replace that entire function with

    void OnGUI(){
        GUI.skin = customSkin;
        /*p1JoystickName = "";
        p2JoystickName = "";
        string[] joysticks = Input.GetJoystickNames();
        foreach(string joystickName in joysticks){
            if (joystickName != p2JoystickName) p1JoystickName = joystickName;
            if (joystickName != p1JoystickName) p2JoystickName = joystickName;
        }*/

        Texture2D p1SelectedBig = null;
        Texture2D p2SelectedBig = null;

        //GUI.BeginGroup(SetResolution(new Rect(457, 465, 378, 220)));{
        GUI.BeginGroup(SetResolution(charactersGrid));{
            int xCount = 0;
            int yCount = 0;
            int currentIndex = 0;
                foreach(CharacterInfo character in UFE.config.characters){
                    float xPos = 112 * xCount;
                    float yPos = 68 * yCount;
                    
                    xCount ++;
                    if (xCount == gridColumns){
                        yCount ++;
                        xCount = 0;
                    }
                    GUI.DrawTexture(SetResolution(new Rect(xPos, yPos, 102, 58)), character.profilePictureSmall);
                    
                    // If the player clicked over a character portrait...
                    if (GUI.Button(SetResolution(new Rect(xPos, yPos, 102, 58)), "")){
                        // Check if he was playing online or not...
                        if (Network.peerType == NetworkPeerType.Disconnected){
                            // If it's a local game, update the corresponding character immediately...
                            if (UFE.config.player1Character == null) {
                                this.SelectCharacter(1, currentIndex);
                                OnCharacterHighlighted(1, currentIndex);
                            } else if (!UFE.config.arcadeMode) {
                                if (UFE.config.player2Character == null) {
                                    this.SelectCharacter(2, currentIndex);
                                    OnCharacterHighlighted(2, currentIndex);
                                }
                            }
                        }else{
                            // If it's an online game, find out if the local player is Player1 or Player2...
                            // And only update the selection for the local player...
                            int localPlayer = UFE.GetLocalPlayer();
                            if (localPlayer == 1 && UFE.config.player1Character == null){
                                this.SelectCharacter(1, currentIndex);
                            }else if (localPlayer == 2 && UFE.config.player2Character == null){
                                this.SelectCharacter(2, currentIndex);
                            }
                        }
                    }
                    
                    //GUI.DrawTextureWithTexCoords(SetResolution(new Rect(xPos, yPos, 86, 105)), character.profilePictureSmall, new Rect(0, 0, 1, 1));
                    //if (GUI.Button(SetResolution(new Rect(xPos, yPos, 86, 105)), character.profilePictureSmall)) {
                    // .
                    //}
                    
                    //if (UFE.config.player1Character != null)
                    
                    //GUI.color = new Color(1,1,1,(Mathf.Sin(Time.time * 20) + 1)/ 2);
                    
                    if (p1HoverIndex == currentIndex && p1HoverIndex == p2HoverIndex){
                        bool selTemp = (UFE.config.player1Character != null && UFE.config.player1Character != null)? true : false;
                        DrawHud(new Rect(xPos, yPos, 102, 58), p1P2Hud, selTemp);
                        //GUI.DrawTexture(SetResolution(new Rect(xPos, yPos, 86, 105)), p1P2Hud);
                        p1SelectedBig = character.profilePictureBig;
                        p2SelectedBig = character.profilePictureBig;
                    }else{
                        if (p1HoverIndex == currentIndex){
                            DrawHud(new Rect(xPos, yPos, 102, 58), p1Hud, (UFE.config.player1Character != null));
                            //GUI.DrawTexture(SetResolution(new Rect(xPos, yPos, 86, 105)), p1Hud);
                            p1SelectedBig = character.profilePictureBig;
                        }
                        
                        if (p2HoverIndex == currentIndex){
                            DrawHud(new Rect(xPos, yPos, 102, 58), p2Hud, (UFE.config.player2Character != null));
                            //GUI.DrawTexture(SetResolution(new Rect(xPos, yPos, 86, 105)), p2Hud);
                            p2SelectedBig = character.profilePictureBig;
                        }
                    }
                    
                    //GUI.color = Color.white;
                    
                    currentIndex ++;
                    
                }
            }
        }GUI.EndGroup();
        
        if (UFE.config.modelSelection) {
            scale.x = Screen.width / originalWidth; 
            scale.y = Screen.height / originalHeight;
            scale.z = 1f;
            Matrix4x4 svMat = GUI.matrix;
            GUI.matrix = Matrix4x4.TRS (Vector3.zero, Quaternion.identity, scale);
        
            int fontSize = GUI.skin.label.fontSize;
            GUI.skin.label.fontSize = 40;
            GUI.skin.label.alignment = TextAnchor.UpperLeft;
            GUI.Label (new Rect (61, 554, 200, 80), UFE.config.characters [p1HoverIndex].characterName);
            GUI.skin.label.alignment = TextAnchor.UpperRight;
            GUI.Label (new Rect (1019, 554, 200, 80), UFE.config.characters [p2HoverIndex].characterName);
            GUI.skin.label.alignment = TextAnchor.UpperLeft;
            GUI.skin.label.fontSize = fontSize;
        
            GUI.matrix = svMat;
        } else {
            if (p1SelectedBig != null) {
                GUI.DrawTexture (SetResolution (new Rect (79, 112, 311, 496)), p1SelectedBig);
                GUI.skin.label.alignment = TextAnchor.UpperLeft;
                GUI.skin.label.fontSize = 30 * (Screen.height / 720);
                GUI.Label (SetResolution (new Rect (178, 597, 250, 50)), UFE.config.characters [p1HoverIndex].characterName);
            if (p2SelectedBig != null) {
                GUI.DrawTextureWithTexCoords (SetResolution (new Rect (902, 113, 311, 496)), p2SelectedBig, new Rect (0, 0, -1, 1));
                GUI.skin.label.alignment = TextAnchor.UpperRight;
                GUI.skin.label.fontSize = 30 * (Screen.height / 720);
                GUI.Label (SetResolution (new Rect (860, 597, 250, 50)), UFE.config.characters [p2HoverIndex].characterName);
            }
        }
        GUI.skin.label.alignment = TextAnchor.UpperLeft;
        
//        GUI.DrawTexture(SetResolution(new Rect(61, 554, p1Overlay.width, p1Overlay.height)), p1Overlay);
//        GUI.DrawTexture(SetResolution(new Rect(1130, 554, p2Overlay.width, p2Overlay.height)), p2Overlay);
        
        if (GUI.Button(returnButtonRect, "", returnButtonStyle)) UFE.StartIntro(2);

        if (UFE.config.arcadeMode) {
            return;
        }

        p1PlayerSelected = GUI.Toggle (SetResolution (new Rect (420, 170, 177, 116)), p1PlayerSelected, "", p1PlayerStyle);
        if (p1PlayerSelected) {
            p1AISelected = false;
            UFE.SetCPU (1, false);
        }
        if (!p1PlayerSelected && !p1AISelected)
            p1PlayerSelected = true;

        p1AISelected = GUI.Toggle (SetResolution (new Rect (420, 310, 177, 116)), p1AISelected, "", p1AIStyle);
        if (p1AISelected && p1PlayerSelected) {
            p1PlayerSelected = false;
            UFE.SetCPU (1, true);
        }

        p2PlayerSelected = GUI.Toggle (SetResolution (new Rect (691, 170, 177, 116)), p2PlayerSelected, "", p2PlayerStyle);
        if (p2PlayerSelected && p2AISelected) {
            p2AISelected = false;
            UFE.SetCPU (2, false);
        }
        if (!p2PlayerSelected && !p2AISelected)
            p2PlayerSelected = true;

        p2AISelected = GUI.Toggle(SetResolution(new Rect(691, 310, 177, 116)), p2AISelected,  "", p2AIStyle);
        if (p2AISelected && p2PlayerSelected) {
            p2PlayerSelected = false;
            UFE.SetCPU (2, true);
        }
    }

If you did not add the 3D character selection, make sure to remove any of the lines with OnCharacterHighlighted

You now have player 2 automatically selected at random and set to CPU when choosing player 1.

Optional if you want to have ongoing rounds:

In the GUIScript.cs, you will want to find the OnGameEnds function and edit it to be

if (UFE.config.arcadeMode && winner == UFE.GetPlayer1 ()) {
    isRunning = false;
    Destroy (player1NameGO);
    Destroy (player2NameGO);
    Destroy(infoGO);
    Destroy (timerGO);
    UFE.SetPlayer2 (UFE.config.characters [UnityEngine.Random.Range (0, UFE.config.characters.Length)]);
    UFE.StartStageSelect(2);
    Destroy(mainAlertGO);
} else {
    // Fires when game ends
    showEndMenu = true;
    isRunning = false;
    Destroy (player1NameGO);
    Destroy (player2NameGO);
    Destroy(infoGO);
    Destroy (timerGO);
}

You may also want to set a variable for the number of rounds played for a limit and possibly an intermediate screen or alert providing progress.

Share

Thumbs up +3 Thumbs down

Re: Collection of UFE Mods and Improvements

How long till arcade mode tutorial

Share

Thumbs up Thumbs down

Re: Collection of UFE Mods and Improvements

sbrtate22 wrote:

How long till arcade mode tutorial

I've been cleaning up everything so it makes sense. Shouldn't be too long.

Share

Thumbs up Thumbs down

Re: Collection of UFE Mods and Improvements

Ok thanks for this tho

Share

Thumbs up Thumbs down

Re: Collection of UFE Mods and Improvements

global config ? i have source i dont see that script

Share

Thumbs up Thumbs down

Re: Collection of UFE Mods and Improvements

sbrtate22 wrote:

global config ? i have source i dont see that script

It isn't a script, it's the asset for the project's GUI. If you didn't create a new one, it'll be UFE/UFE_Config

Clicking on it will show the "Open U.F.E. Global Config" button in the Inspector window.

Share

Thumbs up Thumbs down

7 (edited by roswell108 2015-03-29 17:53:03)

Re: Collection of UFE Mods and Improvements

Scale the floating background to the runtime screen size:

Attach a C# script to the background GameObject from the original tutorial and in Start() add

float distance = transform.position.z - Camera.main.transform.position.z;
float height = 2.0f * Mathf.Tan(0.5f * Camera.main.fieldOfView * Mathf.Deg2Rad) * distance;
float width = height * Screen.width / Screen.height;
transform.localScale = new Vector3(width / 10, 0.01f, height / 10);

This will stretch the plane to fit the window and account for the distance to the camera.

Also, it seems the original rotation and scale would cause the background to be upside-down.
It has been corrected above, but the new values are: rotation of 90, 180, 0 with a scale of 2.5, 0.01, 1.3

Share

Thumbs up Thumbs down

8 (edited by roswell108 2015-03-29 14:07:34)

Re: Collection of UFE Mods and Improvements

Preventing errors when not using "Enable alternative color":

Open up ControlsScript and search for foreach(Renderer char_rend in charRenderers){ which should contain a commented //if (char_rend.material.HasProperty("color") && char_rend.material.HasProperty("shader")){

Instead of the existing commented line (or in addition to it if you don't want to remove the comment), add

if (char_rend.material.HasProperty ("_Color")) {

and then close it where the commented } is for the original condition or uncomment the } (if you replaced the other line)

I think that's what they intended to do, but it looks like it was using the property reference instead of the property name.

Localizing variables that do not need to be shared:

You may want to go back to the CharacterSelectionScript and change the public identifier on all the variables (not the functions, though) to [SerializeField] private because they are not used in any other functions.

Setting a variable public is an easy way to have it show up in the editor, but isn't necessary if they are local variables.

Share

Thumbs up +2 Thumbs down

9 (edited by roswell108 2015-04-08 11:03:51)

Re: Collection of UFE Mods and Improvements

Adding names to your 3D character selection:
* NEW / UPDATED

Open CharacterSelectionScript and add the variables

private float originalWidth = 1280.0f;
private float originalHeight = 720.0f;
private Vector3 scale;

If you have added the arcade mode update, skip over the next edit to the StageSelectionScript change

Look for the set of p1Overlay and p2Overlay GUI.DrawTexture at the end of the OnGUI.
Comment these lines and below where they were add

        scale.x = Screen.width / originalWidth; 
        scale.y = Screen.height / originalHeight;
        scale.z = 1f;
        Matrix4x4 svMat = GUI.matrix;
        GUI.matrix = Matrix4x4.TRS (Vector3.zero, Quaternion.identity, scale);

        int fontSize = GUI.skin.label.fontSize;
        GUI.skin.label.fontSize = 40;
        GUI.skin.label.alignment = TextAnchor.UpperLeft;
        GUI.Label (new Rect (61, 554, 200, 80), UFE.config.player1Character.characterName);
        GUI.skin.label.alignment = TextAnchor.UpperRight;
        GUI.Label (new Rect (1019, 554, 200, 80), UFE.config.player2Character.characterName);
        GUI.skin.label.alignment = TextAnchor.UpperLeft;
        GUI.skin.label.fontSize = fontSize;
        
        GUI.matrix = svMat;

Now open StageSelectionScript and add the same variables.
Scroll down to the end of the OnGUI, comment the p1/p2Overlay GUI.DrawTexture lines, and below where they were add

        scale.x = Screen.width / originalWidth; 
        scale.y = Screen.height / originalHeight;
        scale.z = 1f;
        Matrix4x4 svMat = GUI.matrix;
        GUI.matrix = Matrix4x4.TRS (Vector3.zero, Quaternion.identity, scale);

        int fontSize = GUI.skin.label.fontSize;
        GUI.skin.label.fontSize = 40;
        GUI.skin.label.alignment = TextAnchor.UpperLeft;
        GUI.Label (new Rect (61, 554, 200, 80), UFE.config.player1Character.characterName);
        GUI.skin.label.alignment = TextAnchor.UpperRight;
        GUI.Label (new Rect (1019, 554, 200, 80), UFE.config.player2Character.characterName);
        GUI.skin.label.alignment = TextAnchor.UpperLeft;
        GUI.skin.label.fontSize = fontSize;
        
        GUI.matrix = svMat;

The difference between the two is only how it references the name, and SetResolution is not necessary when using a matrix because it is scaling the matrix based on a 1280x720 screen instead of scaling the position.

This will set up labels that will display the selected character name.

Using the prefab name was an alternative to save a tiny bit of memory, but I had not realized the big profile pictures had already been calling the name the other way. It was not an "added reference" when it was only replacing the existing one.

Share

Thumbs up Thumbs down

Re: Collection of UFE Mods and Improvements

Why don't you use the Name field in Character Editor?

Share

Thumbs up Thumbs down

Re: Collection of UFE Mods and Improvements

and im still not seeing how i can add the private bool arcademode the the ufe config ????????

Share

Thumbs up Thumbs down

12 (edited by roswell108 2015-03-29 22:48:46)

Re: Collection of UFE Mods and Improvements

YumChaGames wrote:

Why don't you use the Name field in Character Editor?

It's a bit of a waste to go all the way back up, drill down, then return a value when you already have the prefab and naming it really isn't that much work.

It would be different if you wanted to display a whole GUI about the character. In that case, it makes sense.

sbrtate22 wrote:

and im still not seeing how i can add the private bool arcademode the the ufe config ????????

You need to have the source version. It's in GlobalInfo under public class GlobalInfo: ScriptableObject { .. } which allows it to be referenced from UFE.config

Share

Thumbs up Thumbs down

Re: Collection of UFE Mods and Improvements

roswell108 wrote:
YumChaGames wrote:

Why don't you use the Name field in Character Editor?

It's a bit of a waste to go all the way back up, drill down, then return a value when you already have the prefab and naming it really isn't that much work.

It would be different if you wanted to display a whole GUI about the character. In that case, it makes sense.

In the case of a 3D select screen, yes this is true.  But you don't have to do any drilling at all wink

GUI.Label(SetResolution(new Rect(178, 597, 250, 50)), UFE.config.characters[p1HoverIndex].characterName, "namesLeft");

That's in the original CharacterSelectionScript.cs.

To me, renaming a game object feels like an inelegant solution to a non-problem.  In general, I would avoid renaming game objects at runtime unless it's absolutely required.

Share

Thumbs up Thumbs down

14 (edited by roswell108 2015-03-30 10:36:41)

Re: Collection of UFE Mods and Improvements

YumChaGames wrote:

It's a bit of a waste to go all the way back up, drill down, then return a value when you already have the prefab and naming it really isn't that much work.

In the case of a 3D select screen, yes this is true.  But you don't have to do any drilling at all wink

GUI.Label(SetResolution(new Rect(178, 597, 250, 50)), UFE.config.characters[p1HoverIndex].characterName, "namesLeft");

That's in the original CharacterSelectionScript.cs.

To me, renaming a game object feels like an inelegant solution to a non-problem.  In general, I would avoid renaming game objects at runtime unless it's absolutely required.

It's meant as a continuation of the 3D selection. There would be no reason to get the name of the prefab without that.

You are still going back to the selected character array to get the index and then get the name when you already have a prefab with a name property chosen. That seems roundabout when it's only a rename if you didn't do it from the start.

TBH simple and efficient matter more than elegant for hacks. I know it may get cleaned up and used for an update, but leaving some room to change it means the credit is inspired by not written by lol.

Share

Thumbs up Thumbs down

Re: Collection of UFE Mods and Improvements

Could u do more tutorial  how to make it where u do need a mouse on the intro where u can use the controller to select the buttons in intro prefab

Share

Thumbs up Thumbs down

Re: Collection of UFE Mods and Improvements

sbrtate22 wrote:

Could u do more tutorial  how to make it where u do need a mouse on the intro where u can use the controller to select the buttons in intro prefab

That one is fairly easy and something I need to do anyway. I should have that up later tonight.

Share

Thumbs up +1 Thumbs down

Re: Collection of UFE Mods and Improvements

roswell108 wrote:
sbrtate22 wrote:

Could u do more tutorial  how to make it where u do need a mouse on the intro where u can use the controller to select the buttons in intro prefab

That one is fairly easy and something I need to do anyway. I should have that up later tonight.

Thank you

Share

Thumbs up Thumbs down

18 (edited by roswell108 2015-04-16 23:00:13)

Re: Collection of UFE Mods and Improvements

xIntro screen gamepad selection (OnGUI method):
* NEW / UPDATED

Open up IntroScript and add the variables

   private int selectedIndex = -1;
   private string[] menuOptions = new string[7] { "Story", "Start", "Arcade", "Host", "Join", "Options", "Credits" };
   [SerializeField] private Texture2D[] menuIcon = new Texture2D[6];
   private string hoverBtn;
   private bool buttonAvailable = true;

Below the variables and before Start() add

        private int menuSelection (string[] menuItems, int selectedItem, float direction) {
        if (direction <= -0.1f) {
            if (selectedItem <= 0) {
                selectedItem = menuItems.Length - 1;
            } else {
                selectedItem -= 1;
                if (selectedItem == 2 && !UFE.isNetworkAddonInstalled) {
                    selectedItem -= 1;
                } else if (selectedItem == 3 && !UFE.isNetworkAddonInstalled) {
                    selectedItem -= 2;
                    // If there is no hosting, there is no joining
                }
            }
        }
        if (direction >= 0.1f) {
            if (selectedItem >= menuItems.Length - 1) {
                selectedItem = 0;
            } else {
                selectedItem += 1;
                if (selectedItem == 3 && !UFE.isNetworkAddonInstalled) {
                    selectedItem += 1;
                } else if (selectedItem == 2 && !UFE.isNetworkAddonInstalled) {
                    selectedItem += 2;
                    // Inverse of the above network option skip
                }
            }
        }
        return selectedItem;
    }
    
    private void handleSelection()
    {
        switch (selectedIndex)
        {
        case 0:  
            UFE.PlaySound(selectSound);
            UFE.config.arcadeMode = false;
            UFE.DelayAction(this.StartCharacterSelect, 0.5f);
            startingCharacterSelect = true;
            break;
        case 1:
            UFE.PlaySound(selectSound);
            UFE.config.arcadeMode = true;
            UFE.DelayAction(this.StartCharacterSelect, 0.5f);
            startingCharacterSelect = true;
            break;
        case 2:
            UFE.PlaySound(selectSound);
            UFE.HostGame();
            hostGameIsOpen = true;
            break;
        case 3:
            UFE.PlaySound(selectSound);
            serverIp = string.Empty;
            joinGameIsOpen = true;
            if (UFE.config.lobbyMusic != null) Camera.main.GetComponent<AudioSource>().clip = UFE.config.lobbyMusic;
            if (UFE.config.music && !Camera.main.GetComponent<AudioSource>().isPlaying) Camera.main.GetComponent<AudioSource>().Play();
            break;
        case 4:
            UFE.PlaySound(selectSound);
            optionsIsOpen = true;
            break;
        case 5:
            UFE.PlaySound(selectSound);
            UFE.StartCreditsScreen(2);
            break;
        default:
            break;
        }
    }

    void FixedUpdate() {
        if (!startingCharacterSelect) {
            float v = Input.GetAxis ("Vertical");
            if (Input.GetKeyDown (KeyCode.W) || Input.GetKeyDown (KeyCode.UpArrow)) {
                v = 1.0f;
            }
            if (Input.GetKeyDown (KeyCode.S) || Input.GetKeyDown (KeyCode.DownArrow)) {
                v = -1.0f;
            }
            if (Math.Abs (v) > 0.5f && buttonAvailable) {
                buttonAvailable = false;
        selectedIndex = menuSelection (menuOptions, selectedIndex, v);
        StartCoroutine (ButtonTimeout ());
            }
            AbstractInputController p1InputController = UFE.GetPlayer1Controller();
            if ((p1InputController.GetButtonDown(UFE.config.inputOptions.confirmButton)
                 || Input.GetButtonDown ("Submit"))) {
                handleSelection ();
            }
        }
    }
    IEnumerator ButtonTimeout ()
    {
        yield return new WaitForSeconds (0.5f);
        buttonAvailable = true;
    }

Now scroll down to the OnGUI section and add

GUI.SetNextControlName ("Arcade");

before the if (GUI.Button... for arcadeMode

Repeat the same process for all of the buttons, changing the name to match the button
Start, Host, Join, Options, Credits

At the very botton of OnGUI (or just above the GUI.matrix = svMat; if you added the tablet popup mod) add

if (selectedIndex >= 0) {
    GUI.FocusControl (menuOptions[selectedIndex]);
}

This will scroll the menu and support selection in the same way the other screens already allow.

It should be noted that the proper way to do this would be using a Canvas and the new Unity 4.6 GUI input methods.

This is a workaround based on http://forum.unity3d.com/threads/gui-co … ard.77436/ to keep OnGUI


Full screen stage preview background:

You will need to be using the persistentScreen mod from above for this to work.
Open StageSelectionScript and just after the first GUI.DrawTexture in OnGUI add

if (UFE.config.persistentScreen != null && !startingGame) {
    UFE.config.persistentScreen.renderer.material.mainTexture = UFE.config.stages [hoverIndex].screenshot;
}

Now you will want to open GlobalInfo.cs and add a variable directly under the persistentScreen

public Texture persistentTexture

Then open up GlobalEditorWindow.cs and right below the persistentScreen item add

globalInfo.persistentTexture = (Texture) EditorGUILayout.ObjectField("Persistent Menu Texture:", globalInfo.persistentTexture, typeof(UnityEngine.Texture), true);

After both of these are added, Open the UFE.cs and find private static void _StartCharacterSelect(float fadeTime){
You should have an if block inside that function from the persistentScreen mod that starts with if (config.persistentScreen != null) {
Right below the if and before the Instantiate command add

if (UFE.config.persistentTexture != null) {
    UFE.config.persistentScreen.renderer.material.mainTexture = UFE.config.persistentTexture;
}

It is important to do this before the object is created for character selection or the background will be pink after the first run because it will still be set to the last stage material that is now blank.

Finally open the Global Configuration Window and expand Screen Options
Drag the background texture you set up for the persistentScreen into the box for Persistent Menu Texture

This will make the stage selection background a larger copy of the icon, so you may want to add higher resolution preview images. The icon will scale the image, so something in between full screen and icon size will scale to both without a lot of lost quality.

It will also restore the original background when you return to the character selection screen.

https://www.dropbox.com/s/b3iq67gtadnpo2q/Screen%20Shot%202015-03-30%20at%204.47.05%20PM.png?dl=1

Share

Thumbs up Thumbs down

Re: Collection of UFE Mods and Improvements

Sorry about the edits. I didn't notice it was losing the material until I went back to run it again after testing for the post.

BTW if there are any other UI type things anyone is trying to do I can always try to help with that. I am posting the stuff I find as I come across it but UI stuff is my specialty. YumChaGames will have to step in for the non-UI stuff haha.

Share

Thumbs up Thumbs down

Re: Collection of UFE Mods and Improvements

One issue with arcade mode ifi want to set the original start to a vs mode how can I do thT

Share

Thumbs up Thumbs down

Re: Collection of UFE Mods and Improvements

sbrtate22 wrote:

One issue with arcade mode ifi want to set the original start to a vs mode how can I do thT

What do you mean? It should be a second option. You don't replace the original.

Share

Thumbs up Thumbs down

Re: Collection of UFE Mods and Improvements

when  start the actual start n select my characters the game doesnt start an no error actual show in console

Share

Thumbs up Thumbs down

23 (edited by roswell108 2015-04-06 19:17:58)

Re: Collection of UFE Mods and Improvements

For the persistentScreen tutorial above, the code needs a slight change for Unity 5.

For the line in UFE.cs change the line

UFE.config.persistentScreen.renderer.material.mainTexture = UFE.config.persistentTexture;

to

#if UNITY_5_0
                UFE.config.persistentScreen.GetComponent<Renderer>().sharedMaterial.mainTexture = UFE.config.persistentTexture;
#else
                UFE.config.persistentScreen.renderer.material.mainTexture = UFE.config.persistentTexture;
#endif

And for the line in StageSelectionScript.cs change the line

UFE.config.persistentScreen.renderer.material.mainTexture = UFE.config.stages [hoverIndex].screenshot;

to

#if UNITY_5_0
            UFE.config.persistentScreen.GetComponent<Renderer>().sharedMaterial.mainTexture = UFE.config.stages [hoverIndex].screenshot;
#else
            UFE.config.persistentScreen.renderer.material.mainTexture = UFE.config.stages [hoverIndex].screenshot;
#endif

This will make both compatible with Unity 5 but backwards compatible with Unity 4.

Share

Thumbs up Thumbs down

Re: Collection of UFE Mods and Improvements

sbrtate22 wrote:

when  start the actual start n select my characters the game doesnt start an no error actual show in console

If you copied the guide above, you should have two buttons. One will select the second character for you and one won't.

If you choose "Start" (or "Versus" if you changed it) then you will be able to pick both characters then a stage.

Share

Thumbs up Thumbs down

Re: Collection of UFE Mods and Improvements

I understand but when I select the one that's not arcade mode the game won't stArtvan when I select player 2 it's chances player 1 to the same charActer an it's doesn't goes to the stage selection I might be implenting so code wrong I will make a video to show wat I mean

Share

Thumbs up Thumbs down