Search Unity

PureMVC C# in Unity 3D

Discussion in 'Scripting' started by vejko, Dec 22, 2009.

  1. vejko

    vejko

    Joined:
    Dec 22, 2009
    Posts:
    3
    Hi Guys,

    Has anyone tried the C# version of PureMVC in Unity 3D?

    Cheers,
    Vejko
     
  2. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    I haven't tried it but a good question to ask is why would you try and use it with Unity? The two don't seem to be a very good fit and trying to use PureMVC with Unity would probably require more hacking/workarounds that it's worth.
     
  3. vejko

    vejko

    Joined:
    Dec 22, 2009
    Posts:
    3
    I am coming from Flex/Flash background and I am using puremvc in all my projects.

    If you have more developers on the same project and everybody knows puremvc rules it is very easy to understand each other's code and logic.

    It makes your code simpler and cleaner and more efficient.

    If Unity uses standard c# then probably it could work, but I will spend some time finding out whether these two great stuff can work together.
     
  4. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    I've used PureMVC for Flex as well and it works well for an application, no doubt about it. The problems with trying to use something like PureMVC in Unity is one of the design of Unity vs Flex/Flash. Unity doesn't lend itself well for working with external MVC frameworks, at least from my limited working with it. If you get things working and have a good workflow with it I would love to hear about it.
     
  5. Mani

    Mani

    Joined:
    Jan 12, 2009
    Posts:
    117
    I was trying to visualize how you would implement that. I haven't looked at the c# version of PureMVC yet but was planning to look at it for the same purpose. I could see how that could be useful for having multiple aspects of the game respond to model changes. D@mn! that's what I'll be thinking about in traffic tonight- thnx.
     
  6. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    Unity is heavily built around the observer and decorator pattern ...

    It won't be easy to get MVC into such a flow especially as you won't be able to seperate anything cleanly (its all monobehavior, splitting 1 into 3 just to please the MVC insanity would result in far less clean code and additionally be less performant as you get three times as many oberservers)
     
  7. superme2012

    superme2012

    Joined:
    Nov 5, 2012
    Posts:
    207
    Interesting, I'm about to look into "observer and decorator" all new to me. I was thinking HMVC for code structure but its just an idea at the moment. I'm in from a pure prototype approach, nasty looking code that needs an arch.
     
  8. SpiderJones

    SpiderJones

    Joined:
    Mar 29, 2014
    Posts:
    245
    When I use PureMVC in Flash projects I have the View Mediators encapsulate View Components that encapsulate View Objects. View logic lives in the View Components, the View Mediators serve as adaptors to the PureMVC framework. And view framework specific code/technology lives in the View Object. In Flash you have two view technologies, the Display List and Stage3D(Starling). By encapsulating the View Objects and isolating view specific technology in the View Object, I can easily switch between the two technologies (Display List and Stage3D). I would apply the same approach when using Unity. Here is my RootView framework for PureMVC (this is in ActionScript, but you could port it) - http://www.dorkbots.com/repositories/root-view/index.html