Unity iphone et Facebook

Le site Myth & Fact a mis en ligne une série de scripts permettant à un jeu Iphone, créé sous Unity, de se connecter à Facebook. La technique est assez compliquée à monter car elle recèle des étapes intégrant des scripts passerelles.
Bref, un bon tutoriel qui est quand même complet pour ceux qui aiment mettre les mains dans le cambouis.

Sortie de iTween pour Unity

Les tweens, que l’on trouve surtout dans Flash, sont une méthode permettant de déplacer, grossir, tourner facilement des objets dans un certains délais. J’avais déjà parlé de la classe Ani.mate que l’on trouve sur le Wiki mais qui est codée en Boo, donc inutilisable sur Unity Iphone.
Voici donc le projet iTween entièrement codé en Javascript et en C# et dérivé de Tweener de Flash apportant les méthodes suivantes :

iTween.punchPosition(GameObject, Hashtable)

* Valid arguments: x:float, y:float, z:float, time:float, delay:float, onComplete:string, onCompleteParams:object
* Default arguments: time:1, delay:0
* Applies a jolt of force on the given axis and springs the GameObject back to its original position like a punching bag.
* Negative/positive values dictate the direction of the initial impact.
* Does not utilize a transition.

iTween.punchRotation(GameObject, Hashtable)

* Valid arguments: x:float, y:float, z:float, time:float, delay:float, onComplete:string, onCompleteParams:object
* Default arguments: time:1, delay:0
* Applies a jolt of rotation force on the given axis based on a percentage or multiplier of 360 degrees and springs the GameObject back to its original position like a punching bag.
* Negative/positive values dictate the direction of the initial impact.
* Does not work on GUIText, GUITexture and similar display objects that do not support rotation.
* Does not utilize a transition.

iTween.moveTo(GameObject, Hashtable)

* Valid arguments: x:float, y:float, z:float, time:float, delay:float, transition:String, onComplete:string, onCompleteParams:object
* Default arguments: time:1, delay:0, transition: »easeInOutCubic »
* Moves the GameObject to the supplied coordinate(s).

iTween.moveFrom(GameObject, Hashtable)

* Valid arguments: x:float, y:float, z:float, time:float, delay:float, transition:String, onComplete:string, onCompleteParams:object
* Default arguments: time:1, delay:0, transition: »easeInOutCubic »
* Moves the GameObject from the supplied coordinate(s).

iTween.fadeTo(GameObject, Hashtable)

* Valid arguments: alpha:float, time:float, delay:float, transition:String, onComplete:string, onCompleteParams:object
* Default arguments: time:1, delay:0, transition: »linear »
* Fades the material of the GameObject to the supplied alpha.
* Only works if the GameObject’s material calculates transparency.

iTween.fadeFrom(GameObject, Hashtable)

* Valid arguments: alpha:float, time:float, delay:float, transition:String, onComplete:string, onCompleteParams:object
* Default arguments: time:1, delay:0, transition: »linear »
* Fades the material of the GameObject from the supplied alpha.
* Only works if the GameObject’s material calculates transparency.

iTween.rotateTo(GameObject, Hashtable)

* Valid arguments: x:float, y:float, z:float, time:float, delay:float, transition:String, onComplete:string, onCompleteParams:object
* Default arguments: time:1, delay:0, transition: »easeInOutCubic »
* Rotates the GameObject to the supplied degree(s).
* Rotation direction is automatically decided based on shortest travel time.
* Does not work on GUIText, GUITexture and similar display objects that do not support rotation.

iTween.rotateFrom(GameObject, Hashtable)

* Valid arguments: x:float, y:float, z:float, time:float, delay:float, transition:String, onComplete:string, onCompleteParams:object
* Default arguments: time:1, delay:0, transition: »easeInOutCubic »
* Rotates the GameObject from the supplied degree(s).
* Rotation direction is automatically decided based on shortest travel time.
* Does not work on GUIText, GUITexture and similar display objects that do not support rotation.

iTween.rotateBy(GameObject, Hashtable)

* Valid arguments: x:float, y:float, z:float, time:float, delay:float, transition:String, onComplete:string, onCompleteParams:object
* Default arguments: time:1, delay:0, transition: »easeInOutCubic »
* Rotates the GameObject 360 degrees times the supplied multiplier(s).
* Negative/positive values dictate direction of rotation.
* Does not work on GUIText, GUITexture and similar display objects that do not support rotation.

iTween.shake(GameObject, Hashtable)

* Valid arguments: x:float, y:float, z:float, time:float, delay:float, onComplete:string, onCompleteParams:object
* Default arguments: time:1, delay:0
* Randomly shakes the GameObject on each supplied axis by the supplied magnitude.
* Negative/positive values dictate direction of initial impact.
* Application will gradually resolve and return object to its original coordinates.
* Does not utilize a transition.

