Page 2 sur 2

Re: Problème Tuto fps partie 1

Publié : 25 Avr 2013 13:55
par namursite
oui par la suite j ai compris.
une scène télécharge en cache le fichier depuis le serveur
l'autre scène dois aller chercher le fichier dans le cache .
vous compris que je ne suis pas programmeur ,
donc merci pour votre compréhension .
il manque ce genre de script , je crois non

Code : Tout sélectionner

using UnityEngine;
using UnityEditor;
public class cache1
	[MenuItem ("Bully!/Mobile Scene Asset Bundle from Selected")]
      static void BuildAssetBundle()
                string assetPath = AssetDatabase.GetAssetPath(Selection.activeObject);
                //make sure user has a scene selected:
                if (Selection.objects.Length != 1 || !assetPath.Contains(".unity"))
                        EditorUtility.DisplayDialog("Scene Asset Bundle Creation", "Please select a single scene in your project.", "OK");
                //set a save location for the bundle:
                string savePath = EditorUtility.SaveFilePanel("Save Scene Asset Bundle", "", "", "unity3d");
                if (savePath == "")
                //save asset bundles for iphone and android:
                string[] pathPieces = savePath.Split('.');
                BuildPipeline.BuildStreamedSceneAssetBundle(new string[] { assetPath }, pathPieces[0] + "." +pathPieces[1], BuildTarget.WebPlayer);
                EditorUtility.DisplayDialog("Scene Asset Bundle Creation", "Done!", "OK");
merci d 'avance :-)

Re: Problème Tuto fps partie 1

Publié : 26 Avr 2013 10:44
par namursite
krys64 a écrit :c est simple, dans ta scene1, si tu clique sur "Terrain" dans ta hierarchy, tu verras qu il manque un script associé à un composant dans la fenetre "inspector"
bon j ai trouver un autre code pas d 'erreur.
au début il ma dis
rejected because no crossdomain.xml policy file was found
je lui ai fournis en utf8 .
maintenant il me met le message suivant :
The unity3d file is not a valid asset bundle.

Code : Tout sélectionner

using UnityEngine;
using System.Collections;

public class AssetLoader : MonoBehaviour {
 string assetURL="";
 // Use this for initialization
 void Start () {
  // This is a Unity method that hijaks the .NET co-iterator functionality and
  // uses it to create a psuedo co-routine
 //This is a co-routine method. Co-routines must return the IEnumerator interface
 //This is because .NET doesnt really have co-routines, it has a co-iterator. Unity
 //cleverly hijacks that to create a co-routine. If you need more information, you
 //can try reading the micrsoft docs on yield return, but they are hairy
 IEnumerator LoadAsset(string url){
  // This call utilizes unity's asset cache to avoid reloading the same assets over again
  // If you dont want asset cahchign replace it with:
   //WWW www = new WWW(url);
  WWW www = WWW.LoadFromCacheOrDownload(url,1);
  // This is how you return from the co-routine. The www needs to be passed
  // back as a parameter. The .NET mechanism hides this within a synthetically produced
  // IEnumerator as its first entry in the enumeration but thats hidden inside of
  // StartCoroutine and you'll never see it.
  // Whatever is returned must inherit from the base class YieldInstruction
yield return www;
  //THis code is run after the www has fetched its data or errorored out
  if (www.error!=null){
   Debug.Log (url);
  } else {
   Debug.Log ("Done");
   AssetBundle ab = www.assetBundle;
   Object[] tilePrefabs = ab.LoadAll(typeof(GameObject));
   foreach(Object obj in tilePrefabs){
    Debug.Log (; 
sur le site il dis

Unity's co-routine mechanism is interesting. theoretically you should be able to use it to do just about any kind of co-routine coding. The hitch is that they have hidden the details of YieldInstruction. This goes along with a general semi-crippling philosophy in Unity that they only want you to use the tools they give you the way they already thought they would be used.

Its too bad, because there is a lot of power in the Unity codebase that is completely blocked off from use by the developer.

vrais ou pas même avec le version pro