예제 #1
0
        /**
         * Initialization
         */
        static PlayMakerExtension()
        {
            // Don't sync PlayMakerGUI because PlayMaker can create it automatically.
            SceneFusionAPI.DontSyncObjectsWith <PlayMakerGUI>();

            // Register property change handlers
            SceneFusionAPI.RegisterPropertyChangeHandler <PlayMakerFSM>(OnPropertyChange);

            // Register on connect/disconnect handler
            SceneFusionAPI.OnConnect    += OnConnect;
            SceneFusionAPI.OnDisconnect += OnDisconnect;

            // Register on spawn request handler
            SceneFusionAPI.OnSpawn += OnSpawn;

            // Register on lock/unlock handler
            SceneFusionAPI.OnLock   += OnLock;
            SceneFusionAPI.OnUnlock += OnUnlock;

            // Register on add/remove component handler
            SceneFusionAPI.OnAddComponent    += OnAddComponent;
            SceneFusionAPI.OnRemoveComponent += OnRemoveComponent;

            // Sync hidden property fsm on PlayMakerFSM
            SceneFusionAPI.SyncHiddenProperties <PlayMakerFSM>("fsm");

            EditorApplication.update += Update;
        }
예제 #2
0
        /**
         * Called every frame.
         */
        private static void Update()
        {
            m_rebuiltPaths.Clear();

            // Move online status indicator down/up when Ferr2D overlay shows/hides.
            if (SceneFusionAPI.IsLoggedIn)
            {
                Vector2 offset = SceneFusionAPI.GetOnlineStatusOffset();
                // OnChanged is set while the Ferr2D overlay is showing
                if (Ferr2D_PathEditor.OnChanged != null)
                {
                    if (offset.y < FERR2D_OVERLAY_HEIGHT)
                    {
                        m_onlineStatusDeltaY = FERR2D_OVERLAY_HEIGHT - offset.y;
                        offset.y             = FERR2D_OVERLAY_HEIGHT;
                        // Change online status offset but do not save the new offset.
                        SceneFusionAPI.SetOnlineStatusOffset(offset, false);
                    }
                }
                else if (m_onlineStatusDeltaY != 0f)
                {
                    offset.y            -= m_onlineStatusDeltaY;
                    m_onlineStatusDeltaY = 0f;
                    // Change online status offset but do not save the new offset.
                    SceneFusionAPI.SetOnlineStatusOffset(offset, false);
                }
            }
            else
            {
                m_onlineStatusDeltaY = 0f;
            }
        }
예제 #3
0
 /**
  * Initialization
  */
 static Ferr2DExtension()
 {
     // Set SF_FERR2D define to compile Ferr2D-dependant code if Ferr2D is detected.
     if (DetectFerr2D())
     {
         SceneFusionAPI.SetDefineSymbol("SF_FERR2D");
     }
 }
예제 #4
0
 /**
  * Initialization
  */
 static PlayMakerExtension()
 {
     // Set SF_PLAYMAKER define to compile PlayMaker-dependant code if PlayMaker is detected.
     if (DetectPlayMaker())
     {
         SceneFusionAPI.SetDefineSymbol("SF_PLAYMAKER");
     }
 }
예제 #5
0
 /**
  * Initialization
  */
 static ProBuilderExtension()
 {
     // Set SF_ProBuilder define to compile ProBuilder-dependant code if ProBuilder is detected.
     if (DetectProBuilder())
     {
         SceneFusionAPI.SetDefineSymbol("SF_PROBUILDER");
     }
 }
예제 #6
0
 /**
  * Called when probuilder changes geometry or the probuilder selection changes. Invalidates in-progress change
  * checks on the modified objects to ensure updates are atomic.
  *
  * @param   pb_Object[] objects that changed.
  */
 private static void OnGeometryChange(pb_Object[] objects)
 {
     if (objects != null) // sometimes this is null, not sure why...
     {
         foreach (pb_Object obj in objects)
         {
             SceneFusionAPI.InvalidateChangeCheck(obj);
         }
     }
 }
예제 #7
0
        /**
         * Called before sending a spawn request for a game object to the server.
         *
         * @param   GameObject gameObject a spawn request will be sent for.
         */
        private static void BeforeSpawnRequest(GameObject gameObject)
        {
            pb_Object obj = gameObject.GetComponent <pb_Object>();

            if (obj != null)
            {
                MeshFilter filter = gameObject.GetComponent <MeshFilter>();
                if (filter != null && filter.sharedMesh != null)
                {
                    // The game object has a mesh whose data is controlled by ProBuilder. Tell Scene Fusion not to
                    // upload the mesh data since Probuilder will be generating it.
                    SceneFusionAPI.DontUploadSceneAsset(filter.sharedMesh);
                }
            }
        }
