コード例 #1
0
 protected void ReportAutoDisable()
 {
     if (GLog.IsLogWarningEnabled)
     {
         GLog.LogWarning("The image effect " + ToString() + " has been disabled as it's not supported on the current platform.");
     }
 }
コード例 #2
0
 /// <summary>
 /// 断开
 /// </summary>
 private void _close()
 {
     _isInitThreadStart = false;
     try
     {
         if (_clientSocket != null)
         {
             _clientSocket.Shutdown(SocketShutdown.Both);
             _clientSocket.Close();
         }
     }
     catch (Exception e)
     {
         if (GLog.IsLogErrorEnabled)
         {
             GLog.LogException("socket 关闭 _clientSocket :" + e.Message);
         }
     }
     _clientSocket = null;
     CloseThread(_receiveThread);
     _receiveThread = null;
     CloseThread(_connectThread);
     _connectThread           = null;
     _currDispatchSocketState = SocketState.NONE;
     if (GLog.IsLogWarningEnabled)
     {
         GLog.LogWarning("socket 关闭完成");
     }
 }
コード例 #3
0
    public static List <string> GetTexturePathsInDirectory(string directoryPath)
    {
        if (texturePathsCache.ContainsKey(directoryPath))
        {
            return(texturePathsCache[directoryPath]);
        }

        DirectoryInfo directoryInfo = new DirectoryInfo(directoryPath);

        if (!directoryInfo.Exists)
        {
            if (GLog.IsLogWarningEnabled)
            {
                GLog.LogWarning(directoryPath + " doesn't exist, please check directory path.");
            }
            return(null);
        }

        var           fileInfos    = directoryInfo.GetFiles("*.*", SearchOption.TopDirectoryOnly);
        List <string> texturePaths = new List <string>();

        foreach (var fileInfo in fileInfos)
        {
            if (textureExtensions.Contains(fileInfo.Extension))
            {
                string filePath = fileInfo.FullName;
                texturePaths.Add(filePath.Substring(Application.dataPath.Length - "Assets".Length)
                                 .Replace('\\', '/'));
            }
        }
        texturePathsCache[directoryPath] = texturePaths;

        return(texturePaths);
    }
コード例 #4
0
    public static bool CreatePlayer(string category, bool ignoreClear = false)
    {
        if (playerMap.ContainsKey(category))
        {
            if (GLog.IsLogWarningEnabled)
            {
                GLog.LogWarning("Audio Player '" + category + "' already created! Returning original player!");
            }
            return(false);
        }

        // Create new Audio Player
        var go = new GameObject("AudioPlayer " + category, typeof(AudioSource), typeof(AudioPlayer));

        ResManager.DontDestroyOnLoad(go);
        if (!ignoreClear)
        {
            ResManager.CanDestroyAll(go);
        }

        var audioPlayer = go.GetComponent <AudioPlayer>();

        audioPlayer.Category     = category;
        audioPlayer.GlobalVolume = 1f;
        playerMap.Add(category, audioPlayer);

        return(true);
    }
コード例 #5
0
ファイル: Debugger.cs プロジェクト: SilasDarkmoon/CapsMVC
 public static void LogWarning(object message)
 {
     if (GLog.IsLogWarningEnabled)
     {
         GLog.LogWarning("DOTWEEN :: " + message);
     }
 }
コード例 #6
0
    LightmapData[] LoadLightmaps()
    {
        if (lightingScenariosData.lightmaps == null ||
            lightingScenariosData.lightmaps.Length == 0)
        {
            if (GLog.IsLogWarningEnabled)
            {
                GLog.LogWarning("No lightmaps stored in scenario ");
            }
            return(null);
        }

        var newLightmaps = new LightmapData[lightingScenariosData.lightmaps.Length];

        for (int i = 0; i < newLightmaps.Length; i++)
        {
            newLightmaps[i] = new LightmapData();
            newLightmaps[i].lightmapColor = lightingScenariosData.lightmaps[i];

            if (lightingScenariosData.lightmapsMode != LightmapsMode.NonDirectional)
            {
                newLightmaps[i].lightmapDir = lightingScenariosData.lightmapsDir[i];
            }
        }
        return(newLightmaps);
    }
