Some popular, commercially available HTML5 video players are essentially big chunks of JavaScript. JWPlayer is one. I use a different one but it's similar in set up.
These players embed in a way that seems out of step with client-side MVC frameworks in general. The players want to render themselves to the DOM. You instantiate a player object and pass a DOM element to it's constructor. Like...
mediaPlayer = new CommercialVideoPlayer("some-place-in-DOM");
The player then renders itself to "some-place-in-DOM".
Doesn't that conflict with view rendering in marionette - with the region manager showing views?
In other words this "player rendering itself" thing seems, on my first look, to conflict with the notion that marionette wants to render. It wants its region manager to map views to DOM elements. It doesn't want some player sticking things in the DOM.
It wants to do...
someRegion.show(someView);
I'm not wrapping my brain around where my HTML5 video player goes in there? Inside a view?
When I put it inside a view and then attempt to show it, like...
videoRegion.show(videoView);//media player is inside videoView
...I get nothing because marionette's region manager and the player are fighting over who gets to render where.
I think I just lack a conceptual understanding of what marionette js would want me to do with this media player. I'm looking for an understanding and a best practice.
Marionette region managers want to display Marionette views. Period. They don't care about what those views do.
In other words, you can have your view create DOM element, then show the video player, something like:
var VideoView = Marionette.ItemView.extend({
template: _.template('<div id="video-player"></div>'),
onShow: function(){
this.mediaPlayer = new CommercialVideoPlayer("some-place-in-DOM");
}
});
var myVideoView = new VideoView();
videoRegion.show(myVideoView);
The above is untested pseudo code, but should get you going in the right direction.
Related
I am entirely new to Unity. I have a task to work with a tool in Unity. I'm not sure the "Game" is where I should work or the "Scene"? this is how my "Game" tab looks like, but I saw animations in the "Scene" tab. for changing parameters of animation, I should come back to the "Game" tab to change and again go to the "Scene" tab to see the result. I think something is wrong, and I should see the animation in the "Game" tab. Am I right?
It was confusing for me to explain my problem cause I have no idea!
It's very confusing what is happening in your Unity scene.
I assume either you have a disabled camera object or no camera at all.
Search the hierarchy for a MainCamera object and enable it. The game view is rendered from cameras in the application. If you cannot find a camera gameobject, try adding a camera (Gameobject>Camera). If you could find a camera gameobject, you should also check it's Camera component has target display set to Display 1.
In the Scene View at the top left, you can click 2D View. Then you can select the canvas in the hierarchy and press "F", while your mouse is over the scene view, to focus it there. In the end, you should be able to see the canvas in the scene view just as you can in the game view.
In fact, you don't need a camera in the scene to render UI elements, which is quite confusing. So if you don't need to solve the "no camera rendering" problem, as long as there are no 3D objects you want to draw. Keep in mind that you will probably need to manually place an audio listener if you want to hear something at some point.
In your hierarchy window search box write this :
t:Camera
And see if any will show up. The camera needs to be enabled if there is one present. If there is none, then you need to create one from GameObjects -> Camera.
As above answers indicate, there is a missing Camera object. Please keep in mind also that a disabled parent object will affect child objects. This was my case, my Camera object was a child object for a XR Ring object which was disabled and I was getting the "No Cameras rendering" message.
I am new to unity and working on a projects.
I want to work with multiple scenes.
some of my scenes are like option menu in the game.
from my main screen I want to open an options scene and when I am done I want to move back to my main scene and when I am back I want to keep the things done in main scene before the options scene opens
I can change scenes with SceneManager but it loads the screen as new as if I did nothing there
is it possible to switch between loaded scenes without loading again? I think that if it is; I can continue from the progress in the main scene
if it is not how can I continue my progress (do I have to keep all the data and when the scene starts load back from that data? )
The SceneManager class provides lots of useful ways to manage your scenes. You can find documentation here.
Using multiple scenes to separate your logic is a great approach, and using the LoadSceneMode.Additive option when loading a new scene lets you load one scene alongside another.
To achieve what you want, you'd roughly need to do the following:
Load your main menu scene.
Load your options scene additively with a call like SceneManager.LoadScene("path/to/options/scene.unity", LoadSceneMode.additive).
Pass input control to your other scene.
Unload the options scene when you are finished with it.
The main menu scene will have been loaded for the entire time, and you won't have to "remember" any values or use DontDestroyOnLoad.
An alternative option is to house all of your menu functionality in a single scene, and switch between multiple canvases. You can find information about that here.
you can create a class with values that you want to keep and put it on a gameobject
and use DontDestroyOnLoad(this.gameObject); so the object won't be removed when you load a new scene
I just have a question and I don't know exactly what to type on google.
I am making a game which is always instantiating scenes now on my login process I am trying to login wrong account so there should be something that needs to pop up like an error message
Now my question is . Is there going to be a problem when I build this up because there's a tons of them or it is just normal?
But basically when i try to input the correct id and password this scenes will be deleted.
There shouldn't be a problem but this looks like an abuse of scene to me. You have too many unnecessary scenes.
Here is when you need to create or use a new scene:
1.Main Menu
This is the first scene that loads. By separating it with your game scene, you will increase loading time.
2.Game Levels
The levels in your game requires scene for each one. This makes loading them faster. You can also separate one scene into multiple ones if it's really a big scene. This also increases the speed of loading time.
You do not need scene for other things you have in your question. Those should be a UI Panels. You can create a panel by going to the GameObject ---> UI --> Panel menu. It's really easy to show/hide a panel.
For example, you have login and emergency panels:
public GameObject loginPanel;
public GameObject emergencyPanel;
to show the login panel, you disable or deactivate the emergency panel first then activate the login panel:
emergencyPanel.SetActive(false);
loginPanel.SetActive(true);
That's all you have to do.
So, in FPS games there is a thing where you can only see your hands, not body, but other players do see your model and animations. Is there a way to do this in Unity?
Thanks for help in advance
That's usually done by just sorting out what's being rendered client side and what's being rendered server-side.
E.g The client-side view will render only the hands overlay and other player models. Depending on how you do your multiplayer, it'll just be a case of just disabling the renderer of the player model and enabling it for other players.
To give a little background about the game: falling items float from the top, and the objective is to flick/slide another object to hit them. If an item hits the ground, you lose a life, and gain points for hitting falling items.
Here is where I'm a little confused. In O'Reilly's iPhone game development. They state have the AppDelegate inherit a game state machine object, and have the main game loop in the App Delegate. Nothing about MVC.
I was going to use MVC. I have all the objects identified for the models, and was going to use one controller to update each model and their corresponding view. Then have a navigation controller in the App Delegate, and push certain controllers (Play, instructions, stats) from the home screen. Then have the game loop run in my gameViewController. I am using Chipmunk as a physics engine by the way.
This is my first game so I'm little confused. I would greatly appreciate any advice on how to proceed. I would like to get the object orientated design right from the start before jumping into code.
I don't think MVC is really what you want here. MVC could apply to your overall application state - ie a view for the menu, a view for the gameboard etc. It doesn't fit well WITHIN the game play - at least just thinking off the top of my head.
Take a look at this post on gameDev. Lots of useful patterns from people smarter about this than I.
https://gamedev.stackexchange.com/questions/4157/what-are-some-programming-design-patterns-that-are-useful-in-game-development
My MVC goes something as follows. Each Game Object that is create is just a single Model. Empty data with no logic attached. When the object is created it also gets a Brain or controller attached to it. Each created Brain is added to the Brain list. The Brain List updates each brain and the brains change the Model.
To show something on screen the Brain adds the Model to the Scene. The scene keeps a list of all the models it is rendering. The Scene is also Updated from the Game Loop. Each update the Scene looks at each Model, any model without a View, is given a view (a new view is created based on data in the model). The Scene then tracks the view until the Model's data says it no longer needs it.
When I have been working on the iPhone I like to break the game loop out onto its own thread. Those folks over at O'Reilly are pretty smart though so take what I've got to say with a grain of salt.
[NSThread detachNewThreadSelector:#selector(GameLoop:) toTarget:self withObject:nil];
Then the game loop itself is updating first the Brains (or "Controller List"), then the Scene (or "view list").
The final piece that ties it all together is the input. For iPhone I use a full screen View. In the touchesBegan and touchesEnd of the view I generate Events which I pass off to the InputManager. The InputManager will send events to different models as needed.
Do you not consider that game state machine to be a kind of data model? I don't have the O'Reilly book you mention, but the description you give sounds to me very much like MVC.
The main point of MVC is to separate an application's content from the way that content is represented on the screen. The "model" in MVC doesn't have to consist of dumb data objects that you read from a file or a web server... it could just as easily be a simulation, a connection to another device, etc. The way I think of it is that the model is the part that you'd keep if you were going to throw out app's GUI and replace it with a script, a command line interface, or maybe a web service. A game state machine could certainly fit that description.
It's not uncommon in an iOS app to have the application delegate instantiate the model. You then have view controllers that know how to talk to the model and translate the data that it provides into something that can be displayed in the view(s). If some of the data that the model provides are graphic elements like textures or meshes, that's okay... those are the data that the game operates on, after all.