/// <summary>
        /// 卸载资源
        /// </summary>
        /// <param name="asset"></param>
        public void UnloadAssetAsync(UnityEngine.Object asset)
        {
            MDebug.Assert(asset != null, LOG_TAG, "asset != null");
            MDebug.Assert(m_AssetToAssetHandlerMap.ContainsKey(asset), LOG_TAG, "m_AssetToAssetHandlerMap.ContainsKey(asset)");

            if (asset == null || !m_AssetToAssetHandlerMap.ContainsKey(asset))
            {
                return;
            }
            AssetHandler assetHandler = m_AssetToAssetHandlerMap[asset];

            if (assetHandler == null)
            {
                MDebug.Log(LOG_TAG, $"UnloadAssetAsync({assetHandler.GetAssetKey()})");

                AssetAction assetAction = assetHandler.RemoveReference();
                switch (assetAction)
                {
                case AssetAction.Unload:
                    AddAssetActionRequest(assetHandler.GetAssetIndex(), AssetAction.Unload);
                    break;

                default:
                    MDebug.Log(LOG_TAG, "unload failed !");
                    break;
                }
            }
        }
示例#2
0
        public void CopyTo(T[] array, int arrayIndex)
        {
            MDebug.Assert(array != null, LOG_TAG, "array != null");
            int arrayLenth = array.Length;

            MDebug.Assert(arrayIndex >= 0 && arrayIndex <= arrayLenth, LOG_TAG, "arrayIndex >= 0 && arrayIndex <= arrayLenth");
            MDebug.Assert(arrayLenth - arrayIndex >= m_Size, LOG_TAG, "arrayLenth - arrayIndex >= m_Size");

            int numToCopy = (arrayLenth - arrayIndex < m_Size)
                ? (arrayLenth - arrayIndex)
                : m_Size;

            if (numToCopy == 0)
            {
                return;
            }

            int firstPart = (m_Array.Length - m_Head < numToCopy)
                ? m_Array.Length - m_Head
                : numToCopy;

            Array.Copy(m_Array, m_Head, array, arrayIndex, firstPart);

            numToCopy -= firstPart;
            if (numToCopy > 0)
            {
                Array.Copy(m_Array, 0, array, arrayIndex + m_Array.Length - m_Head, numToCopy);
            }
        }
示例#3
0
        public void Release(T element)
        {
            m_LastUsingTime = MDebug.GetMillisecondsSinceStartup();

#if GF_DEBUG
            MDebug.Assert(element != null, "Pool", $"element == null");

            bool removedFromUsing = false;
            for (int iObject = 0; iObject < m_Using.Count; iObject++)
            {
                UsingObject usingObject = m_Using[iObject];
                if (usingObject.Obj.Equals(element))
                {
                    removedFromUsing = true;
                    m_Using.RemoveAt(iObject);
                    break;
                }
            }

            if (!removedFromUsing)
            {
                MDebug.LogError("Pool"
                                , $"Object({element.ToString()}) not alloc by ObjectPool<{typeof(T).FullName}>!");
            }
#endif

            element.OnRelease();
            m_Stack.Push(element);

            m_UsingCount--;
        }
            public BundleAction RemoveReference()
            {
                MDebug.LogVerbose(LOG_TAG, $"Bundle Remove Reference:{ms_AssetManager.m_BundleInfos[m_BundleIndex].BundleName}, Reference Count: {m_ReferenceCount}");
                MDebug.Assert(m_ReferenceCount > 0, LOG_TAG, "m_ReferenceCount = 0, Cant Remove!");
                m_ReferenceCount--;
                switch (m_BundleState)
                {
                case BundleState.NotLoad:
                case BundleState.NeedLoad:
                    MDebug.Assert(false, LOG_TAG, "BundleState.NotLoad");
                    return(BundleAction.Null);

                case BundleState.Loaded:
                    if (m_ReferenceCount == 0)
                    {
                        m_BundleState = BundleState.NeedUnload;
                        return(BundleAction.Unload);
                    }
                    else
                    {
                        return(BundleAction.Null);
                    }

                case BundleState.Loading:
                    MDebug.Assert(m_ReferenceCount > 0, LOG_TAG, "m_ReferenceCount > 0");
                    return(BundleAction.Null);

                default:
                    MDebug.Assert(false, LOG_TAG, "Not support BundleState: " + m_BundleState);
                    return(BundleAction.Null);
                }
            }
            public BundleAction AddReference()
            {
                m_ReferenceCount++;

                MDebug.LogVerbose(LOG_TAG, $"Bundle Add Reference:{ms_AssetManager.m_BundleInfos[m_BundleIndex].BundleName}, Reference Count: {m_ReferenceCount}");

                switch (m_BundleState)
                {
                case BundleState.NotLoad:
                    m_BundleState = BundleState.NeedLoad;
                    return(BundleAction.Load);

                case BundleState.Loaded:
                case BundleState.Loading:
                case BundleState.NeedLoad:
                    return(BundleAction.Null);

                case BundleState.NeedUnload:
                    m_BundleState = BundleState.Loaded;
                    return(BundleAction.Null);

                default:
                    MDebug.Assert(false, LOG_TAG, "Not support BundleState: " + m_BundleState);
                    return(BundleAction.Null);
                }
            }
        /// <summary>
        /// 计算一个Transform的name Path
        /// 例,一个Transform结构:
        ///		A
        ///		|-B
        ///		  |-C
        ///		    |-D
        ///		  |-E
        ///	D的Path = /A/B/C/D
        ///	E的Path = /A/E
        /// </summary>
        public static string CalculateTransformPath(Transform transform, Transform rootTransform = null)
        {
#if GF_DEBUG
            const int MAX_DEEP = 1000;
            int       deep     = 0;
#endif

            StringBuilder stringBuilder = StringUtility.AllocStringBuilder();
            Transform     iterTransform = transform;
            while (iterTransform != rootTransform &&
                   iterTransform != null)
            {
                stringBuilder.Insert(0, "/" + iterTransform.name);
                iterTransform = iterTransform.parent;

#if GF_DEBUG
                if (deep++ >= MAX_DEEP)
                {
                    MDebug.Assert(false, "CalculateTransformPath Deep超出限制,是不是代码逻辑有问题");
                    break;
                }
#endif
            }
            return(StringUtility.ReleaseStringBuilder(stringBuilder));
        }