コード例 #7
0
    public Dictionary <string, object> ToDictionaryOfObj()
    {
        if (type == Type.OBJECT)
        {
            Dictionary <string, object> result = new Dictionary <string, object>();
            for (int i = 0; i < list.Count; i++)
            {
                JSONObject val = list[i];
                switch (val.type)
                {
                case Type.STRING: result.Add(keys[i], val.str); break;

                case Type.NUMBER: result.Add(keys[i], val.n); break;

                case Type.BOOL: result.Add(keys[i], val.b); break;

                case Type.NULL: result.Add(keys[i], null); break;

                default: if (GLog.IsLogWarningEnabled)
                    {
                        GLog.LogWarning("Omitting object: " + keys[i] + " in dictionary conversion");
                    }
                    break;
                }
            }
            return(result);
        }
        if (GLog.IsLogWarningEnabled)
        {
            GLog.LogWarning("Tried to turn non-Object JSONObject into a dictionary");
        }
        return(null);
    }
コード例 #8
0
 public virtual bool CheckResources()
 {
     if (GLog.IsLogWarningEnabled)
     {
         GLog.LogWarning("CheckResources () for " + ToString() + " should be overwritten.");
     }
     return(isSupported);
 }
コード例 #9
0
 /// <summary>
 /// 重连
 /// </summary>
 private void _ReConnect()
 {
     if (GLog.IsLogErrorEnabled)
     {
         GLog.LogWarning("socket 断开重连。。。");
     }
     _close();
     _onConnetThread();
 }
コード例 #10
0
    /// <summary>
    /// 移除指定位置的一条数据
    /// </summary>
    /// <param name="index">要移除的数据的位置</param>
    public virtual void RemoveDataAt(int index)
    {
        if (null == datas)
        {
            GLog.LogWarning("Failed to remove data at " + index + "because scroll list doesn't has any data");
            return;
        }

        datas.RemoveAt(index);
        CalculateSize(index);
    }
コード例 #11
0
 public static int ClrFuncPrintWarning(IntPtr l)
 {
     using (var lr = new LuaStateRecover(l))
     {
         var obj = l.GetLua(1).UnwrapDynamic();
         if (GLog.IsLogWarningEnabled)
         {
             GLog.LogWarning(obj);
         }
     }
     return(0);
 }
コード例 #12
0
        public static void InitData()
        {
            langDict.Clear();

            string jsonText = null;
            // 该路径下的语言包是为了翻译公司可以方便查看翻译后的效果
            string topPriorityJsonPath = Path.Combine(Application.persistentDataPath, "languagePack.json");

            if (File.Exists(topPriorityJsonPath))
            {
                jsonText = File.ReadAllText(topPriorityJsonPath);
            }
            else
            {
                TextAsset jsonAsset = ResManager.LoadRes(JSONPATH, typeof(TextAsset)) as TextAsset;

                if (jsonAsset != null)
                {
                    jsonText = jsonAsset.text;
                }
            }

            if (string.IsNullOrEmpty(jsonText))
            {
                return;
            }

            JSONObject json = new JSONObject(jsonText);

            for (int i = 0, len = json.list.Count; i < len; i++)
            {
                string key = json.keys[i];
                string val = json.list[i].str;

                if (langDict.ContainsKey(key))
                {
                    if (GLog.IsLogWarningEnabled)
                    {
                        GLog.LogWarning(string.Format("Dupliciate key in langDict: {0}", key));
                    }
                }
                else
                {
                    langDict.Add(key, val);
                }
            }

            isInitialized = true;
        }
コード例 #13
0
    public static void DestroyPlayer(string category)
    {
        if (!playerMap.ContainsKey(category))
        {
            if (GLog.IsLogWarningEnabled)
            {
                GLog.LogWarning("Audio Player '" + category + "' not exist!");
            }
            return;
        }
        if (playerMap[category])
        {
            playerMap[category].Stop();
            Object.Destroy(playerMap[category]);
        }

        playerMap.Remove(category);
    }
コード例 #14
0
 public static void RemoveInstance <T> () where T : class, new ()
 {
     if (m_Container != null && m_SingletonMap.ContainsKey(typeof(T).ToString()))
     {
         string      name    = typeof(T).ToString();
         IDisposable dispose = m_SingletonMap[name] as IDisposable;
         if (null != dispose)
         {
             dispose.Dispose();
         }
         if (typeof(T).IsSubclassOf(typeof(Component)))
         {
             UnityEngine.Object.Destroy(m_SingletonMap[name] as UnityEngine.Component);
         }
         m_SingletonMap.Remove(name);
         GLog.LogWarning("Singleton REMOVE! (" + name + ")");
     }
 }
