Coder Social home page Coder Social logo

moqi / unity3d-profile Goto Github PK

View Code? Open in Web Editor NEW

This project forked from yanivnizan/unity3d-profile

0.0 2.0 0.0 79.05 MB

Unity3D F2P game social engagement library. Part of The SOOMLA Framework - for virtual economies and mobile game design.

Home Page: http://soom.la

License: Apache License 2.0

unity3d-profile's Introduction

This project is a part of The SOOMLA Framework, which is a series of open source initiatives with a joint goal to help mobile game developers do more together. SOOMLA encourages better game design, economy modeling, social engagement, and faster development.

Haven't you ever wanted a status sharing one liner that looks like this ?!

SoomlaProfile.UpdateStatus(Provider.FACEBOOK, "I love this game !", new VirtualItemReward( ... ));

unity3d-profile

SOOMLA's Profile Module for Unity3d

unity3d-profile is the Unity3d flavor of SOOMLA's Profile Module.

SOOMLA's Profile Module

Download

####Pre baked unitypackage: unity3d-profile v1.0

Debugging

If you want to see full debug messages from android-store and ios-store you just need to check the box that says "Debug Messages" in the SOOMLA Settings. Unity debug messages will only be printed out if you build the project with Development Build checked.

Cloning

There are some necessary files in submodules linked with symbolic links. If you're cloning the project make sure you clone it with the --recursive flag.

$ git clone --recursive [email protected]:soomla/unity3d-profile.git

Getting Started

  1. Go over the guidelines for downloading and importing the official Facebook SDK: https://developers.facebook.com/docs/unity/getting-started/canvas - You don't need to initialize FB. SoomlaProfile will initialize it for you.

    NOTE: unity3d-profile currently supports FB Unity SDK v5.1. Make sure to use that one, support for v6.0 is in the works.

  2. Create an empty folder named Facebook under Assets/Plugins

  3. Move the folder Scripts from Assets/Facebook to Assets/Plugins/Facebook - SOOMLA works from the Plugins folder so it'll be available to UnityScript devs. So you'll have to move Facebook in there as well.

    When working under Unity version > 4.5.0 (targeting iOS) please follow these extra steps:

    1. Edit the file Assets/Facebook/Editor/iOS/fixup.projmods
    1. Under headerpaths change Facebook/Scripts to Plugins/Facebook/Scripts
  4. Download and import soomla-unity3d-core.unitypackage and unity3d-profile.unitypackage. If you also want to use Store related rewards you'll need to go over the instructions of unity3d-store

  5. Drag the "CoreEvents" and "ProfileEvents" Prefabs from ../Assets/Soomla/Prefabs into your scene. You should see it listed in the "Hierarchy" panel. [This step MUST be done for unity3d-profile to work properly!]

  6. On the menu bar click "Window -> Soomla -> Edit Settings" and change the value for "Soomla Secret".

    • Soomla Secret - is an encryption secret you provide that will be used to secure your data. (If you used versions before v1.5.2 this secret MUST be the same as Custom Secret)
      Choose the secret wisely. You can't change them after you launch your game!
    • Social Platforms - select the social platform which you want to integrate with
  7. Initialize SoomlaProfile:

    SoomlaProfile.Initialize();

    Initialize SoomlaProfile ONLY ONCE when your application loads.

    Initialize SoomlaProfile in the "Start()" function of a 'MonoBehaviour' and NOT in the "Awake()" function. SOOMLA has its own 'MonoBehaviour' and it needs to be "Awakened" before you initialize.

    SoomlaProfile will initialize the social providers. Don't initialize them on your own (for example, don't call FB.Init() !).

  8. Call all the social functions you can from SoomlaProfile class. Otherwise, you won't be able to work with SOOMLA correctly. You can still call functions from the FB class but only those that are not provided by SoomlaProfile.

  9. You'll need event handlers in order to be notified about in-app purchasing related events. refer to the Event Handling section for more information.

And that's it ! You have social capabilities for your game.

What's next? Social Actions.

The Profile module is young and only a few social actions are provided. We're always working on extending the social capabilities and hope the community will "jump" on the chance to create them and even connect them with SOOMLA's modules (Store and LevelUp).

Here is an example of sharing a story on the user's feed:

After you initialized SoomlaProfile and logged the user in:

  SoomlaProfile.UpdateStory(
                  Provider.FACEBOOK,
                  "Check out this great story by SOOMLA !",  
                  "SOOMLA is 2 years young!",
                  "soomla_2_years",
                  "http://blog.soom.la/2014/08/congratulations-soomla-is-2-years-young.html",
                  "http://blog.soom.la/wp-content/uploads/2014/07/Birthday-bot-300x300.png",
                  new BadgeReward("sherriff", "Sheriff"));

And that's it! unity3d-profile knows how to contact Facebook and share a story with the information you provided.
It will also give the user the BadgeReward we configured in the function call.

Storage

unity3d-profile is caching user information on the device. You can access it through:

UserProfile userProfile = SoomlaProfile.GetStoredUserProfile(Provider.FACEBOOK);

The on-device storage is encrypted and kept in a SQLite database. SOOMLA is preparing a cloud-based storage service that will allow this SQLite to be synced to a cloud-based repository that you'll define.

Event Handling

SOOMLA lets you subscribe to profile events, get notified and implement your own application specific behavior to those events.

Your behavior is an addition to the default behavior implemented by SOOMLA. You don't replace SOOMLA's behavior.

The 'ProfileEvents' class is where all event go through. To handle various events, just add your specific behavior to the delegates in the Events class.

For example, if you want to 'listen' to a MarketPurchase event:

StoreEvents.OnMarketPurchase += onMarketPurchase;

ProfileEvents.OnLoginFinished += (UserProfile UserProfile) => {
			Soomla.SoomlaUtils.LogDebug("My Perfect Game", "login finished with profile: " + UserProfile.toJSONObject().print());
			SoomlaProfile.GetContacts(Provider.FACEBOOK);
};

Facebook Caveats

  1. See iOS Facebook Caveats
  2. See Android Facebook Caveats

Contribution

SOOMLA appreciates code contributions! You are more than welcome to extend the capabilities of SOOMLA.

Fork -> Clone -> Implement -> Add documentation -> Test -> Pull-Request.

IMPORTANT: If you would like to contribute, please follow our Documentation Guidelines. Clear, consistent comments will make our code easy to understand.

SOOMLA, Elsewhere ...

License

Apache License. Copyright (c) 2012-2014 SOOMLA. http://www.soom.la

unity3d-profile's People

Contributors

dimanem avatar gurdotan avatar hadarhod87 avatar lassic avatar refaelos avatar sluzky avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.