示例#7
0
        public static void AppendParameterInfo(StringBuilder stringBuilder, RpcValue parameterInfo)
        {
            switch (parameterInfo.ValueType)
            {
            case ValueType.Byte:
            case ValueType.Short:
            case ValueType.Int:
            case ValueType.Long:
            case ValueType.Float:
            case ValueType.Double:
                AppendValueType(stringBuilder, parameterInfo.ValueType);
                break;

            case ValueType.FixedValueTypeArray:
            case ValueType.VariableValueTypeArray:
                ArrayPool <RpcValue> .Node parameters = parameterInfo.ArrayValue;
                break;

            default:
                MDebug.Assert(false
                              , "Rpc"
                              , "Not support ValueType: " + parameterInfo.ValueType);
                break;
            }
        }
        private void ParallelUpdate(float deltaTime)
        {
            MDebug.Assert(m_ParallelItemsCache.Count == 0, "Core", "m_ParallelTasksCache.Count == 0");

            string lastGroupName = string.Empty;

            for (int iBehaviour = 0; iBehaviour < m_BehavioursForTraverse.Count; iBehaviour++)
            {
                BaseBehaviour iterBehaviour = m_BehavioursForTraverse[iBehaviour];
                if (!iterBehaviour.CanUpdate() ||
                    !iterBehaviour.HasFeature(FeatureFlag.ParallelUpdate))
                {
                    continue;
                }

                string groupName = iterBehaviour.GetGroup();
                if (groupName != lastGroupName)
                {
                    ExecuteParallelUpdateGroup();
                }

                lastGroupName = groupName;
                m_ParallelItemsCache.Add(m_ParallelItemPool.Alloc()
                                         .SetData(iterBehaviour, deltaTime));
            }

            ExecuteParallelUpdateGroup();
        }
        public override void OnLateUpdate(float deltaTime)
        {
            base.OnLateUpdate(deltaTime);

            while (m_BundleActionRequests.Count > 0)
            {
                BundleActionRequest bundleActionRequest = m_BundleActionRequests.Dequeue();
                if (bundleActionRequest.BundleIndex >= 0 && bundleActionRequest.BundleIndex < m_BundleHandlers.Length)
                {
                    m_BundleHandlers[bundleActionRequest.BundleIndex].TryExecuteAction(bundleActionRequest.BundleAction);
                }
                else
                {
                    MDebug.Assert(false, LOG_TAG, "m_BundleHandlers.TryGetValue(bundleActionRequest.BundleName, out BundleHandler bundleHandler)");
                }
            }

            while (m_AssetActionRequests.Count > 0)
            {
                AssetActionRequest assetActionRequest = m_AssetActionRequests.Dequeue();
                int assetHandlerIndex = assetActionRequest.AssetIndex;
                if (assetHandlerIndex >= 0 && assetHandlerIndex < m_AssetHandlers.Length)
                {
                    m_AssetHandlers[assetHandlerIndex].TryExecuteAction(assetActionRequest.AssetAction);
                }
                else
                {
                    MDebug.Assert(false, LOG_TAG, "m_BundleHandlers.TryGetValue(bundleActionRequest.BundleName, out BundleHandler bundleHandler)");
                }
            }
        }