コード例 #15
0
 /// <summary>
 /// For capslua call xlua, TODO: REMOVE AFTER CAPSLUA IS DELETED
 /// </summary>
 public object[] CallLuaFunc(string funcName, params object[] args)
 {
     if (lua != null)
     {
         var func = lua.Get <LuaFunction>(funcName);
         if (func != null)
         {
             return(func.Call(lua, args));
         }
         else
         {
             if (GLog.IsLogWarningEnabled)
             {
                 GLog.LogWarning("Cannot find lua function '" + funcName + "'.");
             }
         }
     }
     return(null);
 }
コード例 #16
0
 private void DispatchCheckSocketState()
 {
     if (_currDispatchSocketState == _currSocketState || _luaCallback == null)
     {
         return;
     }
     try
     {
         if (GLog.IsLogWarningEnabled)
         {
             GLog.LogWarning("socket DispatchCheckSocketState 派发事件 currDispatchSocketState :[" + _currDispatchSocketState + "]  _currSocketState :" + _currSocketState);
         }
         _currDispatchSocketState = _currSocketState;
         _luaCallback((int)_currSocketState);
     }
     catch (Exception e)
     {
         GLog.LogException("DispatchCheckSocketState ==> " + e.Message);
     }
 }
コード例 #17
0
    public void SelectDefaultToggle(int tag)
    {
        m_cache_tag          = tag;
        isTriggerLuaListener = false;
        LuaTable lua = gameObject.GetComponent <LuaBehaviour>().lua;

        for (int i = 0; i < Toggles.Count; i++)
        {
            int        toggleTag = i + 1;
            GameObject obj       = Toggles[i];
            LuaTable   btnLua    = obj.GetComponent <LuaBehaviour>().lua;
            if (btnLua == null)
            {
                if (GLog.IsLogWarningEnabled)
                {
                    GLog.LogWarning("CommonToggle.SelectDefaultToggle: btnLua is null !!!");
                }
            }
            if (toggleTag == tag)
            {
                obj.GetComponent <Toggle>().isOn = true;
                if (onToggleSelected != null)
                {
                    onToggleSelected(lua, btnLua, tag);
                }
                if (onTagSwitched != null)
                {
                    onTagSwitched(lua, tag);
                }
            }
            else
            {
                obj.GetComponent <Toggle>().isOn = false;
                if (onToggleDeselected != null)
                {
                    onToggleDeselected(lua, btnLua, tag);
                }
            }
        }
        isTriggerLuaListener = true;
    }
コード例 #18
0
    public static Color ParseColorString(string colorString)
    {
        if (string.IsNullOrEmpty(colorString))
        {
            if (GLog.IsLogWarningEnabled)
            {
                GLog.LogWarning("colorString is null or empty");
            }
            return(Color.black);
        }

        string[] rgba = colorString.Split(',');

        if (rgba.Length == 3)
        {
            return(new Color(float.Parse(rgba[0]), float.Parse(rgba[1]), float.Parse(rgba[2])));
        }
        else if (rgba.Length == 4)
        {
            return(new Color(float.Parse(rgba[0]), float.Parse(rgba[1]), float.Parse(rgba[2]), float.Parse(rgba[3])));
        }

        throw new Exception("Illegal color string length!");
    }