예제 #8
0
        /**
         * Initialization
         */
        static ProBuilderExtension()
        {
            // Register property change handler
            SceneFusionAPI.RegisterPropertyChangeHandler <pb_Object>(OnPropertyChange);

            // Register before spawn request handler
            SceneFusionAPI.BeforeFirstSync += BeforeSpawnRequest;

            // Register on selection update handler. This is also invoked when geometry changes which is what we want
            // it for.
            pb_Editor.OnSelectionUpdate += OnGeometryChange;

            // Register on mesh compile handler.
            pb_EditorUtility.AddOnMeshCompiledListener(OnMeshCompiled);

            EditorApplication.update += Update;
        }
예제 #9
0
        /**
         * Initialization
         */
        static Ferr2DExtension()
        {
            // Ferr2D does not respect NotEditable hide flags so we have to explicitly prevent edits to Ferr2D
            // components on locked objects.
            SceneFusionAPI.PreventEditsWhileLocked <Ferr2D_Path>();
            SceneFusionAPI.PreventEditsWhileLocked <Ferr2DT_PathTerrain>();

            // Register property change handlers
            SceneFusionAPI.RegisterPropertyChangeHandler <Ferr2D_Path>(OnPropertyChange);
            SceneFusionAPI.RegisterPropertyChangeHandler <Ferr2DT_PathTerrain>(OnPropertyChange);
            SceneFusionAPI.RegisterPropertyChangeHandler <sfFerr2DAdaptor>(OnPropertyChange);

            // Register before spawn request handler
            SceneFusionAPI.BeforeFirstSync += BeforeFirstSync;

            // Register new Ferr2D mesh callback
            sfFerr2DAdaptor.NewFerr2DMeshCallback = OnNewFerr2DMesh;

            // Sync hidden property m_SortingOrder on MeshRenderers
            SceneFusionAPI.SyncHiddenProperties <MeshRenderer>("m_SortingOrder");

            EditorApplication.update += Update;
        }
예제 #10
0
        /**
         * Called before syncing a game object for the first time. Adds our adaptor component to Ferr2D objects to sync
         * some additional data.
         *
         * @param   GameObject gameObject a spawn request will be sent for.
         */
        private static void BeforeFirstSync(GameObject gameObject)
        {
            Ferr2D_Path path = gameObject.GetComponent <Ferr2D_Path>();

            if (path != null)
            {
                // This is a Ferr2D object. Add our adaptor component if there isn't one already.
                sfFerr2DAdaptor adaptor = gameObject.GetComponent <sfFerr2DAdaptor>();
                if (adaptor == null)
                {
                    adaptor = gameObject.AddComponent <sfFerr2DAdaptor>();
                }
                if (adaptor.HasControlledMesh)
                {
                    MeshFilter filter = gameObject.GetComponent <MeshFilter>();
                    if (filter != null && filter.sharedMesh != null)
                    {
                        // The game object has a mesh whose data is controlled by Ferr2D. Tell Scene Fusion not to
                        // upload the mesh data since Ferr2D will be generating it.
                        SceneFusionAPI.DontUploadSceneAsset(filter.sharedMesh);
                    }
                }
            }
        }
예제 #11
0
 /**
  * Called when we detect a new Ferr2D mesh.
  *
  * @param   Mesh mesh generated by Ferr2D.
  */
 private static void OnNewFerr2DMesh(Mesh mesh)
 {
     // Tell Scene Fusion not to upload this mesh since it will be generated by Ferr2D.
     SceneFusionAPI.DontUploadSceneAsset(mesh);
 }
예제 #12
0
 private static void RecursiveUnlock()
 {
     SceneFusionAPI.RecursiveUnlock(Selection.gameObjects);
 }
예제 #13
0
 private static void Unlock()
 {
     SceneFusionAPI.Unlock(Selection.gameObjects);
 }
예제 #14
0
 /**
  * Called when probuilder builds a mesh. Invalidates in-progress change checks on the modified object to ensure
  * updates are atomic.
  *
  * @param   pb_Object obj whose mesh was built.
  * @param   Mesh mesh that was built.
  */
 private static void OnMeshCompiled(pb_Object obj, Mesh mesh)
 {
     SceneFusionAPI.InvalidateChangeCheck(obj);
 }