示例#10
0
        public void Release()
        {
#if GF_DEBUG
            if (m_Root._After != null)
            {
                MDebug.Assert(m_Root._After == null
                              , "ArrayPool"
                              , "m_Root._After == null");

                StringBuilder stringBuilder = StringUtility.AllocStringBuilder();
                stringBuilder.Append("ArrayPool<").Append(typeof(T).FullName).Append(">has memory leak!\n");
                Node iterNode = m_Root;
                while (iterNode != null)
                {
                    stringBuilder.Append("Offset:").Append(iterNode.GetOffset())
                    .Append("\tSize:").Append(iterNode.GetSize())
                    .Append("\tIsUsed:").Append(iterNode.IsUsed())
                    .Append('\n');
                    iterNode = iterNode._After;
                }
                MDebug.LogError("ArrayPool"
                                , StringUtility.ReleaseStringBuilder(stringBuilder));
            }
#endif

            m_Buffer = null;
            ms_NodePool.Release(m_Root);
            m_Root = null;
        }
        /// <summary>
        /// 获取一个transform相对rootTransform的缩放
        /// 如果rootTransform为null,则获得transform相对世界空间缩放
        /// </summary>
        public static Vector3 CalculateLossyScale(Transform transform, Transform rootTransform = null)
        {
            if (rootTransform == null)
            {
                return(transform.lossyScale);
            }
            else
            {
#if GF_DEBUG
                const int MAX_DEEP = 1000;
                int       deep     = 0;
#endif

                Transform iterTransform = transform;
                Vector3   scale         = Vector3.one;
                while (iterTransform != rootTransform &&
                       iterTransform != null)
                {
                    scale         = MathUtility.EachMulti(scale, iterTransform.localScale);
                    iterTransform = iterTransform.parent;
#if GF_DEBUG
                    if (deep++ >= MAX_DEEP)
                    {
                        MDebug.Assert(false, "CalculateLossyScale Deep超出限制,是不是代码逻辑有问题");
                        break;
                    }
#endif
                }
                return(scale);
            }
        }
示例#12
0
        public void VerifyLegality()
        {
            Node iterNode   = m_Root;
            Node beforeNode = null;
            int  nodeCount  = 0;

            while (iterNode != null)
            {
                nodeCount++;
                if (beforeNode != null)
                {
                    MDebug.Assert(iterNode._Before == beforeNode
                                  , "ArrayPool"
                                  , "iterNode._Before == beforeNode");

                    MDebug.Assert(beforeNode.GetOffset() + beforeNode.GetSize() == iterNode.GetOffset()
                                  , "ArrayPool"
                                  , "beforeNode.GetOffset() + beforeNode.GetSize() == iterNode.GetOffset()");
                }

                beforeNode = iterNode;
                iterNode   = iterNode._After;
            }

            MDebug.Assert(nodeCount == ms_NodePool.GetUsingCount()
                          , "ArrayPool"
                          , "nodeCount == m_NodePool.GetUsingCount()");

            MDebug.Assert(beforeNode.GetOffset() + beforeNode.GetSize() == m_Buffer.Length
                          , "ArrayPool"
                          , "beforeNode.GetOffset() + beforeNode.GetSize() == m_Buffer.Length");
        }