コード例 #19
0
 public static JSONObject TOJSON(object obj)                 //For a generic guess
 {
     if (touched.Add(obj))
     {
         JSONObject result = JSONObject.obj;
         //Fields
         FieldInfo[] fieldinfo = obj.GetType().GetFields();
         foreach (FieldInfo fi in fieldinfo)
         {
             JSONObject val = JSONObject.nullJO;
             if (!fi.GetValue(obj).Equals(null))
             {
                 MethodInfo info = typeof(JSONTemplates).GetMethod("From" + fi.FieldType.Name);
                 if (info != null)
                 {
                     object[] parms = new object[1];
                     parms[0] = fi.GetValue(obj);
                     val      = (JSONObject)info.Invoke(null, parms);
                 }
                 else if (fi.FieldType == typeof(string))
                 {
                     val = JSONObject.CreateStringObject(fi.GetValue(obj).ToString());
                 }
                 else
                 {
                     val = JSONObject.Create(fi.GetValue(obj).ToString());
                 }
             }
             if (val)
             {
                 if (val.type != JSONObject.Type.NULL)
                 {
                     result.AddField(fi.Name, val);
                 }
                 else if (GLog.IsLogWarningEnabled)
                 {
                     GLog.LogWarning("Null for this non-null object, property " + fi.Name + " of class " + obj.GetType().Name + ". Object type is " + fi.FieldType.Name);
                 }
             }
         }
         //Properties
         PropertyInfo[] propertyInfo = obj.GetType().GetProperties();
         foreach (PropertyInfo pi in propertyInfo)
         {
             //This section should mirror part of AssetFactory.AddScripts()
             JSONObject val = JSONObject.nullJO;
             if (!pi.GetValue(obj, null).Equals(null))
             {
                 MethodInfo info = typeof(JSONTemplates).GetMethod("From" + pi.PropertyType.Name);
                 if (info != null)
                 {
                     object[] parms = new object[1];
                     parms[0] = pi.GetValue(obj, null);
                     val      = (JSONObject)info.Invoke(null, parms);
                 }
                 else if (pi.PropertyType == typeof(string))
                 {
                     val = JSONObject.CreateStringObject(pi.GetValue(obj, null).ToString());
                 }
                 else
                 {
                     val = JSONObject.Create(pi.GetValue(obj, null).ToString());
                 }
             }
             if (val)
             {
                 if (val.type != JSONObject.Type.NULL)
                 {
                     result.AddField(pi.Name, val);
                 }
                 else if (GLog.IsLogWarningEnabled)
                 {
                     GLog.LogWarning("Null for this non-null object, property " + pi.Name + " of class " + obj.GetType().Name + ". Object type is " + pi.PropertyType.Name);
                 }
             }
         }
         return(result);
     }
     if (GLog.IsLogWarningEnabled)
     {
         GLog.LogWarning("trying to save the same data twice");
     }
     return(JSONObject.nullJO);
 }
コード例 #20
0
    public void OnSceneGUI()
    {
        Lightbeam lightBeam = (target as Lightbeam);

        if (lightBeam.IsModifyingMesh == true && IsLightBeamMesh() == false)
        {
            if (GLog.IsLogWarningEnabled)
            {
                GLog.LogWarning("Exited lightbeam modification mode. No valid lightbeam mesh was found.");
            }
            lightBeam.IsModifyingMesh = false;
        }

        if (Event.current.type == EventType.ValidateCommand)
        {
            if (Event.current.commandName == "UndoRedoPerformed")
            {
                if (IsLightBeamMesh())
                {
                    lightBeam.GenerateBeam();
                }
            }
        }

        if (lightBeam.IsModifyingMesh)
        {
            // Register the undos when we press the Mouse button.
            if (Event.current.type == EventType.MouseDown && Event.current.button == 0)
            {
                Undo.SetSnapshotTarget(lightBeam.Settings, "Modify Lightbeam Mesh");
                Undo.CreateSnapshot();
                Undo.RegisterSnapshot();
                Undo.ClearSnapshotTarget();
            }

            // red radius circles
            Handles.matrix = lightBeam.transform.localToWorldMatrix;
            Handles.color  = Color.black;
            Handles.DrawWireDisc(new Vector3(0, -lightBeam.Length, 0), Vector3.up, lightBeam.RadiusBottom);
            Handles.DrawWireDisc(Vector3.zero, Vector3.up, lightBeam.RadiusTop);

            // handle positions and sizes
            Vector3 rTopPos     = new Vector3(-lightBeam.RadiusTop, 0, 0);
            Vector3 rBottomPos  = new Vector3(-lightBeam.RadiusBottom, -lightBeam.Length, 0);
            Vector3 lengthPos   = new Vector3(0, -lightBeam.Length, 0);
            float   rTopSize    = HandleUtility.GetHandleSize(lightBeam.transform.TransformDirection(rTopPos));
            float   rBottomSize = HandleUtility.GetHandleSize(lightBeam.transform.TransformDirection(rBottomPos));
            float   lengthSize  = HandleUtility.GetHandleSize(lightBeam.transform.TransformDirection(lengthPos));

            // yellow radius handles
            Handles.color          = Color.yellow;
            lightBeam.RadiusTop    = Handles.ScaleValueHandle(lightBeam.RadiusTop, rTopPos, Quaternion.identity, rTopSize, Handles.CylinderCap, 2);
            lightBeam.RadiusBottom = Handles.ScaleValueHandle(lightBeam.RadiusBottom, rBottomPos, Quaternion.identity, rBottomSize, Handles.CylinderCap, 2);
            lightBeam.Length       = Handles.ScaleValueHandle(lightBeam.Length, lengthPos, Quaternion.Euler(Vector3.up), lengthSize, Handles.CubeCap, 0);

            if (lightBeam.RadiusTop <= 0.01f)
            {
                lightBeam.RadiusTop = 0.01f;
            }
            if (lightBeam.RadiusBottom <= 0.01f)
            {
                lightBeam.RadiusBottom = 0.01f;
            }

            if (GUI.changed)
            {
                lightBeam.GenerateBeam();
                EditorUtility.SetDirty(lightBeam);
            }
        }
    }
