コード例 #1
0
        public static bool SetupLightmap(Object lightmapAssetObj)
        {
            if (!(lightmapAssetObj is LightMapAsset))
            {
                return false;
            }


            LightMapAsset lightmapAsset = (LightMapAsset)lightmapAssetObj;

            if (lightmapAsset.lightmapFar == null || lightmapAsset.lightmapNear == null || lightmapAsset.lightmapFar.Length != lightmapAsset.lightmapNear.Length)
            {
                return false;
            }

            int count = lightmapAsset.lightmapFar.Length;
            LightmapData[] lightmapDatas = new LightmapData[count];
            for (int i = 0; i < count; ++i)
            {
                LightmapData Lightmap = new LightmapData();
                Lightmap.lightmapFar = lightmapAsset.lightmapFar[i];
                Lightmap.lightmapNear = lightmapAsset.lightmapNear[i];
                lightmapDatas[i] = Lightmap;
            }
            LightmapSettings.lightmaps = lightmapDatas;
            return true;
        }
コード例 #2
0
 /// <summary>
 /// Write the specified value using the writer.
 /// </summary>
 /// <param name="value">Value.</param>
 /// <param name="writer">Writer.</param>
 public override void Write(object value, ISaveGameWriter writer)
 {
     UnityEngine.LightmapData lightmapData = (UnityEngine.LightmapData)value;
     writer.WriteProperty("lightmapColor", lightmapData.lightmapColor);
     writer.WriteProperty("lightmapDir", lightmapData.lightmapDir);
     writer.WriteProperty("shadowMask", lightmapData.shadowMask);
 }