示例#13
0
            public bool TryExecuteAction(AssetAction assetAction)
            {
                switch (assetAction)
                {
                case AssetAction.Load:
                    return(TryLoadAsset());

                case AssetAction.Unload:
                    return(TryUnloadAsset());

                case AssetAction.LoadedCallback:
                    try
                    {
                        m_OnAssetLoaded?.Invoke(m_AssetKey, m_Asset);
                    }
                    catch (Exception e)
                    {
                        MDebug.LogError(LOG_TAG, "LoadedCallBack Error \n\n" + e.ToString());
                    }
                    finally
                    {
                        m_OnAssetLoaded = null;
                    }
                    return(true);

                default:
                    MDebug.Assert(false, LOG_TAG, "Not support AssetAction: " + assetAction);
                    return(false);
                }
            }
示例#14
0
            public AssetAction RemoveReference()
            {
                MDebug.LogVerbose(LOG_TAG, $"Asset Remove Reference:{m_AssetKey}, Reference Count: {m_ReferenceCount}");
                MDebug.Assert(m_ReferenceCount > 0, LOG_TAG, "m_ReferenceCount = 0 cant remove");
                if (m_ReferenceCount == 0)
                {
                    return(AssetAction.Null);
                }
                m_ReferenceCount--;
                switch (m_AssetState)
                {
                case AssetState.WaitLoad:
                case AssetState.Loading:
                    MDebug.Assert(false, LOG_TAG, "Asset Not Load But Remove Reference");
                    return(AssetAction.Null);

                case AssetState.Loaded:
                    if (m_ReferenceCount == 0)
                    {
                        m_AssetState = AssetState.NeedUnload;
                        return(AssetAction.Unload);
                    }
                    else
                    {
                        return(AssetAction.Null);
                    }

                default:
                    MDebug.Assert(false, LOG_TAG, "Asset Not Support AssetState");
                    return(AssetAction.Null);
                }
            }
示例#15
0
            public AssetAction AddReference(Action <AssetKey, UnityEngine.Object> callback)
            {
                m_OnAssetLoaded += callback;
                m_ReferenceCount++;

                MDebug.LogVerbose(LOG_TAG, $"Asset Add Reference:{m_AssetKey}, Reference Count: {m_ReferenceCount}");

                switch (m_AssetState)
                {
                case AssetState.Loaded:
                    MDebug.Assert(m_Asset != null, LOG_TAG, "m_Asset != null");
                    return(AssetAction.LoadedCallback);

                case AssetState.NotLoad:
                    m_AssetState = AssetState.WaitLoad;
                    return(AssetAction.RequestLoadBundle);

                case AssetState.WaitLoad:
                case AssetState.Loading:
                    return(AssetAction.Null);

                case AssetState.NeedUnload:
                    MDebug.Assert(m_Asset != null, LOG_TAG, "m_Asset != null");
                    m_AssetState = AssetState.Loaded;
                    return(AssetAction.LoadedCallback);

                default:
                    MDebug.Assert(false, LOG_TAG, "Asset Not Support AssetState");
                    return(AssetAction.Null);
                }
            }
示例#16
0
        /// <summary>
        /// 包含Bundle是否需要加载判断,添加资源引用计数,并在尚未加载Bundle时,设置加载完成时回调
        /// </summary>
        /// <param name="bundleIndex"></param>
        /// <param name="assetIndex"></param>
        private void LoadBundleForLoadAsset(int bundleIndex, int assetIndex)
        {
            BundleHandler bundleHandler = m_BundleHandlers[bundleIndex];

            if (bundleHandler == null)
            {
                bundleHandler = m_BundleHandlerPool.Alloc();
                bundleHandler.SetBundleIndex(bundleIndex);
                m_BundleHandlers[bundleIndex] = bundleHandler;
            }

            BundleAction bundleAction = bundleHandler.AddReference();

            if (bundleAction == BundleAction.Load)
            {
                m_BundleActionRequests.Enqueue(new BundleActionRequest(bundleIndex, bundleAction));

                MDebug.LogVerbose(LOG_TAG, $"Add load bundle action. Bundle:({m_BundleInfos[bundleIndex].BundleName}) Asset:({(AssetKey)assetIndex})");
            }
            else if (bundleAction == BundleAction.Null)
            {
                // Dont need handle
            }
            else
            {
                MDebug.Assert(false, "AsestBundle", "Not support BundleAction: " + bundleAction);
            }

            bundleHandler.TryAddDependencyAsset(m_AssetHandlers[assetIndex]);
        }