コード例 #21
0
 public static void LogWarning(this object obj)
 {
     GLog.LogWarning(obj);
 }
コード例 #22
0
    public override void OnInspectorGUI()
    {
        EditorGUIUtility.LookLikeInspector();
        Lightbeam lightBeam = (target as Lightbeam);

        if (lightBeam.IsModifyingMesh == true && IsLightBeamMesh() == false)
        {
            if (GLog.IsLogWarningEnabled)
            {
                GLog.LogWarning("Escaped lightbeam modification mode. No valid lightbeam mesh was found.");
            }
            lightBeam.IsModifyingMesh = false;
        }

        if (lightBeam.IsModifyingMesh == false)
        {
            EditorGUILayout.BeginHorizontal();
            if (IsLightBeamMesh())
            {
                if (GUILayout.Button(new GUIContent("Modify", "Modify the lightbeam mesh.")))
                {
                    Undo.RegisterUndo(lightBeam, "Modify light beam");
                    ModifyMesh(lightBeam);
                    EditorUtility.SetDirty(lightBeam);
                }
            }
            else
            {
                GUI.enabled = false;
                if (GUILayout.Button(new GUIContent("Modify", "Missing a valid lightbeam mesh.")))
                {
                }
                GUI.enabled = true;
            }

            if (GUILayout.Button(new GUIContent("New Lightbeam Mesh", "Create a new lightbeam mesh for this object.")))
            {
                int result = EditorUtility.DisplayDialogComplex("Duplicate material", "Do you want to duplicate the material?\nIf you don't duplicate the same material will be used.", "Yes", "No", "Cancel");

                if (result == 0) // ok
                {
                    Undo.RegisterSceneUndo("New Lightbeam Mesh");
                    SaveNewAsset(lightBeam, true);
                    ModifyMesh(lightBeam);
                    EditorUtility.SetDirty(lightBeam);
                }
                if (result == 1) // no
                {
                    Undo.RegisterSceneUndo("New Lightbeam Mesh");
                    SaveNewAsset(lightBeam, false);
                    ModifyMesh(lightBeam);
                    EditorUtility.SetDirty(lightBeam);
                }
            }
            EditorGUILayout.EndHorizontal();
        }
        else
        {
            EditorGUILayout.BeginVertical();

            string RadiusTopTooltip          = "The top radius of the lightbeam.";
            string RadiusBottomTooltip       = "The bottom radius of the lightbeam.";
            string LengthTooltip             = "Length of the lightbeam.";
            string SubdivisionsTooltip       = "Horizontal Subdivisions\n\nIncreasing this will smoothen the lightbeam by adding vertices.";
            string SubdivisionsHeightTooltip = "Vertical Subdivisions\n\nIncreasing this will smoothen the lightbeam by adding vertices.";

            lightBeam.RadiusTop          = EditorGUILayout.FloatField(new GUIContent("Radius Top", RadiusTopTooltip), lightBeam.RadiusTop);
            lightBeam.RadiusBottom       = EditorGUILayout.FloatField(new GUIContent("Radius Bottom", RadiusBottomTooltip), lightBeam.RadiusBottom);
            lightBeam.Length             = EditorGUILayout.FloatField(new GUIContent("Length", LengthTooltip), lightBeam.Length);
            lightBeam.Subdivisions       = EditorGUILayout.IntSlider(new GUIContent("Subdivisions", SubdivisionsTooltip), lightBeam.Subdivisions, 3, 50);
            lightBeam.SubdivisionsHeight = EditorGUILayout.IntSlider(new GUIContent("Subdivisions Height", SubdivisionsHeightTooltip), lightBeam.SubdivisionsHeight, 1, 10);

            if (lightBeam.RadiusTop <= 0.01f)
            {
                lightBeam.RadiusTop = 0.01f;
            }
            if (lightBeam.RadiusBottom <= 0.01f)
            {
                lightBeam.RadiusBottom = 0.01f;
            }

            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button(new GUIContent("Done", "Finish modifying the lightbeam mesh.")))
            {
                Undo.RegisterUndo(lightBeam, "Finished Modifying Lightbeam Mesh");
                lightBeam.IsModifyingMesh = false;
                EditorUtility.SetDirty(lightBeam);
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.EndVertical();
        }

        if (GUI.changed)
        {
            Undo.SetSnapshotTarget(lightBeam.Settings, "Modify Lightbeam Mesh");
            Undo.CreateSnapshot();
            Undo.RegisterSnapshot();
            lightBeam.GenerateBeam();
            EditorUtility.SetDirty(lightBeam);
        }
    }