iTween.stab(GameObject, Hashtable)

* Valid arguments: volume:float, pitch:float, clip:AudioClip, delay:float, onComplete:string, onCompleteParams:object
* Default arguments: time:1, delay:0
* Plays an AudioClip one time based on supplied volume and pitch.
* « onComplete » functionality fires after audio has finished playing.
* If an AudioSource component isn’t attached to the GameObject one will be automatically added.
* If no AudioClip is provided the default AudioSource’s clip property will be used.

iTween.scaleTo(GameObject, Hashtable)

* Valid arguments: x:float, y:float, z:float, time:float, delay:float, onComplete:string, onCompleteParams:object
* Default arguments: time:1, delay:0, transition: »easeInOutCubic »
* Scales the GameObject to the supplied multiplier(s).

iTween.scaleFrom(GameObject, Hashtable)

* Valid arguments: x:float, y:float, z:float, time:float, delay:float, onComplete:string, onCompleteParams:object
* Default arguments: time:1, delay:0, transition: »easeInOutCubic »
* Scales the GameObject from the supplied multiplier(s).

iTween.audioTo(GameObject, Hashtable)

* Valid arguments: volume:float, pitch:float, delay:float, onComplete:string, onCompleteParams:object
* Default arguments: time:1, delay:0, transition: »linear »
* Fades volume and or pitch of an AudioClip to the supplied target values.

iTween.audioFrom(GameObject, Hashtable)

* Valid arguments: volume:float, pitch:float, delay:float, onComplete:string, onCompleteParams:object
* Default arguments: time:1, delay:0, transition: »linear »
* Fades volume and or pitch of an AudioClip from the supplied target values.

iTween.stop(GameObject)

* Stops all iTweens on the supplied GameObject.

iTween.stopType(GameObject, String)

* Stops all iTweens on the supplied GameObject of a particular method.
* Supplied types are of the root name of the type (i.e. « move », « scale », « fade », etc…) minus the « To » or « From ».

iTween.tweenCount()

* Returns an int.
* Returns the total number of iTweens on the supplied GameObject.

De plus, sont intégrés les habituels « ease » permettant de donner des effets de mouvement.

Dessiner dans Unity

Le site Everydayflash a transposé une méthode de flash permettant de dessiner dans Unity. L’intérêt est de pouvoir créer des dessins directement en 3D en utilisant les méthodes de générations de polygones intégrées dans l’API.
Mais là où ça devient fort, c’est que le site propose 3 manières pour y arrivez avec les sources fournies et les démos. A voir absolument.

Script EncloseTerrain

Trouvé sur le site Bydesigngames, voici un script en C# qui permet de créer des murs tout autour d’un terrain afin de lui imposer une limite.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
* Written by: Matt Greene (aka Deis)
* Last Revision: 3/11/2010 12:50 EST
*
* A very simply script for encapsulating your terrain
* in a wall. I suggest combining this script with others
* such as the Terrain Toolkit and blending.
*
* NOTICE: You need to manually set your Height and Depth
* in this script for now.
*
*/
 
using UnityEngine;
using UnityEditor;
 
public class EncloseTerrain : MonoBehaviour
{
// The desired height of the wall
public static float EncloseHeight = 5;
// How thick the wall needs to be
public static float EncloseDepth = 10;
 
[MenuItem("CONTEXT/Terrain/Enclose")]
[MenuItem("CONTEXT/TerrainData/Enclose")]
[MenuItem("Terrain/Enclose")]
public static void Enclose(MenuCommand command)
{
TerrainData terrainData;
 
if (command.context is TerrainData)
terrainData = (TerrainData) command.context;
else if (command.context is Terrain)
terrainData = ((Terrain) command.context).terrainData;
else
terrainData = Terrain.activeTerrain.terrainData;
 
Undo.RegisterUndo(terrainData, "Enclose Terrain");
 
EditorUtility.DisplayProgressBar("Enclose Terrain", "Initializing", 0.0f);
 
 
int w = terrainData.heightmapWidth;
int h = terrainData.heightmapHeight;
float size = terrainData.size.y;
float[,] heights = terrainData.GetHeights(0, 0, w, h);
 
for (int x = 0; x < heights.GetLength(0); x++)
{
for (int y = 0; y < heights.GetLength(1); y++)
{
if (x < EncloseDepth || x > w - EncloseDepth)
{
heights[x, y] = EncloseHeight / size;
}
 
if (y < EncloseDepth || y > h - EncloseDepth)
{
heights[x, y] = EncloseHeight / size;
}
}
}
 
terrainData.SetHeights(0, 0, heights);
 
EditorUtility.DisplayProgressBar("Enclose Terrain", "Finalizing", 1.0f);
EditorUtility.ClearProgressBar();
}
}