コード例 #3
0
 static public int set_lightmapColor(IntPtr l)
 {
     try {
                     #if DEBUG
         var    method     = System.Reflection.MethodBase.GetCurrentMethod();
         string methodName = GetMethodName(method);
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.BeginSample(methodName);
                     #else
         Profiler.BeginSample(methodName);
                     #endif
                     #endif
         UnityEngine.LightmapData self = (UnityEngine.LightmapData)checkSelf(l);
         UnityEngine.Texture2D    v;
         checkType(l, 2, out v);
         self.lightmapColor = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
             #if DEBUG
     finally {
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.EndSample();
                     #else
         Profiler.EndSample();
                     #endif
     }
             #endif
 }
コード例 #4
0
 static public int get_shadowMask(IntPtr l)
 {
     try {
                     #if DEBUG
         var    method     = System.Reflection.MethodBase.GetCurrentMethod();
         string methodName = GetMethodName(method);
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.BeginSample(methodName);
                     #else
         Profiler.BeginSample(methodName);
                     #endif
                     #endif
         UnityEngine.LightmapData self = (UnityEngine.LightmapData)checkSelf(l);
         pushValue(l, true);
         pushValue(l, self.shadowMask);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
             #if DEBUG
     finally {
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.EndSample();
                     #else
         Profiler.EndSample();
                     #endif
     }
             #endif
 }
コード例 #5
0
 static public int constructor(IntPtr l)
 {
     try {
                     #if DEBUG
         var    method     = System.Reflection.MethodBase.GetCurrentMethod();
         string methodName = GetMethodName(method);
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.BeginSample(methodName);
                     #else
         Profiler.BeginSample(methodName);
                     #endif
                     #endif
         UnityEngine.LightmapData o;
         o = new UnityEngine.LightmapData();
         pushValue(l, true);
         pushValue(l, o);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
             #if DEBUG
     finally {
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.EndSample();
                     #else
         Profiler.EndSample();
                     #endif
     }
             #endif
 }
コード例 #6
0
// fields

// properties
    static void LightmapSettings_lightmaps(JSVCall vc)
    {
        if (vc.bGet)
        {
            var result = UnityEngine.LightmapSettings.lightmaps;
            var arrRet = result;
            for (int i = 0; arrRet != null && i < arrRet.Length; i++)
            {
                JSMgr.datax.setObject((int)JSApi.SetType.SaveAndTempTrace, arrRet[i]);
                JSApi.moveSaveID2Arr(i);
            }
            JSApi.setArrayS((int)JSApi.SetType.Rval, (arrRet != null ? arrRet.Length : 0), true);
        }
        else
        {
            UnityEngine.LightmapData[] arg0 = JSDataExchangeMgr.GetJSArg <UnityEngine.LightmapData[]>(() =>
            {
                int jsObjID = JSApi.getObject((int)JSApi.GetType.Arg);
                int length  = JSApi.getArrayLength(jsObjID);
                var ret     = new UnityEngine.LightmapData[length];
                for (var i = 0; i < length; i++)
                {
                    JSApi.getElement(jsObjID, i);
                    ret[i] = (UnityEngine.LightmapData)JSMgr.datax.getObject((int)JSApi.GetType.SaveAndRemove);
                }
                return(ret);
            });
            UnityEngine.LightmapSettings.lightmaps = arg0;
        }
    }
コード例 #7
0
 static public int constructor(IntPtr l)
 {
     UnityEngine.LightmapData o;
     o = new UnityEngine.LightmapData();
     pushObject(l, o);
     return(1);
 }
コード例 #8
0
    // Use this for initialization
    static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
    {
        LightmappingTool.LoadObjects();
        if (LightmappingTool.window!=null) LightmappingTool.window.Repaint();

        bool Found=false;
        foreach (string i in importedAssets)
        {
            if (i.Contains("lightmap")){
                Found=true;
                break;
            }
        }
        if (!Found) return;

        ArrayList loaded = new ArrayList();

        LightmapData[] data = new LightmapData[LightmappingTool.numberOfLightmaps];
        for (int i = 0; i < LightmappingTool.numberOfLightmaps; i++)
        {
            data[i] = new LightmapData();

        }
        try
        {
            foreach (string f in Directory.GetFiles(Application.dataPath + LightmappingTool.LMdir.Replace("<sceneName>", Path.GetFileNameWithoutExtension(EditorApplication.currentScene))))
            {
                for (int i = 1; i < LightmappingTool.numberOfLightmaps+1; i++)
                {
                    if (Path.GetFileName(f) == "lightmap" + i + LightmappingTool.fileFormat)
                    {
                        Texture2D tex = (Texture2D)AssetDatabase.LoadAssetAtPath(f.Substring(Application.dataPath.Length - 6), typeof(Texture2D));
                        data[i-1].lightmapFar = tex;
                        loaded.Add(i);
                    }
                }
            }
            string container= "";
            foreach (int i in loaded){
                container+=""+i+", ";
            }
            try
            {
                container= container.Substring(0, container.Length - 2);
            }
            catch{}
            if (container.Length > 0)
            {

                Debug.Log("At " + String.Format("{0:T}", DateTime.Now) + " following lightmaps got loaded: " + container);
            }
        }
        catch (DirectoryNotFoundException)
        {
            if (LightmappingTool.LMdir[0] != Convert.ToChar("/")) LightmappingTool.LMdir = "/" + LightmappingTool.LMdir;
            System.IO.Directory.CreateDirectory(Application.dataPath + LightmappingTool.LMdir.Replace("<sceneName>", Path.GetFileNameWithoutExtension(EditorApplication.currentScene)));
        }
        LightmapSettings.lightmaps = data;
    }
コード例 #9
0
 static public int set_lightmapNear(IntPtr l)
 {
     UnityEngine.LightmapData o = (UnityEngine.LightmapData)checkSelf(l);
     UnityEngine.Texture2D    v;
     checkType(l, 2, out v);
     o.lightmapNear = v;
     return(0);
 }
コード例 #10
0
 public void loadLightmap()
 {
     lightmapData = new LightmapData[10];
     for (int i = 0; i < 2; i++) {
         lightmapData[i] = new LightmapData();
         lightmapData[i].lightmapFar = Resources.Load("Lightmaps/LightmapFar-" + i.ToString(), typeof(Texture2D)) as Texture2D;
         lightmapData[i].lightmapNear = Resources.Load("Lightmaps/LightmapNear-" + i.ToString(), typeof(Texture2D)) as Texture2D;
     }
     LightmapSettings.lightmaps = lightmapData;
 }
コード例 #11
0
//--------------------------------------------debug view end----------------------------
	void Start()
	{
		GameObject player = GameObject.FindWithTag("Player");
		if(player != null && playerStartPosition != null)
		{
			player.transform.position = playerStartPosition.position;
			player.transform.rotation = playerStartPosition.rotation;
		}

		if(lowLevel)
			SetRenderLevelLow();

		RenderSettings.ambientLight = this.ambColor;
		RenderSettings.fogColor = this.fogColor;
		RenderSettings.fogMode = this.fogType;
		RenderSettings.fogDensity = this.fogDensity;
		RenderSettings.fogStartDistance = this.fogStart;
		RenderSettings.fogEndDistance = this.fogEnd;
		RenderSettings.fog = !this.lowLevel & this.fogOn;

		if(lightMapsFar.Length > 0)
		{
			LightmapSettings.lightmapsMode = LightmapsMode.NonDirectional;
			LightmapData[] newLightMaps = new LightmapData[lightMapsFar.Length];
			
			for(int i = 0; i < newLightMaps.Length; i++)
			{
				LightmapData newLmap = new LightmapData();
				if(lightMapsFar[i] == null && Application.isEditor)
				{
					Debug.LogError("Lost Lightmap!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!",this.gameObject);
					Debug.Break();
				}
				newLmap.lightmapFar = lightMapsFar[i];
				newLightMaps[i] = newLmap;
			}
			
			LightmapSettings.lightmaps = newLightMaps;
		}
	//	this.enabled = false;

//--------------------------------------------debug view, useless for game----------------------------
		this.enabled = debugButton;
		debugFog = fogOn;
		debugTransparentObj = !lowLevel;
		debugLowMatObj = lowLevel;
		debugShowFPS = false;

		if(SpecialObjects != null && SpecialObjects.Length > 0)
			debugSpObj = SpecialObjects[0].activeSelf;

		lastInterval = Time.realtimeSinceStartup;
		frames = 0;
//--------------------------------------------debug view end----------------------------
	}
コード例 #12
0
ファイル: MapLighting.cs プロジェクト: cyanpunk/muonline
        public void Init(Util.Map.Location map)
        {
            LightmapData[] lightmapData = new LightmapData[1];

            LightmapSettings.lightmapsMode = LightmapsMode.Single;
            for( int i = 0 ; i < 1 ; i++ ) {
                lightmapData[i] = new LightmapData();
                lightmapData[i].lightmapFar = Resources.Load(Util.File.DIRECTORY_LIGHTS+(int)map, typeof(Texture2D)) as Texture2D;
            }
            LightmapSettings.lightmaps = lightmapData;
        }
コード例 #13
0
 static public int get_shadowMask(IntPtr l)
 {
     try {
         UnityEngine.LightmapData self = (UnityEngine.LightmapData)checkSelf(l);
         pushValue(l, self.shadowMask);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
コード例 #14
0
	static public int constructor(IntPtr l) {
		try {
			UnityEngine.LightmapData o;
			o=new UnityEngine.LightmapData();
			pushValue(l,true);
			pushValue(l,o);
			return 2;
		}
		catch(Exception e) {
			return error(l,e);
		}
	}
コード例 #15
0
 static public int constructor(IntPtr l)
 {
     try {
         UnityEngine.LightmapData o;
         o = new UnityEngine.LightmapData();
         pushValue(l, o);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
コード例 #16
0
 static public int get_lightmapNear(IntPtr l)
 {
     try {
         UnityEngine.LightmapData self = (UnityEngine.LightmapData)checkSelf(l);
         pushValue(l, self.lightmapNear);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
コード例 #17
0
 static public int get_lightmapNear(IntPtr l)
 {
     try {
         UnityEngine.LightmapData self = (UnityEngine.LightmapData)checkSelf(l);
         pushValue(l, true);
         pushValue(l, self.lightmapNear);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
コード例 #18
0
 public static int constructor(IntPtr l)
 {
     try {
         UnityEngine.LightmapData o;
         o=new UnityEngine.LightmapData();
         pushValue(l,o);
         return 1;
     }
     catch(Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return 0;
     }
 }
コード例 #19
0
 static public int set_shadowMask(IntPtr l)
 {
     try {
         UnityEngine.LightmapData self = (UnityEngine.LightmapData)checkSelf(l);
         UnityEngine.Texture2D    v;
         checkType(l, 2, out v);
         self.shadowMask = v;
         return(0);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
コード例 #20
0
 static public int constructor(IntPtr l)
 {
     try {
         UnityEngine.LightmapData o;
         o = new UnityEngine.LightmapData();
         pushValue(l, o);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
コード例 #21
0
 static public int constructor(IntPtr l)
 {
     LuaDLL.lua_remove(l, 1);
     UnityEngine.LightmapData o;
     if (matchType(l, 1))
     {
         o = new UnityEngine.LightmapData();
         pushObject(l, o);
         return(1);
     }
     LuaDLL.luaL_error(l, "New object failed.");
     return(0);
 }
コード例 #22
0
 static public int set_lightmapNear(IntPtr l)
 {
     try {
         UnityEngine.LightmapData self = (UnityEngine.LightmapData)checkSelf(l);
         UnityEngine.Texture2D    v;
         checkType(l, 2, out v);
         self.lightmapNear = v;
         return(0);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
コード例 #23
0
 static public int set_lightmapNear(IntPtr l)
 {
     try {
         UnityEngine.LightmapData self = (UnityEngine.LightmapData)checkSelf(l);
         UnityEngine.Texture2D    v;
         checkType(l, 2, out v);
         self.lightmapNear = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
コード例 #24
0
 static void LightmapData_lightmapNear(JSVCall vc)
 {
     if (vc.bGet)
     {
         UnityEngine.LightmapData _this = (UnityEngine.LightmapData)vc.csObj;
         var result = _this.lightmapNear;
         JSMgr.datax.setObject((int)JSApi.SetType.Rval, result);
     }
     else
     {
         UnityEngine.Texture2D    arg0  = (UnityEngine.Texture2D)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
         UnityEngine.LightmapData _this = (UnityEngine.LightmapData)vc.csObj;
         _this.lightmapNear = arg0;
     }
 }
コード例 #25
0
ファイル: LightmapTool.cs プロジェクト: KevinKernel/Unity
        //Selection Lightmap to Unity Lightmaping Array
        private void SelLMToLMArray()
        {
            int count = Selection.objects.Length;
            LightmapData[] LMData = new LightmapData[count];

            Object[] LMTexture = Selection.objects;

            for (int i = 0; i < count; ++i)
            {
                LightmapData lightmapFar = new LightmapData();
                lightmapFar.lightmapFar = LMTexture[i] as Texture2D;
                LMData[int.Parse((LMTexture[i].name.Split('_'))[1])] = lightmapFar;
            }

            LightmapSettings.lightmaps = LMData;
        }
コード例 #26
0
    public void SetLightMapTextures()
    {
        if (lightMapTexturesFar == null || lightMapTexturesFar.Length <= 0)
            return;

            LightmapData[] lightmapData = new LightmapData[lightMapTexturesFar.Length];

            for (int i = 0; i < lightMapTexturesFar.Length; i++)
            {
                lightmapData[i] = new LightmapData();
                lightmapData[i].lightmapFar = lightMapTexturesFar[i];

        }
        #if UNITY_5_0
            LightmapSettings.lightmapsMode = LightmapsMode.NonDirectional;
        #endif
            LightmapSettings.lightmaps = lightmapData;
    }
コード例 #27
0
	void Awake ()
	{
		if (m_RendererInfo == null || m_RendererInfo.Length == 0)
			return;

		var lightmaps = LightmapSettings.lightmaps;
		var combinedLightmaps = new LightmapData[lightmaps.Length + m_Lightmaps.Length];

		lightmaps.CopyTo(combinedLightmaps, 0);
		for (int i = 0; i < m_Lightmaps.Length;i++)
		{
			combinedLightmaps[i+lightmaps.Length] = new LightmapData();
			combinedLightmaps[i+lightmaps.Length].lightmapFar = m_Lightmaps[i];
		}

		ApplyRendererInfo(m_RendererInfo, lightmaps.Length);
		LightmapSettings.lightmaps = combinedLightmaps;
	}
コード例 #28
0
 public void UpdateLightmap()
 {
     int length = Mathf.Max(this.LightmapFars.Length,this.LightmapNears.Length);
     LightmapData[] lightmaps = new LightmapData[length];
     for (int i = 0; i < length; i++)
     {
         LightmapData lightmapData = new LightmapData(); ;
         if (i < this.LightmapFars.Length)
         {
             lightmapData.lightmapFar = this.LightmapFars[i];
         }
         if (i < this.LightmapNears.Length)
         {
             lightmapData.lightmapNear = this.LightmapNears[i];
         }
         lightmaps[i] = lightmapData;
     }
     LightmapSettings.lightmaps = lightmaps;
 }
コード例 #29
0
        /// <summary>
        /// Read the data into the specified value.
        /// </summary>
        /// <param name="value">Value.</param>
        /// <param name="reader">Reader.</param>
        public override void ReadInto(object value, ISaveGameReader reader)
        {
            UnityEngine.LightmapData lightmapData = (UnityEngine.LightmapData)value;
            foreach (string property in reader.Properties)
            {
                switch (property)
                {
                case "lightmapColor":
                    if (lightmapData.lightmapColor == null)
                    {
                        lightmapData.lightmapColor = reader.ReadProperty <UnityEngine.Texture2D> ();
                    }
                    else
                    {
                        reader.ReadIntoProperty <UnityEngine.Texture2D> (lightmapData.lightmapColor);
                    }
                    break;

                case "lightmapDir":
                    if (lightmapData.lightmapDir == null)
                    {
                        lightmapData.lightmapDir = reader.ReadProperty <UnityEngine.Texture2D> ();
                    }
                    else
                    {
                        reader.ReadIntoProperty <UnityEngine.Texture2D> (lightmapData.lightmapDir);
                    }
                    break;

                case "shadowMask":
                    if (lightmapData.shadowMask == null)
                    {
                        lightmapData.shadowMask = reader.ReadProperty <UnityEngine.Texture2D> ();
                    }
                    else
                    {
                        reader.ReadIntoProperty <UnityEngine.Texture2D> (lightmapData.shadowMask);
                    }
                    break;
                }
            }
        }
コード例 #30
0
    void ApplyLightmaps()
    {
        if (m_applied)
            return;

        var lightmaps = LightmapSettings.lightmaps;
        var combinedLightmaps = new LightmapData[lightmaps.Length + m_Lightmaps.Length];

        lightmaps.CopyTo(combinedLightmaps, 0);
        for (int i = 0; i < m_Lightmaps.Length;i++)
        {
            combinedLightmaps[i+lightmaps.Length] = new LightmapData();
            combinedLightmaps[i+lightmaps.Length].lightmapFar = m_Lightmaps[i];
        }

        ApplyRendererInfo(m_RendererInfo, lightmaps.Length);
        LightmapSettings.lightmaps = combinedLightmaps;

        m_applied = true;
    }
コード例 #31
0
    // Update is called once per frame
    void Update()
    {
        if (aa !=null && aa.isDone)
        {
            //load lightmap
            Debug.Log("load lightmap...");
            List<LightmapData> arrld = new List<LightmapData>();
            LightmapData ld = new LightmapData();
            ld.lightmapFar = aa.assetBundle.Load("LightmapFar-0", typeof(Texture2D)) as Texture2D;
            ld.lightmapNear = aa.assetBundle.Load("LightmapNear-0", typeof(Texture2D)) as Texture2D;
            arrld.Add(ld);

            LightmapSettings.lightmapsMode = LightmapsMode.Dual;
            LightmapSettings.lightmaps = arrld.ToArray();

            //load model
            Debug.Log("load model...");
            GameObject go = GameObject.Instantiate(aa.assetBundle.Load("StaticObj", typeof(GameObject))) as GameObject;
            aa = null;
        }
    }
コード例 #32
0
ファイル: Switch1Script.cs プロジェクト: larcohex/unity
 void OnMouseDown()
 {
     if (on == "0") {
         on = "1";
         string switch2 = GameObject.Find ("Switch2").GetComponent<Switch2Script>().getState();
         string switch3 = GameObject.Find ("Switch3").GetComponent<Switch3Script>().getState();
         LightmapData[] lightmapData = new LightmapData[3];
         for(int i = 0 ; i < 3 ; i++ )
         {
             lightmapData[i] = new LightmapData();
         }
         for( int i = 0 ; i < 3 ; i++ )
         {
             lightmapData[i].lightmapFar = Resources.Load( "lightmap" + on + switch2 + switch3 + "/LightmapFar-" + i.ToString(), typeof(Texture2D)) as Texture2D;
             lightmapData[i].lightmapNear = Resources.Load("lightmap" + on + switch2 + switch3 + "/LightmapNear-" + i.ToString(), typeof(Texture2D)) as Texture2D;
             Debug.Log (lightmapData[i].lightmapFar);
             Debug.Log (lightmapData[i].lightmapNear);
         }
         LightmapSettings.lightmaps = lightmapData;
     }
     else {
         on = "0";
         string switch2 = GameObject.Find ("Switch2").GetComponent<Switch2Script>().getState();
         string switch3 = GameObject.Find ("Switch3").GetComponent<Switch3Script>().getState();
         LightmapData[] lightmapData = new LightmapData[3];
         for(int i = 0 ; i < 3 ; i++ )
         {
             lightmapData[i] = new LightmapData();
         }
         for( int i = 0 ; i < 3 ; i++ )
         {
             lightmapData[i].lightmapFar = Resources.Load( "lightmap" + on + switch2 + switch3 + "/LightmapFar-" + i.ToString(), typeof(Texture2D)) as Texture2D;
             lightmapData[i].lightmapNear = Resources.Load("lightmap" + on + switch2 + switch3 + "/LightmapNear-" + i.ToString(), typeof(Texture2D)) as Texture2D;
             Debug.Log (lightmapData[i].lightmapFar);
             Debug.Log (lightmapData[i].lightmapNear);
         }
         LightmapSettings.lightmaps = lightmapData;
     }
 }
コード例 #33
0
ファイル: IOSTest.cs プロジェクト: seenen/Tool_AssetBundles
    IEnumerator Scene()
    {
        yield return 1;

#if UNITY_IPHONE
		string path = "file://" + Application.dataPath + "/Raw/";
#elif UNITY_STANDALONE_WIN
        string path = "file://" + Application.dataPath + "/StreamingAssets/";
#else
		string path = "jar:file://" + Application.dataPath + "!/assets/";
#endif

        Debug.Log(path + "110101.assetBundles");

        ABLoad load = new ABLoad(path + "110101.assetBundles");
        while (true)
        {
            if (load.bundle.isDone)
                break;

            yield return 1;
        }
        
        //  加载场景
        GameObject res = load.Load<GameObject>("110101");
        Instantiate(res);

        //  加载LightMap
        ArrayList texlist = new ArrayList();// Texture2D

        Object[] objects = load.LoadAll();
        foreach (Object e in objects)
        {
            if (!e.name.StartsWith("LightmapFar-"))
                continue;

            if (e.GetType() == typeof(Texture2D))
                texlist.Add(e);
        }
        texlist.Sort();

        //  数据集数量
        int lmDataSetCount = (texlist.Count + 1) / 2;
        int lmDataIndex = 0;

        LightmapData[] lmDataSet = new LightmapData[lmDataSetCount];

        for (int i = 0; i < texlist.Count; ++i)
        {
            LightmapData lmData = new LightmapData();
            lmData.lightmapFar = (Texture2D)texlist[i];
            if ((++i) != texlist.Count) lmData.lightmapNear = (Texture2D)texlist[i];

            lmDataSet[lmDataIndex] = lmData;
        }

        LightmapSettings.lightmapsMode = LightmapsMode.Dual;
        LightmapSettings.lightmaps = lmDataSet;

        load.Close();

    }
コード例 #34
0
 static public int get_lightmapNear(IntPtr l)
 {
     UnityEngine.LightmapData o = (UnityEngine.LightmapData)checkSelf(l);
     pushValue(l, o.lightmapNear);
     return(1);
 }
コード例 #35
0
ファイル: ScenesManager.cs プロジェクト: lbddk/ahzs-client
        private void SwitchLightMapFog(MapData data, Action<Boolean> loaded)
        {
            RenderSettings.fog = data.fog;
            RenderSettings.fogColor = data.fogColor;
            RenderSettings.fogMode = data.fogMode;
            RenderSettings.fogStartDistance = data.linearFogStart;
            RenderSettings.fogEndDistance = data.linearFogEnd;
            RenderSettings.ambientLight = data.ambientLight;

            if (String.IsNullOrEmpty(data.lightmap))
            {
                if (loaded != null)
                    loaded(true);
            }
            else
            {
                AssetCacheMgr.GetSceneResource(data.lightmap, (lm) =>
                {
                    AssetCacheMgr.UnloadAssetbundle(data.lightmap);
                    m_lightmap = lm;
                    LightmapData lmData = new LightmapData();
                    lmData.lightmapFar = lm as Texture2D;
                    LightmapSettings.lightmaps = new LightmapData[1] { lmData };
                    if (loaded != null)
                        loaded(true);
                });
                if (!String.IsNullOrEmpty(data.lightProbes))
                    AssetCacheMgr.GetSceneResource(data.lightProbes, (lp) =>
                    {
                        AssetCacheMgr.UnloadAssetbundle(data.lightProbes);
                        m_lightProbes = lp;
                        LightmapSettings.lightProbes = lp as LightProbes;
                    });
            }
        }
コード例 #36
0
    protected void OnInstantiateLightmaps(GameControllerBase mainGame, PB.Common.LightmapInfo lightmap)
    {
        if (lightmap.lightmapsMode != "" && lightmap.lightmapsMode != null && lightmap.lightmaps.Count > 0)
        {
            LightmapsMode mode = (LightmapsMode)Enum.Parse(typeof(LightmapsMode), lightmap.lightmapsMode);
            LightmapSettings.lightmapsMode = mode;

            List<LightmapData> maps = new List<LightmapData>();
            Level level = mainGame.Game.WorldData.Level;
            foreach (LightmapDataInfo lmData in level.Lightmap.lightmaps)
            {
                LightmapData data = new LightmapData();

                string nearKey = string.Format("{0}{1}/{2}.unity3d", PopBloopSettings.LevelAssetsUrl, level.Path, lmData.nearLightmap);
                string farKey = string.Format("{0}{1}/{2}.unity3d", PopBloopSettings.LevelAssetsUrl, level.Path, lmData.farLightmap);

                if (lmData.nearLightmap != "" && AssetsManager.Bundles.ContainsKey(nearKey))
                {
                    WWW www = AssetsManager.Bundles[nearKey];

                    if (www.assetBundle != null)
                    {
                        data.lightmapNear = (Texture2D)www.assetBundle.mainAsset;
                    }
                    else
                    {
                        Debug.LogWarning("OnInstantiateLightmaps.NearLightMaps: AssetBundle not found on " + nearKey);
                    }
                }

                // Setup Far Lightmap if there is
                if (lmData.farLightmap != "" && AssetsManager.Bundles.ContainsKey(farKey))
                {
                    WWW www = AssetsManager.Bundles[farKey];

                    if (www.assetBundle != null)
                    {
                        data.lightmapFar = (Texture2D)www.assetBundle.mainAsset;
                    }
                    else
                    {
                        Debug.LogWarning("OnInstantiateLightmaps.FarLightMaps: AssetBundle not found on " + farKey);
                    }
                }

                maps.Add(data);
            }

            if (maps.Count > 0)
            {
                LightmapSettings.lightmaps = maps.ToArray();
            }
        }
    }
コード例 #37
0
    static int _CreateLightmapData(IntPtr L)
    {
        int count = LuaDLL.lua_gettop(L);

        if (count == 0)
        {
            LightmapData obj = new LightmapData();
            LuaScriptMgr.PushObject(L, obj);
            return 1;
        }
        else
        {
            LuaDLL.luaL_error(L, "invalid arguments to method: LightmapData.New");
        }

        return 0;
    }
コード例 #38
0
ファイル: GameLuaInterface.cs プロジェクト: fengqk/Art
    public static int SetLightmaps(IntPtr L)
    {
        if (LuaDLL.lua_isnil(L, 1))
        {
            LightmapSettings.lightmaps = new LightmapData[] { };
            return 0;
        }

        if (!LuaDLL.lua_istable(L, 1))
        {
            LuaDLL.lua_pushstring(L, "SetLightmaps: param 1 must be table");
            LuaDLL.lua_error(L);
            return 1;
        }

        ArrayList lightDatas = new ArrayList();
        LuaDLL.lua_pushnil(L);
        int i=0;
        while (LuaDLL.lua_next(L, 1) != 0)
        {
            ++i;
            IntPtr objptr = LuaDLL.lua_touserdata(L, -1);
            UnityEngine.Texture2D tex = default(UnityEngine.Texture2D);
            System.Object temp = default(System.Object);
            if (LuaStatic.GetObj(objptr, out temp))
            {
                if (temp.GetType().Name != "Texture2D")
                {
                    string str = string.Format("SetLightmaps #{0} must be a Texture2D", i);
                    Debug.Log(str);
                }
                else
                {
                    tex = temp as Texture2D;
                    LightmapData data = new LightmapData();
                    data.lightmapNear = null;
                    data.lightmapFar = tex;
                    lightDatas.Add(data);
                }
            }
            else
            {
                LuaStatic.traceback(L);
                LuaDLL.lua_error(L);
                return 1;
            }
            LuaDLL.lua_pop(L, 1);
        }
        LightmapSettings.lightmaps = (LightmapData[])lightDatas.ToArray(typeof(LightmapData));
        return 0;
   }
コード例 #39
0
 /// <summary>
 /// Read the data using the reader.
 /// </summary>
 /// <param name="reader">Reader.</param>
 public override object Read(ISaveGameReader reader)
 {
     UnityEngine.LightmapData lightmapData = new UnityEngine.LightmapData();
     ReadInto(lightmapData, reader);
     return(lightmapData);
 }