コード例 #23
0
    protected override void Awake()
    {
        base.Awake();

        LuaTable lua = gameObject.GetComponent <LuaBehaviour>().lua;

        lua.Get("onToggleSelected", out onToggleSelected);
        lua.Get("onToggleDeselected", out onToggleDeselected);
        lua.Get("onToggleCreated", out onToggleCreated);
        lua.Get("onTagSwitched", out onTagSwitched);
        if (ButtonGroupType == ButtonGroupType.Dynamic)
        {
            Toggles = new List <GameObject>();

            GameObject prefabObj = null;
            if (!string.IsNullOrEmpty(TogglePrefab))
            {
                prefabObj = Capstones.UnityFramework.ResManager.LoadRes(TogglePrefab) as GameObject;
            }

            for (int i = 0; i < TogglesCount; i++)
            {
                var obj = GameObject.Instantiate(prefabObj != null ? prefabObj : ToggleObj, transform);

                if (obj)
                {
                    if (!obj.activeSelf)
                    {
                        if (GLog.IsLogWarningEnabled)
                        {
                            GLog.LogWarning("CommonToggle.Awake: obj is not active !!!");
                        }
                        obj.FastSetActive(true);
                    }

                    Toggles.Add(obj);
                }
            }
        }
        for (int i = 0; i < Toggles.Count; i++)
        {
            int        tag = i + 1;
            GameObject obj = Toggles[i];
            Debug.Assert(obj.GetComponent <UnityEngine.UI.Toggle>(), "Toggle object must has a toggle compoment");
            LuaTable btnLua = obj.GetComponent <LuaBehaviour>().lua;
            if (btnLua == null)
            {
                if (GLog.IsLogWarningEnabled)
                {
                    GLog.LogWarning("CommonToggle.Awake: btnLua is null !!!");
                }
            }
            if (onToggleCreated != null)
            {
                onToggleCreated(lua, btnLua, tag);
            }
            Toggle t = obj.GetComponent <Toggle>();
            t.group          = this;
            t.onValueChanged = new Toggle.ToggleEvent();
            t.onValueChanged.AddListener((bool active) =>
            {
                if (isTriggerLuaListener)
                {
                    LuaTable btnLua2 = Toggles[tag - 1].GetComponent <LuaBehaviour>().lua;
                    if (active)
                    {
                        if (AllowReselect)
                        {
                            m_cache_tag = tag;
                        }
                        else if (tag == m_cache_tag)
                        {
                            return;
                        }
                        else
                        {
                            m_cache_tag = tag;
                        }

                        if (onToggleSelected != null)
                        {
                            onToggleSelected(lua, btnLua2, tag);
                        }
                        if (onTagSwitched != null)
                        {
                            onTagSwitched(lua, tag);
                        }
                    }
                    else
                    {
                        if (onToggleDeselected != null)
                        {
                            onToggleDeselected(lua, btnLua2, tag);
                        }
                    }
                }
            });
        }
    }
