LogWarning() public static method

public static LogWarning ( object message ) : void
message object
return void
Ejemplo n.º 1
0
    public void OpenZbsDebugger(string ip = "localhost")
    {
        if (!Directory.Exists(LuaConst.zbsDir))
        {
            Debugger.LogWarning("ZeroBraneStudio not install or LuaConst.zbsDir not right");
            return;
        }

        if (!LuaConst.openLuaSocket)
        {
            OpenLuaSocket();
        }

        if (!string.IsNullOrEmpty(LuaConst.zbsDir))
        {
            luaState.AddSearchPath(LuaConst.zbsDir);
        }

        luaState.LuaDoString(string.Format("DebugServerIp = '{0}'", ip), "@LuaClient.cs");
    }
Ejemplo n.º 2
0
 internal static bool OnTweenCallback <T>(TweenCallback <T> callback, T param)
 {
     if (DOTween.useSafeMode)
     {
         try
         {
             callback(param);
         }
         catch (Exception ex)
         {
             Debugger.LogWarning("An error inside a tween callback was silently taken care of > " + ex.Message);
             return(false);
         }
     }
     else
     {
         callback(param);
     }
     return(true);
 }
Ejemplo n.º 3
0
 internal static bool OnTweenCallback(TweenCallback callback)
 {
     if (DOTween.useSafeMode)
     {
         try
         {
             callback();
         }
         catch (Exception ex)
         {
             Debugger.LogWarning("An error inside a tween callback was silently taken care of > " + ex.Message + "\n\n" + ex.StackTrace + "\n\n");
             return(false);
         }
     }
     else
     {
         callback();
     }
     return(true);
 }
Ejemplo n.º 4
0
        /// <summary>
        ///     Tweens a Text's text to the given value.
        ///     Also stores the Text as the tween's target so it can be used for filtered operations
        /// </summary>
        /// <param name="endValue">The end string to tween to</param>
        /// <param name="duration">The duration of the tween</param>
        /// <param name="richTextEnabled">
        ///     If TRUE (default), rich text will be interpreted correctly while animated,
        ///     otherwise all tags will be considered as normal text
        /// </param>
        /// <param name="scrambleMode">The type of scramble mode to use, if any</param>
        /// <param name="scrambleChars">
        ///     A string containing the characters to use for scrambling.
        ///     Use as many characters as possible (minimum 10) because DOTween uses a fast scramble mode which gives better
        ///     results with more characters.
        ///     Leave it to NULL (default) to use default ones
        /// </param>
        public static TweenerCore <string, string, StringOptions> DOText(this Text target, string endValue,
                                                                         float duration, bool richTextEnabled = true, ScrambleMode scrambleMode = ScrambleMode.None,
                                                                         string scrambleChars = null)
        {
            if (endValue == null)
            {
                if (Debugger.logPriority > 0)
                {
                    Debugger.LogWarning(
                        "You can't pass a NULL string to DOText: an empty string will be used instead to avoid errors");
                }
                endValue = "";
            }

            var t = DOTween.To(() => target.text, x => target.text = x, endValue, duration);

            t.SetOptions(richTextEnabled, scrambleMode, scrambleChars)
            .SetTarget(target);
            return(t);
        }
Ejemplo n.º 5
0
        public override void OnMessage(NetPeer peer, NetDataReader reader)
        {
            var npcid    = reader.GetLong();
            var spawnPos = reader.GetVector3();
            var rotation = reader.GetQuaternion();

            var npcView      = npcMgr.CreateNpc <TankView>();
            var mainRoleView = npcView as TankView;

            if (mainRoleView != null)
            {
                mainRoleView.Initialize(npcid, true);  //创建主角自身
                mainRoleView.InitInterpolateFields(spawnPos, rotation);
            }
            //lockstepMgr.Identity = npcid;

            ///启动Lockstep同步
            //lockstepMgr.Initialize();
            //lockstepMgr.StartLockstep();
            Debugger.LogWarning("RetUserInfoHandler  npcid:>" + npcid + " spawnPos:>" + spawnPos + " rotation:>" + rotation);
        }
Ejemplo n.º 6
0
    public void OpenZbsDebugger(string ip = "localhost")
    {
        if (!Directory.Exists(LuaConst.zbsDir))
        {
            Debugger.LogWarning("ZeroBraneStudio not install or LuaConst.zbsDir not right");
            return;
        }

        if (!LuaConst.openLuaSocket)
        {
            OpenLuaSocket();
        }

        //if (!string.IsNullOrEmpty(LuaConst.zbsDir))
        //{
        //    LuaState.AddSearchPath(LuaConst.zbsDir);
        //}

        //Cancel start debug at start of app.
        //LuaState.LuaDoString(string.Format("DebugServerIp = '{0}'", ip));
    }