示例#17
0
        void ICollection.CopyTo(Array array, int index)
        {
            MDebug.Assert(array != null, LOG_TAG, "array != null");
            MDebug.Assert(array.Rank == 1, LOG_TAG, "array.Rank == 1");
            MDebug.Assert(array.GetLowerBound(0) == 0, LOG_TAG, "array.GetLowerBound(0) == 0");
            int arrayLength = array.Length;

            MDebug.Assert(index >= 0 || index <= arrayLength, LOG_TAG, "index >= 0 || index <= arrayLength");
            MDebug.Assert(arrayLength - index >= m_Size, LOG_TAG, "arrayLength - index >= m_Size");

            int numToCopy = (arrayLength - index < m_Size) ? arrayLength - index : m_Size;

            if (numToCopy == 0)
            {
                return;
            }

            try
            {
                int firstPart = (m_Array.Length - m_Head < numToCopy)
                    ? m_Array.Length - m_Head
                    : numToCopy;
                Array.Copy(m_Array, m_Head, array, index, firstPart);
                numToCopy -= firstPart;

                if (numToCopy > 0)
                {
                    Array.Copy(m_Array, 0, array, index + m_Array.Length - m_Head, numToCopy);
                }
            }
            catch (ArrayTypeMismatchException)
            {
                MDebug.Assert(false, LOG_TAG, "ArrayTypeMismatchException");
            }
        }
示例#18
0
        /// <summary>
        /// Jacobi求解三元一次方程近似解
        ///     <see cref="https://en.wikipedia.org/wiki/Jacobi_method"/>
        /// a_n1 * x + a_n2 * y + a_n3 * z = bn
        /// 方程组需要满足diagonally dominant matrices或symmetric matrix
        ///     <see cref="https://en.wikipedia.org/wiki/Diagonally_dominant_matrix"/>
        ///     TODO 我只判断了diagonally dominant matrices,还没判断symmetric的情况
        /// <see cref="GaussSeidelMethod"/>
        /// </summary>
        /// <param name="iterationCount">迭代次数,次数越多结果越正确</param>
        /// <param name="x" name="y" name="z">预测的近似值及计算结果</param>
        public static void JacobiMethod(int iterationCount
                                        , ref float x, ref float y, ref float z
                                        , float a11, float a12, float a13, float b1
                                        , float a21, float a22, float a23, float b2
                                        , float a31, float a32, float a33, float b3)
        {
#if GF_DEBUG
            MDebug.Assert(Mathf.Abs(a11) > Mathf.Abs(a12) + Mathf.Abs(a13) &&
                          Mathf.Abs(a22) > Mathf.Abs(a21) + Mathf.Abs(a23) &&
                          Mathf.Abs(a33) > Mathf.Abs(a31) + Mathf.Abs(a32),
                          "Not a diagonally dominant matrices!");
#endif

            float tempX = x, tempY = y, tempZ = z;
            // 对角线的导数,为了性能提前算好
            float a11Reciprocal = 1.0f / a11;
            float a22Reciprocal = 1.0f / a22;
            float a33Reciprocal = 1.0f / a33;
            while (iterationCount-- > 0)
            {
                tempX = (b1 - a12 * y - a13 * z) * a11Reciprocal;
                tempY = (b2 - a21 * x - a23 * z) * a22Reciprocal;
                tempZ = (b3 - a31 * x - a32 * y) * a33Reciprocal;
                x     = tempX; y = tempY; z = tempZ;
            }
        }
示例#19
0
        public static void AppendValueType(StringBuilder stringBuilder, ValueType valueType)
        {
            switch (valueType)
            {
            case ValueType.Byte:
            case ValueType.Short:
            case ValueType.Int:
            case ValueType.Long:
            case ValueType.Float:
            case ValueType.Double:
                stringBuilder.Append('_').Append((byte)valueType);
                break;

            // 所有数组都当成同一种类型,方便处理
            case ValueType.FixedValueTypeArray:
            case ValueType.VariableValueTypeArray:
                stringBuilder.Append('_').Append((byte)ValueType.FixedValueTypeArray);
                break;

            default:
                MDebug.Assert(false
                              , "Rpc"
                              , "Not support ValueType: " + valueType);
                break;
            }
        }