コード例 #24
0
ファイル: TweenManager.cs プロジェクト: SilasDarkmoon/CapsMVC
        static void VerifyActiveTweensList()
        {
            int        nullTweensWithinLookup = 0, inactiveTweensWithinLookup = 0, activeTweensAfterNull = 0;
            List <int> activeTweensAfterNullIds = new List <int>();

            for (int i = 0; i < _maxActiveLookupId + 1; ++i)
            {
                Tween t = _activeTweens[i];
                if (t == null)
                {
                    nullTweensWithinLookup++;
                }
                else if (!t.active)
                {
                    inactiveTweensWithinLookup++;
                }
            }
            int len            = _activeTweens.Length;
            int firstNullIndex = -1;

            for (int i = 0; i < len; ++i)
            {
                if (firstNullIndex == -1 && _activeTweens[i] == null)
                {
                    firstNullIndex = i;
                }
                else if (firstNullIndex > -1 && _activeTweens[i] != null)
                {
                    activeTweensAfterNull++;
                    activeTweensAfterNullIds.Add(i);
                }
            }

            if (nullTweensWithinLookup > 0 || inactiveTweensWithinLookup > 0 || activeTweensAfterNull > 0)
            {
                string s = "VerifyActiveTweensList WARNING:";
                if (isUpdateLoop)
                {
                    s += " - UPDATE LOOP (" + updateLoopCount + ")";
                }
                if (nullTweensWithinLookup > 0)
                {
                    s += " - NULL Tweens Within Lookup (" + nullTweensWithinLookup + ")";
                }
                if (inactiveTweensWithinLookup > 0)
                {
                    s += " - Inactive Tweens Within Lookup (" + inactiveTweensWithinLookup + ")";
                }
                if (activeTweensAfterNull > 0)
                {
                    string indexes = "";
                    len = activeTweensAfterNullIds.Count;
                    for (int i = 0; i < len; ++i)
                    {
                        if (i > 0)
                        {
                            indexes += ",";
                        }
                        indexes += activeTweensAfterNullIds[i];
                    }
                    s += " - Active tweens after NULL ones (" + (firstNullIndex - 1) + "/" + activeTweensAfterNull + "[" + indexes + "]" + ")";
                }
                if (GLog.IsLogWarningEnabled)
                {
                    GLog.LogWarning(s);
                }
            }
        }
コード例 #25
0
    public static T getInstance <T> (T obj = default(T)) where T : class, new ()
    {
        if (Application.isPlaying && m_IsDestroying)
        {
            GLog.LogWarning("SingletonObject is mark as Destroy! Can not get instance any more!");
            return(null);
        }
        if (m_Container == null)
        {
#if UNITY_EDITOR
            if (!Application.isPlaying)
            {
                while (true)
                {
                    m_Container = GameObject.Find(m_Name);
                    if (null != m_Container)
                    {
                        GameObject.DestroyImmediate(m_Container);
                    }
                    else
                    {
                        break;
                    }
                }
            }
#endif
            m_Container      = new GameObject();
            m_Container.name = m_Name;
            m_Container.AddComponent(typeof(SingletonObject));
            Debug.Log("Create Singleton from:" + typeof(T).ToString());
        }
        string name = typeof(T).ToString();
        if (!m_SingletonMap.ContainsKey(name))
        {
            if (System.Type.GetType(name) != null)
            {
                if (null != obj)
                {
                    m_SingletonMap.Add(name, obj);
                    if (typeof(T).IsSubclassOf(typeof(Component)))
                    {
                        Component c = obj as Component;
                        DontDestroyOnLoad(c.transform.root.gameObject);
                    }
                }
                else
                {
                    if (typeof(T).IsSubclassOf(typeof(Component)))
                    {
                        // Awake -> Init -> Start -> Update ····
                        m_SingletonMap.Add(name, m_Container.AddComponent(typeof(T)));
                    }
                    else
                    {
                        m_SingletonMap.Add(name, new T());
                    }
                    ISingletonInit sInit = m_SingletonMap[name] as ISingletonInit;
                    if (null != sInit)
                    {
                        sInit.Init();
                    }
                }
            }
            else
            {
                GLog.LogWarning("Singleton Type ERROR! (" + name + ")");
            }
        }
        return(m_SingletonMap[name] as T);
    }