Ejemplo n.º 7
0
 public static bool StringToBool(string str, bool defaultValue = false)
 {
     try
     {
         if (string.IsNullOrEmpty(str))
         {
             Debugger.LogWarning("Can not convert null or empty to bool.");
             return(defaultValue);
         }
         if (sBoolRegex.IsMatch(str))
         {
             return(Convert.ToBoolean(Convert.ToDouble(str)));
         }
         return(Convert.ToBoolean(str));
     }
     catch (Exception e)
     {
         Debugger.LogError(string.Format("Can not convert {0} to bool with {1}", str, e.GetType().Name));
     }
     return(defaultValue);
 }
Ejemplo n.º 8
0
 public static short StringToShort(string str, short defaultValue = 0)
 {
     try
     {
         if (string.IsNullOrEmpty(str))
         {
             Debugger.LogWarning("Can not convert null or empty to short.");
             return(defaultValue);
         }
         if (sIntRegex.IsMatch(str))
         {
             return(Convert.ToInt16(str));
         }
         return(Convert.ToInt16(Convert.ToDouble(str)));
     }
     catch (Exception e)
     {
         Debugger.LogError(string.Format("Can not convert {0} to short with {1}", str, e.GetType().Name));
     }
     return(defaultValue);
 }
Ejemplo n.º 9
0
        public static void CheckNotSetFontText()
        {
            Debugger.LogError("[Cehcking Not Set Font Text:Start]");
            DirectoryInfo uiDirectoryInfo = new DirectoryInfo("Assets/Res/Resources/ui");

            foreach (FileInfo fileInfo in uiDirectoryInfo.GetFiles("*.prefab", SearchOption.AllDirectories))
            {
                string      prefabPath         = fileInfo.FullName.Substring(fileInfo.FullName.IndexOf(@"Assets\"));
                GameObject  gameObject         = AssetDatabase.LoadAssetAtPath <GameObject>(prefabPath);
                Text[]      texts              = gameObject.GetComponentsInChildren <Text>(true);
                List <Text> notSetFontTextList = new List <Text>();
                for (int i = 0; i < texts.Length; i++)
                {
                    if (texts[i].font == null)
                    {
                        notSetFontTextList.Add(texts[i]);
                    }
                }

                if (notSetFontTextList.Count > 0)
                {
                    Debugger.LogError("-------------------------------------------------------------------------------- [" + gameObject.name + "] --------------------------------------------------------------------------------");
                    Transform parent = null;
                    for (int i = 0; i < notSetFontTextList.Count; i++)
                    {
                        string textPath = string.Empty;
                        parent = notSetFontTextList[i].transform.parent;
                        while (parent != null)
                        {
                            textPath = parent.name + "/" + textPath;
                            parent   = parent.parent;
                        }
                        textPath += notSetFontTextList[i].name + " not set font!";
                        Debugger.LogWarning(textPath);
                    }
                }
            }
            Debugger.LogError("[Cehcking Not Set Font Text:End]");
        }
Ejemplo n.º 10
0
 public static bool RemoveVesselFromSystem(Vessel toRemove)
 {
     Debugger.LogWarning("Despawning " + toRemove.vesselName);
     if (toRemove.loaded)
     {
         Debugger.LogError(toRemove.vesselName + " is loaded!");
     }
     else
     {
         Guid id = toRemove.id;
         if (persistentVessels.ContainsKey(id))
         {
             PersistentVessel vessel = persistentVessels [id];
             return(vessel.Despawn());
         }
         else
         {
             Debugger.LogError(toRemove.vesselName + " was never cached as a PersistentVessel!");
         }
     }
     return(false);
 }
Ejemplo n.º 11
0
 internal static bool OnTweenCallback <T>(TweenCallback <T> callback, T param)
 {
     if (DOTween.useSafeMode)
     {
         try {
             callback(param);
         } catch (Exception e) {
             if (Debugger.logPriority >= 1)
             {
                 Debugger.LogWarning(string.Format(
                                         "An error inside a tween callback was silently taken care of ({0}) ► {1}", e.TargetSite, e.Message
                                         ));
             }
             return(false); // Callback error
         }
     }
     else
     {
         callback(param);
     }
     return(true);
 }
Ejemplo n.º 12
0
 public static long ObjectToLong(object data, long defaultValue = 0)
 {
     try
     {
         if (data == null)
         {
             Debugger.LogWarning("Can not convert null to long.");
             return(defaultValue);
         }
         if (data is string)
         {
             string dataStr = data.ToString();
             return(StringParser.StringToLong(dataStr, defaultValue));
         }
         return(Convert.ToInt64(data));
     }
     catch (Exception e)
     {
         Debugger.LogError(string.Format("Can not convert {0} to long with {1}", data, e.GetType().Name));
     }
     return(defaultValue);
 }
Ejemplo n.º 13
0
 public static bool ObjectToBool(object data, bool defaultValue = false)
 {
     try
     {
         if (data == null)
         {
             Debugger.LogWarning("Can not convert null to bool.");
             return(defaultValue);
         }
         if (data is string)
         {
             string dataStr = data.ToString();
             return(StringParser.StringToBool(dataStr, defaultValue));
         }
         return(Convert.ToBoolean(data));
     }
     catch (Exception e)
     {
         Debugger.LogError(string.Format("Can not convert {0} to bool with {1}", data, e.GetType().Name));
     }
     return(defaultValue);
 }
Ejemplo n.º 14
0
        public static void FlushVesselCache(string unloadedSeed, Guid unloadIgnoreID)
        {
            // Save a snapshot
            PersistenceGenerator.SaveSnapshot(unloadedSeed);
            // Cache the current system
            Vessel[]      allVessels         = GameObject.FindObjectsOfType <Vessel> ();
            List <Vessel> unclearableVessels = new List <Vessel> ();

            // Despawn all vessels
            Debugger.Log(allVessels.Length + " vessels need to be despawed.");
            if (unloadIgnoreID != Guid.Empty)
            {
                Debugger.Log("Vessel with ID " + unloadIgnoreID.ToString() + " will be ignored.");
            }
            for (int i = 0; i < allVessels.Length; i++)
            {
                Vessel vessel = allVessels [i];
                // Clear the vessel unless we are asked to ignore it
                if (vessel.id != unloadIgnoreID || unloadIgnoreID == Guid.Empty)
                {
                    vesselSeeds [vessel.id] = unloadedSeed;
                    if (!RemoveVesselFromSystem(vessel))
                    {
                        Debugger.LogWarning("Could not unload " + vessel.name);
                        unclearableVessels.Add(vessel);
                    }
                }
            }
            // Clear the vessel cache
            FlightGlobals.Vessels.Clear();
            HighLogic.CurrentGame.flightState.protoVessels.Clear();
            // If we couldn't unload something, ensure it's not duplicated
            foreach (Vessel vessel in unclearableVessels)
            {
                FlightGlobals.Vessels.Add(vessel);
                HighLogic.CurrentGame.flightState.protoVessels.Add(vessel.BackupVessel());
            }
        }
Ejemplo n.º 15
0
 // Assumes that the callback exists (because it was previously checked).
 // Returns TRUE in case of success, FALSE in case of error (if safeMode is on)
 internal static bool OnTweenCallback(TweenCallback callback, Tween t)
 {
     if (DOTween.useSafeMode)
     {
         try {
             callback();
         } catch (Exception e) {
             if (Debugger.logPriority >= 1)
             {
                 Debugger.LogWarning(string.Format(
                                         "An error inside a tween callback was silently taken care of ({0}) ► {1}\n\n{2}\n\n", e.TargetSite, e.Message, e.StackTrace
                                         ), t);
             }
             DOTween.safeModeReport.Add(SafeModeReport.SafeModeReportType.Callback);
             return(false); // Callback error
         }
     }
     else
     {
         callback();
     }
     return(true);
 }
Ejemplo n.º 16
0
 public static void ClearNonSystemVessels()
 {
     foreach (Vessel v in GameObject.FindObjectsOfType <Vessel>())
     {
         Guid id = v.id;
         if (vesselSeeds.ContainsKey(id))
         {
             string           seed             = vesselSeeds [id];
             PersistentVessel persistentVessel = persistentVessels [id];
             if (persistentVessel.loaded)
             {
                 if (seed != WarpDrive.seedString)
                 {
                     Debugger.LogWarning("Vessel is in the wrong seed!");
                 }
             }
         }
         else
         {
             Debugger.LogError("Vessel loaded but not cached: " + v.vesselName + ", ID: " + id.ToString());
         }
     }
 }
Ejemplo n.º 17
0
    static void Push(List <_MethodBase> list, _MethodBase r)
    {
        string name  = GetMethodName(r.Method);
        int    index = list.FindIndex((p) => { return(GetMethodName(p.Method) == name && CompareMethod(p, r) >= 0); });

        if (index >= 0)
        {
            if (CompareMethod(list[index], r) == 2)
            {
                Debugger.LogWarning("{0}.{1} has been dropped as function {2} more match lua", className, list[index].GetTotalName(), r.GetTotalName());
                list.RemoveAt(index);
                list.Add(r);
                return;
            }
            else
            {
                Debugger.LogWarning("{0}.{1} has been dropped as function {2} more match lua", className, r.GetTotalName(), list[index].GetTotalName());
                return;
            }
        }

        list.Add(r);
    }
Ejemplo n.º 18
0
        public static void CheckUnusedSpritesInMainUI()
        {
            Debugger.LogError("========== Check Unused sprite in main ui ==========");
            Dictionary <string, int> unusedMainUISpriteNamesDic = new Dictionary <string, int>();
            TextAsset mainUIAtlasInfoTextAsset = AssetDatabase.LoadAssetAtPath <TextAsset>("Assets/Res/Atlas/main_ui.txt");

            string[] mainUISpriteInfoStrings = mainUIAtlasInfoTextAsset.text.Split('\n');
            for (int i = 0, count = mainUISpriteInfoStrings.Length; i < count; i++)
            {
                unusedMainUISpriteNamesDic.TryAdd(mainUISpriteInfoStrings[i].Split(';')[0], 0);
            }

            DirectoryInfo uiDirectoryInfo = new DirectoryInfo("Assets/Res/Resources/ui");

            foreach (FileInfo fileInfo in uiDirectoryInfo.GetFiles("*.prefab", SearchOption.AllDirectories))
            {
                string       prefabPath = fileInfo.FullName.Substring(fileInfo.FullName.IndexOf(@"Assets\"));
                GameObject   gameObject = AssetDatabase.LoadAssetAtPath <GameObject>(prefabPath);
                List <Image> images     = new List <Image>();
                gameObject.GetComponentsInChildren <Image>(true, images);
                for (int i = 0, count = images.Count; i < count; i++)
                {
                    if (images[i].sprite != null &&
                        images[i].sprite.texture.name.Equals("main_ui") &&
                        unusedMainUISpriteNamesDic.ContainsKey(images[i].sprite.name))
                    {
                        unusedMainUISpriteNamesDic.Remove(images[i].sprite.name);
                    }
                }
            }

            foreach (string spriteName in unusedMainUISpriteNamesDic.Keys)
            {
                Debugger.LogWarning(spriteName);
            }
            Debugger.LogError("========== Check Unused sprite in main ui ==========");
        }
Ejemplo n.º 19
0
    public static MicroPhoneInput getInstance(GameObject go)
    {
        if (m_instance == null)
        {
            micArray = Microphone.devices;
            if (micArray.Length == 0)
            {
                Debugger.LogWarning("Microphone.devices is null");
            }
            int len = Microphone.devices.Length;
            for (int i = 0; i < len; i++)
            {
                string deviceStr = Microphone.devices[i];
                Debugger.Log("device name = 11 {0}", deviceStr);
            }
            if (micArray.Length == 0)
            {
                Debugger.LogWarning("no mic device");
            }

            m_instance = go.gameObject.AddComponent <MicroPhoneInput>();
        }
        return(m_instance);
    }
Ejemplo n.º 20
0
 static void EditTexture()
 {
     Object[] selectObjs = Selection.objects;
     foreach (Object targetObj in selectObjs)
     {
         if (targetObj != null && targetObj is Texture)
         {
             string          path            = AssetDatabase.GetAssetPath(targetObj);
             TextureImporter textureImporter = AssetImporter.GetAtPath(path) as TextureImporter;
             textureImporter.textureType      = TextureImporterType.Sprite;
             textureImporter.spriteImportMode = SpriteImportMode.Single;
             string[] excisionArray = path.Split('/');
             string   packingTag    = excisionArray[excisionArray.Length - 2];
             textureImporter.spritePackingTag    = packingTag;
             textureImporter.spritePixelsPerUnit = 100;
             textureImporter.filterMode          = FilterMode.Bilinear;
             textureImporter.mipmapEnabled       = false;
             textureImporter.textureFormat       = TextureImporterFormat.AutomaticTruecolor;
             int size;
             try
             {
                 using (FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read))
                 {
                     System.Drawing.Image image = System.Drawing.Image.FromStream(fs);
                     size = image.Width > image.Height ? image.Width : image.Height;
                 }
             }
             catch (Exception e)
             {
                 Console.WriteLine(e);
                 throw;
             }
             int maxSize = size;
             if (size < 32)
             {
                 maxSize = 32;
             }
             else if (32 < size && size < 64)
             {
                 maxSize = 64;
             }
             else if (64 < size && size < 128)
             {
                 maxSize = 128;
             }
             else if (128 < size && size < 256)
             {
                 maxSize = 256;
             }
             else if (256 < size && size < 512)
             {
                 maxSize = 512;
             }
             else if (512 < size && size < 1024)
             {
                 maxSize = 1024;
             }
             else if (1024 < size && size < 2048)
             {
                 maxSize = 2048;
             }
             else if (2048 < size && size < 4096)
             {
                 maxSize = 4096;
             }
             else if (4096 < size && size < 8192)
             {
                 maxSize = 8192;
             }
             else
             {
                 Debugger.LogWarning("Select Texture Not Setting Max Size");
             }
             Debugger.Log("File Path:" + path + "   File Size:" + size + "   Setting MaxSize:" + maxSize + "    Packing Tag:" + packingTag);
             textureImporter.SetPlatformTextureSettings("iPhone", maxSize, TextureImporterFormat.AutomaticTruecolor);
             textureImporter.SetPlatformTextureSettings("Android", maxSize, TextureImporterFormat.AutomaticTruecolor);
             textureImporter.SetPlatformTextureSettings("Standalone", maxSize, TextureImporterFormat.AutomaticTruecolor);
             AssetDatabase.ImportAsset(path);
         }
     }
 }
Ejemplo n.º 21
0
        public static void NameBody(PlanetData planet, bool skipPlanetCheck = false)
        {
            if (planet.IsSun() || planet.solarSystem.IsKerbol())
            {
                return;
            }
            if (!skipPlanetCheck && planetaryBodies.ContainsKey(planet.solarSystem.sunData.planetID))
            {
                // Haven't named all the planets yet, need to do that first
                NamePlanets(planet.solarSystem);
            }
            if (!planetaryBodies.ContainsKey(planet.referenceBodyData.planetID))
            {
                // This would be removed if we are a planet which has already been named
                return;
            }
            string referenceName = planet.referenceBodyData.name;

            if (string.IsNullOrEmpty(referenceName))
            {
                Debugger.LogWarning("Reference name is empty! " +
                                    "Planet: " + planet.planetID + ", " +
                                    "reference body: " + planet.referenceBodyData.name + ", " +
                                    "ID " + planet.referenceBodyData.planetID);
                PlanetData referenceBody = planet.solarSystem.GetPlanetByID(planet.referenceBodyData.planetID);
                referenceName = referenceBody.planet.bodyName;
            }
            // Get list of all "sibling" bodies (bodies orbiting the same reference body)
            PlanetData[] siblingBodies = planetaryBodies [planet.referenceBodyData.planetID];
            int          index         = 0;

            for (int i = 0; i < siblingBodies.Length; i++)
            {
                if (siblingBodies [i].planetID == planet.planetID)
                {
                    index = i;
                    break;
                }
            }
            string name = referenceName + " ";

            if (planet.IsMoon())
            {
                while (index >= romanNumerals.Length)
                {
                    name  += romanNumerals [romanNumerals.Length - 1];
                    index -= romanNumerals.Length;
                }
                name += romanNumerals [index];
            }
            else
            {
                int systemNameIndex = 98;                 // "b" in ASCII
                // Change the letter to match the distance from the sun
                systemNameIndex += index;
                name            += ((char)systemNameIndex);
            }
            planet.solarSystem.NamePlanet(planet.planetID, name);
            planet.name            = name;
            planet.planet.bodyName = name;
        }
Ejemplo n.º 22
0
    static BindType[] GenBindTypes(BindType[] list, bool beDropBaseType = true)
    {
        allTypes = new List <BindType>(list);

        for (int i = 0; i < list.Length; i++)
        {
            if (dropType.IndexOf(list[i].type) >= 0)
            {
                Debug.LogWarning(list[i].type.FullName + " in dropType table, not need to export");
                allTypes.Remove(list[i]);
                continue;
            }
            else if (beDropBaseType && baseType.IndexOf(list[i].type) >= 0)
            {
                Debug.LogWarning(list[i].type.FullName + " is Base Type, not need to export");
                allTypes.Remove(list[i]);
                continue;
            }
            else if (list[i].type.IsEnum)
            {
                continue;
            }

            Type t = list[i].baseType;

            while (t != null)
            {
                if (t.IsInterface)
                {
                    Debugger.LogWarning("{0} has a base type {1} is Interface", list[i].name, t.FullName);
                    list[i].baseType = t.BaseType;
                }
                else if (dropType.IndexOf(t) >= 0)
                {
                    Debugger.LogWarning("{0} has a base type {1} is a drop type", list[i].name, t.FullName);
                    list[i].baseType = t.BaseType;
                }
                else if (!beDropBaseType || baseType.IndexOf(t) < 0)
                {
                    int index = allTypes.FindIndex((bt) => { return(bt.type == t); });

                    if (index < 0)
                    {
                        if (!t.IsAbstract)
                        {
                            Debugger.LogWarning("not defined bindtype for {0}, autogen it, child class is {1}", t.FullName, list[i].name);
                            BindType bt = new BindType(t);
                            allTypes.Add(bt);
                        }
                        else
                        {
                            Debugger.LogWarning("not defined bindtype for {0}, it is abstract class, jump it, child class is {1}", t.FullName, list[i].name);
                            list[i].baseType = t.BaseType;
                        }
                    }
                }

                t = t.BaseType;
            }
        }

        return(allTypes.ToArray());
    }
Ejemplo n.º 23
0
 private void DrawWarningBox(string message)
 {
     EditorGUILayout.HelpBox(message, MessageType.Warning);
     Debugger.LogWarning(message);
 }
Ejemplo n.º 24
0
        private Orbit CreateOrbit(double inclination,
                                  double eccentricity,
                                  double semiMajorAxis,
                                  double longitudeAscendingNode,
                                  double argumentOfPeriapsis,
                                  double meanAnomalyAtEpoch,
                                  double epoch,
                                  Orbit orbit,
                                  CelestialBody referenceBody)
        {
            if (double.IsNaN(inclination))
            {
                inclination = 0;
                Debugger.LogWarning("Inclination not a number!");
            }
            if (double.IsNaN(eccentricity))
            {
                eccentricity = 0;
                Debugger.LogWarning("Eccentricity not a number!");
            }
            if (double.IsNaN(semiMajorAxis))
            {
                semiMajorAxis = referenceBody.Radius + referenceBody.maxAtmosphereAltitude + 10000;
                Debugger.LogWarning("Semi-Major Axis not a number!");
            }
            if (double.IsNaN(longitudeAscendingNode))
            {
                longitudeAscendingNode = 0;
                Debugger.LogWarning("Longitude Ascending Node not a number!");
            }
            if (double.IsNaN(argumentOfPeriapsis))
            {
                argumentOfPeriapsis = 0;
                Debugger.LogWarning("Argument of Periapsis not a number!");
            }
            if (double.IsNaN(meanAnomalyAtEpoch))
            {
                meanAnomalyAtEpoch = 0;
                Debugger.LogWarning("Mean Anomaly at Epoch not a number!");
            }
            if (double.IsNaN(epoch))
            {
                epoch = Planetarium.GetUniversalTime();
                Debugger.LogWarning("Epoch not a number!");
            }
            if (Mathf.Sign((float)eccentricity - 1.0f) == Mathf.Sign((float)semiMajorAxis))
            {
                semiMajorAxis = -semiMajorAxis;
            }
            if (Mathf.Sign((float)semiMajorAxis) >= 0)
            {
                while (meanAnomalyAtEpoch < 0)
                {
                    meanAnomalyAtEpoch += Mathf.PI * 2;
                }
                while (meanAnomalyAtEpoch > Mathf.PI * 2)
                {
                    meanAnomalyAtEpoch -= Mathf.PI * 2;
                }
            }
            if (referenceBody == null)
            {
                Debugger.LogError("Reference body is null!");
                // Cannot proceed with setting orbit
                return(orbit);
            }
            if (solarSystem.debug)
            {
                Debugger.Log("Reference Body: " + referenceBody);
                Debugger.Log("Inclination: " + inclination);
                Debugger.Log("Eccentricity: " + eccentricity);
                Debugger.Log("Semi-Major Axis: " + semiMajorAxis + " (" + (semiMajorAxis / AstroUtils.KERBAL_ASTRONOMICAL_UNIT) + " Kerbin Astronomical Units)");
                Debugger.Log("Longitude of Ascending Node: " + longitudeAscendingNode);
                Debugger.Log("Argument of Periapsis: " + argumentOfPeriapsis);
                Debugger.Log("Mean Anomaly at Epoch: " + meanAnomalyAtEpoch);
                Debugger.Log("Epoch: " + epoch);
            }
            Orbit newOrbit = new Orbit(inclination, eccentricity, semiMajorAxis, longitudeAscendingNode, argumentOfPeriapsis, meanAnomalyAtEpoch, epoch, referenceBody);

            return(newOrbit);
        }
    static int LogWarning(IntPtr L)
    {
        int count = LuaDLL.lua_gettop(L);

        if (count == 1 && ToLua.CheckTypes(L, 1, typeof(string)))
        {
            string arg0 = ToLua.ToString(L, 1);

            try
            {
                Debugger.LogWarning(arg0);
            }
            catch (Exception e)
            {
                return(LuaDLL.toluaL_exception(L, e));
            }

            return(0);
        }
        else if (count == 1 && ToLua.CheckTypes(L, 1, typeof(object)))
        {
            object arg0 = ToLua.ToVarObject(L, 1);

            try
            {
                Debugger.LogWarning(arg0);
            }
            catch (Exception e)
            {
                return(LuaDLL.toluaL_exception(L, e));
            }

            return(0);
        }
        else if (count == 2 && ToLua.CheckTypes(L, 1, typeof(string), typeof(object)))
        {
            string arg0 = ToLua.ToString(L, 1);
            object arg1 = ToLua.ToVarObject(L, 2);

            try
            {
                Debugger.LogWarning(arg0, arg1);
            }
            catch (Exception e)
            {
                return(LuaDLL.toluaL_exception(L, e));
            }

            return(0);
        }
        else if (count == 3 && ToLua.CheckTypes(L, 1, typeof(string), typeof(object), typeof(object)))
        {
            string arg0 = ToLua.ToString(L, 1);
            object arg1 = ToLua.ToVarObject(L, 2);
            object arg2 = ToLua.ToVarObject(L, 3);

            try
            {
                Debugger.LogWarning(arg0, arg1, arg2);
            }
            catch (Exception e)
            {
                return(LuaDLL.toluaL_exception(L, e));
            }

            return(0);
        }
        else if (count == 4 && ToLua.CheckTypes(L, 1, typeof(string), typeof(object), typeof(object), typeof(object)))
        {
            string arg0 = ToLua.ToString(L, 1);
            object arg1 = ToLua.ToVarObject(L, 2);
            object arg2 = ToLua.ToVarObject(L, 3);
            object arg3 = ToLua.ToVarObject(L, 4);

            try
            {
                Debugger.LogWarning(arg0, arg1, arg2, arg3);
            }
            catch (Exception e)
            {
                return(LuaDLL.toluaL_exception(L, e));
            }

            return(0);
        }
        else if (ToLua.CheckTypes(L, 1, typeof(string)) && ToLua.CheckParamsType(L, typeof(object), 2, count - 1))
        {
            string   arg0 = ToLua.ToString(L, 1);
            object[] arg1 = ToLua.ToParamsObject(L, 2, count - 1);

            try
            {
                Debugger.LogWarning(arg0, arg1);
            }
            catch (Exception e)
            {
                return(LuaDLL.toluaL_exception(L, e));
            }

            return(0);
        }
        else
        {
            LuaDLL.luaL_error(L, "invalid arguments to method: Debugger.LogWarning");
        }

        return(0);
    }
Ejemplo n.º 26
0
    static void AutoAddBaseType(BindType bt, bool beDropBaseType)
    {
        Type t = bt.baseType;

        if (t == null)
        {
            return;
        }

        if (WrapList.sealedList.Contains(t))
        {
            WrapList.sealedList.Remove(t);
            Debugger.LogError("{0} not a sealed class, it is parent of {1}", LuaMisc.GetTypeName(t), bt.name);
        }

        if (t.IsInterface)
        {
            Debugger.LogWarning("{0} has a base type {1} is Interface, use SetBaseType to jump it", bt.name, t.FullName);
            bt.baseType = t.BaseType;
        }
        else if (dropType.IndexOf(t) >= 0)
        {
            Debugger.LogWarning("{0} has a base type {1} is a drop type", bt.name, t.FullName);
            bt.baseType = t.BaseType;
        }
        else if (!beDropBaseType || baseType.IndexOf(t) < 0)
        {
            int index = allTypes.FindIndex((iter) => { return(iter.type == t); });

            if (index < 0)
            {
#if JUMP_NODEFINED_ABSTRACT
                if (t.IsAbstract && !t.IsSealed)
                {
                    Debugger.LogWarning("not defined bindtype for {0}, it is abstract class, jump it, child class is {1}", LuaMisc.GetTypeName(t), bt.name);
                    bt.baseType = t.BaseType;
                }
                else
                {
                    Debugger.LogWarning("not defined bindtype for {0}, autogen it, child class is {1}", LuaMisc.GetTypeName(t), bt.name);
                    bt = new BindType(t);
                    allTypes.Add(bt);
                }
#else
                Debugger.LogWarning("not defined bindtype for {0}, autogen it, child class is {1}", LuaMisc.GetTypeName(t), bt.name);
                bt = new BindType(t);
                allTypes.Add(bt);
#endif
            }
            else
            {
                return;
            }
        }
        else
        {
            return;
        }

        AutoAddBaseType(bt, beDropBaseType);
    }
Ejemplo n.º 27
0
        /// <summary>
        /// Localize the specified value.
        /// </summary>

        static public string Get(string key)
        {
            // Ensure we have a language to work with
            if (!localizationHasBeenSet)
            {
                LoadDictionary(PlayerPrefs.GetString("Language", "English"));
            }

            if (mLanguages == null)
            {
                Debugger.LogError("No localization data present");
                return(null);
            }

            string lang = language;

            if (mLanguageIndex == -1)
            {
                for (int i = 0; i < mLanguages.Length; ++i)
                {
                    if (mLanguages[i] == lang)
                    {
                        mLanguageIndex = i;
                        break;
                    }
                }
            }

            if (mLanguageIndex == -1)
            {
                mLanguageIndex = 0;
                mLanguage      = mLanguages[0];
                Debugger.LogWarning("Language not found: " + lang);
            }

            string val;

            string[] vals;

#if !UNITY_IPHONE && !UNITY_ANDROID && !UNITY_WP8 && !UNITY_BLACKBERRY
            //		if (UICamera.currentScheme == UICamera.ControlScheme.Touch)
#endif
            {
                string mobKey = key + " Mobile";

                if (mLanguageIndex != -1 && mDictionary.TryGetValue(mobKey, out vals))
                {
                    if (mLanguageIndex < vals.Length)
                    {
                        return(vals[mLanguageIndex]);
                    }
                }
                if (mOldDictionary.TryGetValue(mobKey, out val))
                {
                    return(val);
                }
            }

            if (mLanguageIndex != -1 && mDictionary.TryGetValue(key, out vals))
            {
//				Common.UI.Components.FontCacheText.instance.CheckIfNeedToAddNewWords(vals[0]);
                if (mLanguageIndex < vals.Length)
                {
                    string s = vals[mLanguageIndex];
                    if (string.IsNullOrEmpty(s))
                    {
                        s = vals[0];
                    }
                    return(s);
                }
                return(vals[0]);
            }
            if (mOldDictionary.TryGetValue(key, out val))
            {
//				Common.UI.Components.FontCacheText.instance.CheckIfNeedToAddNewWords(val);
                return(val);
            }

#if UNITY_EDITOR
            Debugger.LogWarning("Localization key not found: '" + key + "' for language " + lang);
#endif
            return(key);
        }
Ejemplo n.º 28
0
    /// <summary>
    /// 初始化预加载
    /// </summary>
    public IEnumerator InitPreLoad(Action finish)
    {
        bool   isFinishMap  = false;
        string assetMapName = (!isBundle ? "dev" : "") + AppPathUtils.AssetBundleMap;

        yield return(AppInter.StartCoroutine(AsyncLoadAtPath(assetMapName, EAssetBaseType.Text, (obj) =>
        {
            string[] assetArr = ((string)obj).Split('\n');
            int chunkIndex = 0;

            foreach (string assetInfo in assetArr)
            {
                string asset = assetInfo.Trim();
                if (string.IsNullOrEmpty(asset))
                {
                    continue;
                }

                if (asset == AppPathUtils.AssetForMap)
                {
                    chunkIndex = 1;
                    continue;
                }

                string[] fileInfos = asset.Split(';');
                string assetType = fileInfos[0];

                string fileName = Path.GetFileName(fileInfos[1]);   //去掉目录
                fileName = fileName.Replace(".", "_" + assetType + ".");

                if (chunkIndex == 0)
                {
                    if (isBundle)
                    {
                        nameToPathMap[fileName] = fileInfos[2]; //fileInfos[2] -> Md5值
                    }
                    else
                    {
                        string srcfileName = Path.GetFileName(fileInfos[2]);
                        nameToPathMap[srcfileName + assetType] = fileInfos[2];
                    }
                }
                else if (chunkIndex == 1)
                {
                    string bundleName = Path.GetFileName(fileInfos[2]); //去掉目录
                    pathToBundleMap[fileName] = bundleName;
                }
            }
            isFinishMap = true;
        })));

        while (!isFinishMap)
        {
            yield return(null);
        }

        if (isBundle)
        {
            //加载assetBundleManifest
            yield return(AppInter.StartCoroutine(AsyncLoadBundleAtPath("bin_none" + AppPathUtils.BundleSuffix, (bundle) =>
            {
                if (bundle != null)
                {
                    Debugger.LogWarning("<<AssetLoader , InitPreLoad>> Cant find AssetBundleManifest");
                    return;
                }
                manifest = bundle.LoadAsset <AssetBundleManifest>("AssetBundleManifest");
            })));
        }

        if (finish != null)
        {
            finish.Invoke();
        }

        Debugger.Log("AssetLoader , InitPreload is finish ");
    }
Ejemplo n.º 29
0
    //    /// <summary>
    //    /// 从缓存中获取资源
    //    /// </summary>
    //    /// <param name="poolName">缓存池的名称</param>
    //    /// <param name="path">资源相对路径</param>
    //    /// <param name="callback">加载完成的回调</param>
    //    public void SwapAssetAtPath(string poolName , string path , Action<UnityEngine.Object> callback)
    //    {
    //        ARCCache<string, AssetBundle> cachePool = swapnCachePool(poolName);
    //        AssetBundle bundle = cachePool.Get(path);
    //        if (bundle != null)
    //        {
    //            if (callback != null)
    //                callback(bundle.mainAsset);
    //            return;
    //        }
    //
    //        //异步加载
    //        AppInter.StartCoroutine(AsyncLoadAtPath(path,EAssetBaseType.AssetBundle, (obj) =>
    //        {
    //            bundle = obj as AssetBundle;
    //            if (bundle == null)
    //            {
    //                Debugger.LogWarning("<<AssetLoader , SwapAsset>> load faile !  Path -->> " + path);
    //                return;
    //            }
    //            cachePool.Put(path , bundle);
    //
    //            if(callback != null)
    //                callback(bundle.mainAsset);
    //        }));
    //    }

    /// <summary>
    /// 从AssetBundle缓存中获取资源
    /// </summary>
    /// <param name="poolName">缓存池的名称</param>
    /// <param name="resName">资源名</param>
    /// <param name="callback">加载完成的回调</param>
    public IEnumerator SwapAssetByName <T>(string poolName, string resName, EAssetType assetType,
                                           Action <UnityEngine.Object> callback, Action <float, float> progress)
        where T : UnityEngine.Object
    {
        ARCCache <string, Asset> cachePool = swapnCachePool(poolName);
        string bundleName = GetBundleName(resName, assetType);

        if (string.IsNullOrEmpty(bundleName))
        {
            callback.Invoke(null);
            Debugger.LogWarning("<<AssetLoader , SwapAssetByName>> load faile !  Res -->> " + resName);
            yield break;
        }

        Asset bundle = cachePool.Get(bundleName);

#if UNITY_EDITOR
        if (!isBundle)
        {
            if (bundle == null)
            {
                string             path = GetBundleEncrypeName(resName + assetType.ToString().ToLower());
                UnityEngine.Object obj  = AssetDatabase.LoadAssetAtPath <T>(path);
                if (obj == null)
                {
                    Debugger.LogWarning("<<AssetLoader , SwapAssetByName>> load faile !  Path -->> " + path);
                    callback.Invoke(obj);
                    yield break;
                }

                bundle = new Asset(bundleName, obj);
                cachePool.Put(bundleName, bundle);
            }
            callback.Invoke(bundle.Resource);
            yield break;
        }
#endif

        if (bundle != null)
        {
            if (callback != null)
            {
                callback(bundle.Get <AssetBundle>().LoadAsset <T>(resName));
            }
            yield break;
        }
        //异步加载
        yield return(AppInter.StartCoroutine(loadBundleAndDependenices(cachePool, bundleName, (obj) =>
        {
            if (obj == null)
            {
                Debugger.LogWarning("<<AssetLoader , SwapAssetByName>> load faile !  Path -->> " + bundleName);
                callback.Invoke(null);
                return;
            }

            Asset asset = new Asset(bundleName, obj);
            cachePool.Put(bundleName, asset);

            if (callback != null)
            {
                callback(obj.LoadAsset <T>(resName));
            }
        }, progress)));
    }
Ejemplo n.º 30
0
 public static void Warning(string str)
 {
     Debugger.LogWarning(str);
 }