示例#20
0
        public void Test(RpcValue paramater)
        {
            ArrayPool <byte> bufferPool = TcpClient.GetBufferPool();

            ArrayPool <byte> .Node buffer;
            lock (bufferPool)
            {
                buffer = bufferPool.AllocBuffer(DEFAULT_BUFFER_SIZE);
            }

            int serializePoint = buffer.GetOffset();

            paramater.Serialize(buffer.GetBuffer(), ref serializePoint);

            int dserializePoint = buffer.GetOffset();

            paramater.Deserialize(RpcValueArrayPool
                                  , RpcValuePool
                                  , buffer.GetBuffer()
                                  , ref dserializePoint);

            lock (bufferPool)
            {
                bufferPool.ReleaseBuffer(buffer);
            }

            MDebug.Assert(serializePoint == dserializePoint
                          , "Rpc"
                          , "serializePoint == dserializePoint");
        }
示例#21
0
 public void UnloadAssetAsync(UnityEngine.Object asset)
 {
     MDebug.Assert(asset != null, LOG_TAG, "Asset You Want To Release Is Null!");
     if (!(asset is GameObject) && !(asset is Component))
     {
         Resources.UnloadAsset(asset);
     }
 }
示例#22
0
 public void OnBundleLoaded(string bundleName)
 {
     m_RemainLoadBundleCount--;
     MDebug.Assert(m_RemainLoadBundleCount >= 0, LOG_TAG, "m_RemainLoadBundleCount >= 0");
     if (m_RemainLoadBundleCount == 0)
     {
         ms_AssetManager.AddAssetActionRequest(m_AssetKey, AssetAction.Load);
     }
 }
示例#23
0
        public void RemoveBehaivour(BaseEntityBehaviour behaviour)
        {
            MDebug.Assert(behaviour.GetOwner() == this
                          , "Entity"
                          , "component.GetOwner() == this");

            behaviour.SetOwner(null);
            behaviour.DestorySelf();
        }
示例#24
0
        public void AddBehaviour(BaseEntityBehaviour behaviour)
        {
            MDebug.Assert(behaviour.GetOwner() == null
                          , "Entity"
                          , "component.GetOwner() == null");

            behaviour.SetOwner(this);
            behaviour.SetEnable(true);
        }
示例#25
0
        public BetterQueue(int capacity)
        {
            MDebug.Assert(capacity >= 0, LOG_TAG, "capacity >= 0");

            m_Array = new T[capacity];
            m_Head  = 0;
            m_Tail  = 0;
            m_Size  = 0;
        }
        public void DestroyEntity(BaseEntity entity)
        {
            MDebug.Assert(m_InstanceIDToEntities[entity.GetInstanceID()] == entity
                          , "Entity"
                          , "m_InstanceIDToEntities[entity.GetInstanceID()] == entity");
            m_InstanceIDToEntities.Remove(entity.GetInstanceID());

            entity.OnRelease();
        }
示例#27
0
        /// <summary>
        /// 直接返回指定名称的AssetBundle,除FairyGUI不要使用
        /// </summary>
        /// <param name="assetBundleName"></param>
        /// <param name="callback"></param>
        public void LoadAssetBundleForFairyGUIAsync(string assetBundleName, Action <AssetBundle> callback)
        {
            MDebug.Log(LOG_TAG, $"LoadAssetBundleAsync({assetBundleName})");
            MDebug.Assert(callback != null, LOG_TAG, "callback != null");
            m_FairyGUICallBack = callback;
            string tmpAssetBundlePath = Path.Combine(m_RootBundlePath, assetBundleName);

            AssetBundle.LoadFromFileAsync(tmpAssetBundlePath).completed += LoadAssetBundleForFairyGUICallBack;
        }
示例#28
0
        public static void BeginCreateLib(IntPtr luaState, string libName)
        {
            MDebug.Assert(ms_CurrntLibName == null
                          , "XLua"
                          , "ms_CurrntLibName == null");

            ms_CurrntLibName = libName;

            Lua.lua_newtable(luaState);
        }
示例#29
0
        public static char GetHexValue(int value)
        {
            MDebug.Assert(value >= 0 && value < 16, "value is out of range.");
            if (value < 10)
            {
                return((char)(value + '0'));
            }

            return((char)(value - 10 + 'A'));
        }
示例#30
0
        public static void RegistFunction(IntPtr luaState, string libName, string functionName, lua_CSFunction function)
        {
            MDebug.Assert(ms_CurrntLibName == libName
                          , "XLua"
                          , "ms_CurrntLibName == libName");

            Lua.xlua_pushasciistring(luaState, functionName);
            Lua.lua_pushstdcallcfunction(luaState, function);
            Lua.lua_rawset(luaState, -3);
        }