コード例 #26
0
    void Parse(string str, int maxDepth = -2, bool storeExcessLevels = false, bool strict = false)
    {
        if (!string.IsNullOrEmpty(str))
        {
            str = str.Trim(WHITESPACE);
            if (strict)
            {
                if (str[0] != '[' && str[0] != '{')
                {
                    type = Type.NULL;
                    if (GLog.IsLogWarningEnabled)
                    {
                        GLog.LogWarning("Improper (strict) JSON formatting.  First character must be [ or {");
                    }
                    return;
                }
            }
            if (str.Length > 0)
            {
#if (UNITY_WP8 || UNITY_METRO) && !UNITY_EDITOR
                if (str.Length == 4 && string.Compare(str.ToLower(), "true") == 0)
                {
                    type = Type.BOOL;
                    b    = true;
                }
                else if (str.Length == 5 && string.Compare(str.ToLower(), "false") == 0)
                {
                    type = Type.BOOL;
                    b    = false;
                }
                else if (str.Length == 4 && string.Compare(str.ToLower(), "null") == 0)
                {
#else
                if (string.Compare(str, "true", true) == 0)
                {
                    type = Type.BOOL;
                    b    = true;
                }
                else if (string.Compare(str, "false", true) == 0)
                {
                    type = Type.BOOL;
                    b    = false;
                }
                else if (string.Compare(str, "null", true) == 0)
                {
#endif
                    type = Type.NULL;
//#if USEFLOAT
//                } else if(str == INFINITY) {
//                    type = Type.NUMBER;
//                    n = float.PositiveInfinity;
//                } else if(str == NEGINFINITY) {
//                    type = Type.NUMBER;
//                    n = float.NegativeInfinity;
//                } else if(str == NaN) {
//                    type = Type.NUMBER;
//                    n = float.NaN;
//#else
                }
                else if (str == INFINITY)
                {
                    type = Type.NUMBER;
                    n    = double.PositiveInfinity;
                }
                else if (str == NEGINFINITY)
                {
                    type = Type.NUMBER;
                    n    = double.NegativeInfinity;
                }
                else if (str == NaN)
                {
                    type = Type.NUMBER;
                    n    = double.NaN;
//#endif
                }
                else if (str[0] == '"')
                {
                    type     = Type.STRING;
                    this.str = FromJSONString(str.Substring(1, str.Length - 2));
                }
                else
                {
                    int tokenTmp = 1;

                    /*
                     * Checking for the following formatting (www.json.org)
                     * object - {"field1":value,"field2":value}
                     * array - [value,value,value]
                     * value - string	- "string"
                     *		 - number	- 0.0
                     *		 - bool		- true -or- false
                     *		 - null		- null
                     */
                    int offset = 0;
                    switch (str[offset])
                    {
                    case '{':
                        type = Type.OBJECT;
                        keys = new List <string>();
                        list = new List <JSONObject>();
                        break;

                    case '[':
                        type = Type.ARRAY;
                        list = new List <JSONObject>();
                        break;

                    default:
                        try {
//#if USEFLOAT
//                                n = System.Convert.ToSingle(str);
//#else
                            n = System.Convert.ToDouble(str);
//#endif
                            type = Type.NUMBER;
                        } catch (System.FormatException) {
                            type = Type.NULL;
                            if (GLog.IsLogWarningEnabled)
                            {
                                GLog.LogWarning("improper JSON formatting:" + str);
                            }
                        }
                        return;
                    }
                    string propName  = "";
                    bool   openQuote = false;
                    bool   inProp    = false;
                    int    depth     = 0;
                    while (++offset < str.Length)
                    {
                        if (System.Array.IndexOf(WHITESPACE, str[offset]) > -1)
                        {
                            continue;
                        }
                        if (str[offset] == '\\')
                        {
                            offset += 1;
                            continue;
                        }
                        if (str[offset] == '"')
                        {
                            if (openQuote)
                            {
                                if (!inProp && depth == 0 && type == Type.OBJECT)
                                {
                                    propName = FromJSONString(str.Substring(tokenTmp + 1, offset - tokenTmp - 1));
                                }
                                openQuote = false;
                            }
                            else
                            {
                                if (depth == 0 && type == Type.OBJECT)
                                {
                                    tokenTmp = offset;
                                }
                                openQuote = true;
                            }
                        }
                        if (openQuote)
                        {
                            continue;
                        }
                        if (type == Type.OBJECT && depth == 0)
                        {
                            if (str[offset] == ':')
                            {
                                tokenTmp = offset + 1;
                                inProp   = true;
                            }
                        }

                        if (str[offset] == '[' || str[offset] == '{')
                        {
                            depth++;
                        }
                        else if (str[offset] == ']' || str[offset] == '}')
                        {
                            depth--;
                        }
                        //if  (encounter a ',' at top level)  || a closing ]/}
                        if ((str[offset] == ',' && depth == 0) || depth < 0)
                        {
                            inProp = false;
                            string inner = str.Substring(tokenTmp, offset - tokenTmp).Trim(WHITESPACE);
                            if (inner.Length > 0)
                            {
                                if (type == Type.OBJECT)
                                {
                                    keys.Add(propName);
                                }
                                if (maxDepth != -1)                                                                                                                                                     //maxDepth of -1 is the end of the line
                                {
                                    list.Add(Create(inner, (maxDepth < -1) ? -2 : maxDepth - 1));
                                }
                                else if (storeExcessLevels)
                                {
                                    list.Add(CreateBakedObject(inner));
                                }
                            }
                            tokenTmp = offset + 1;
                        }
                    }
                }
            }
            else
            {
                type = Type.NULL;
            }
        }
        else
        {
            type = Type.NULL;                   //If the string is missing, this is a null
        }
        //Profiler.EndSample();
    }