예제 #1
0
        // ------------------------------ HIERARCHY ICON -----------------------------

        public override float Draw(Rect r, GameObject go)
        {
#if H2_DEV
            Profiler.BeginSample("h2_Lock.Draw");
#endif

            if (h2_Lazy.isMouseDown)
            {
                var icoRect = h2_Utils.subRectRight(r, 16f);
                h2_GUI.Check(icoRect, go, ToggleLock, null, null, UnSmartToggle);

#if H2_DEV
                Profiler.EndSample();
#endif
                return(MaxWidth);
            }

            if (h2_Lazy.isRepaint)
            {
                var icoRect = h2_Utils.subRectRight(r, 16f);
                (setting as h2_LockSetting).DrawIcon(icoRect, go);
#if H2_DEV
                Profiler.EndSample();
#endif
                return(MaxWidth);
            }

#if H2_DEV
            Profiler.EndSample();
#endif
            return(MaxWidth);
        }
예제 #2
0
        internal static JobHandle UpdateTreeMeshes(int[] treeNodeIDs)
        {
            var finalJobHandle = default(JobHandle);

#if UNITY_EDITOR
            //JobsUtility.JobWorkerCount = math.max(1, ((JobsUtility.JobWorkerMaximumCount + 1) / 2) - 1);
#endif

            var treeUpdates      = new TreeUpdate[treeNodeIDs.Length];
            var treeUpdateLength = 0;
            Profiler.BeginSample("Tag_Setup");
            for (int t = 0; t < treeNodeIDs.Length; t++)
            {
                var treeNodeIndex = treeNodeIDs[t] - 1;
                var treeInfo      = CSGManager.nodeHierarchies[treeNodeIndex].treeInfo;

                Profiler.BeginSample("Tag_Reset");
                treeInfo.Reset();
                Profiler.EndSample();

                var treeBrushes = treeInfo.treeBrushes;
                if (treeBrushes.Count == 0)
                {
                    continue;
                }

                var chiselLookupValues = ChiselTreeLookup.Value[treeNodeIndex];
                var chiselMeshValues   = ChiselMeshLookup.Value;

                ref var brushMeshBlobs          = ref chiselMeshValues.brushMeshBlobs;
                ref var transformations         = ref chiselLookupValues.transformations;
예제 #3
0
        // ------------------------------ HIERARCHY ICON -----------------------------

        public override float Draw(Rect r, GameObject go)
        {
#if H2_DEV
            Profiler.BeginSample("h2_Tag.Draw");
#endif

            if (go == null || setting == null || !h2_Lazy.isRepaint)
            {
#if H2_DEV
                Profiler.EndSample();
#endif
                return(0);
            }

            var ss       = setting as h2_TagSetting;
            var drawRect = new Rect(r.x + r.width - MaxWidth, r.y, MaxWidth, r.height);
            var ww       = ss.DrawTag(drawRect, go);

            if (MaxWidth < ww || ss.labelColor.maxWidth == 0)
            {
                MaxWidth = ww;
                ss.labelColor.maxWidth = ww;
            }

#if H2_DEV
            Profiler.EndSample();
#endif

            return(ww);
        }
예제 #4
0
        // ------------------------------ HIERARCHY ICON -----------------------------

        public override float Draw(Rect r, GameObject go)
        {
#if H2_DEV
            Profiler.BeginSample("h2_Active.Draw");
#endif

            if (h2_Lazy.isMouseDown)
            {
                var icoRect = h2_Utils.subRectRight(r, 16f);
                h2_GUI.Check(icoRect, go, Toggle, null, InvertSibling, UnSmartToggle);

#if H2_DEV
                Profiler.EndSample();
#endif
                return(MaxWidth);
            }

            if (h2_Lazy.isRepaint)
            {
                var icoRect = h2_Utils.subRectRight(r, 16f);
                var idx     = go.activeInHierarchy ? 0 : go.activeSelf ? 2 : 1;
                (setting as h2_ActiveIconSetting).DrawIcon(icoRect, idx, go);

#if H2_DEV
                Profiler.EndSample();
#endif
                return(MaxWidth);
            }

#if H2_DEV
            Profiler.EndSample();
#endif
            return(MaxWidth);
        }
        private float MeasureStartupTime(int numFloats)
        {
            // float[] startingValues = new float[numFloats];
            // float[] endingValues = new float[numFloats];

            // for (int i = 0; i < numFloats; ++i)
            // {
            //     startingValues[i] = UnityEngine.Random.value;
            //     endingValues[i] = 1 + UnityEngine.Random.value;
            // }

            Action <float> floatSetter = (f) => { };

            // Stopwatch watch = Stopwatch.StartNew();
            for (int i = 0; i < numFloats; ++i)
            {
                Profiler.BeginSample("Tween");
                // Routine.Start(this, Tween.Float(startingValues[i], endingValues[i], floatSetter, 1.0f).Loop());
                Routine.Start(this, Tween.Float(0, 1, floatSetter, 1.0f).Loop());
                Profiler.EndSample();
            }
            // watch.Stop();
            // return (watch.ElapsedTicks / 10000f);
            return(0);
        }
예제 #6
0
        public override float Draw(Rect r, GameObject go)
        {
#if H2_DEV
            Profiler.BeginSample("h2_Script.Draw");
#endif

            if ((go == null) || !h2_Lazy.isRepaint)
            {
#if H2_DEV
                Profiler.EndSample();
#endif

                return(0);
            }

            var state = GetState(go, h2_Selection.Contains(go) ? 0.1f : 60f);
            //slow refresh for gameObjects that are not selected
            if (state == h2_ScriptState.None)
            {
#if H2_DEV
                Profiler.EndSample();
#endif
                return(0);
            }

            var s       = (h2_ScriptSetting)setting;
            var icoRect = h2_Utils.subRectRight(r, MaxWidth);
            h2_GUI.SolidColor(icoRect, s.stateColors[(int)state - 1]);

#if H2_DEV
            Profiler.EndSample();
#endif
            return(MaxWidth);
        }
예제 #7
0
        // ------------------------------ HIERARCHY ICON -----------------------------
        //static Color[] colors = {
        //	new Color32(0,0, 128, 255),
        //	new Color32(128, 0, 0, 255),
        //	new Color32(0, 128, 0, 255)
        //};

        public override float Draw(Rect r, GameObject go)
        {
#if H2_DEV
            Profiler.BeginSample("h2_Prefab.Draw");
#endif
            if (go == null)
            {
                return(0);
            }


            var info = Get(go, h2_Selection.Contains(go) ? 0.2f : 1f);
            if (info.type == PrefabType.None)
            {
                return(0);
            }

            if (h2_Lazy.isMouseDown)
            {
                var icoRect = h2_Utils.subRectRight(r, 16f);
                h2_GUI.Check(icoRect, go, SelectPrefab);

#if H2_DEV
                Profiler.EndSample();
#endif
                return(MaxWidth);
            }

            if (h2_Lazy.isRepaint)
            {
                var icoRect = h2_Utils.subRectRight(r, 16f);
                var s       = setting as h2_PrefabSetting;
                //h2_GUI.SolidColor(icoRect, colors[info.colorIndex]);

                s.DrawIcon(icoRect, info.colorIndex, go);

#if H2_DEV
                Profiler.EndSample();
#endif
                return(MaxWidth);
            }

#if H2_DEV
            Profiler.EndSample();
#endif
            return(MaxWidth);
        }
        private static void SaveToFile(string filePath, PackedMemorySnapshot snapshot)
        {
            // Saving snapshots using JsonUtility, instead of BinaryFormatter, is significantly faster.
            // I cancelled saving a memory snapshot that is saving using BinaryFormatter after 24 hours.
            // Saving the same memory snapshot using JsonUtility.ToJson took 20 seconds only.

            Debug.LogFormat("Saving...");
            System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch();
            Profiler.BeginSample("PackedMemorySnapshotUtility.SaveToFile");
            stopwatch.Start();

            string json = JsonUtility.ToJson(snapshot);

            File.WriteAllText(filePath, json);

            stopwatch.Stop();
            Profiler.EndSample();
            Debug.LogFormat("Saving took {0}ms", stopwatch.ElapsedMilliseconds);
        }
예제 #9
0
        public override void OnInspectorGUI()
        {
            var s = (h2_Setting)target;

            Profiler.BeginSample("h2.Setting.OnGUI");
            EditorGUI.BeginChangeCheck();
            {
                //s.Check2Reset();
                s.Common.DrawInspector();
                s.SceneViewHL.DrawInspector();
                s.ParentIndicator.DrawInspector();
                s.Script.DrawInspector();
                s.Lock.DrawInspector();
                s.Active.DrawInspector();
                s.Prefab.DrawInspector();
                s.Static.DrawInspector();
                s.Combine.DrawInspector();
                s.GOIcon.DrawInspector();
                s.Tag.DrawInspector();
                s.Layer.DrawInspector();


                //Debug.Log("A");

                s.Component.DrawInspector();

                //Debug.Log("B");

                GUILayout.FlexibleSpace();
                s.palette.Draw();
                //s.Static.Draw(s.previewAllStates);
                //s.Lock.Draw(s.previewAllStates);
            }

            if (EditorGUI.EndChangeCheck())
            {
                EditorUtility.SetDirty(target);
                h2_Utils.DelayRepaintHierarchy();
            }
            Profiler.EndSample();
        }
        private static PackedMemorySnapshot LoadFromFile(string filePath)
        {
            Debug.LogFormat("Loading...");
            System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch();
            PackedMemorySnapshot         result;
            string fileExtension = Path.GetExtension(filePath);

            if (string.Equals(fileExtension, ".memsnap2", System.StringComparison.OrdinalIgnoreCase))
            {
                Profiler.BeginSample("PackedMemorySnapshotUtility.LoadFromFile(json)");
                stopwatch.Start();

                string json = File.ReadAllText(filePath);
                result = JsonUtility.FromJson <PackedMemorySnapshot>(json);

                stopwatch.Stop();
                Profiler.EndSample();
            }
            else if (string.Equals(fileExtension, ".memsnap", System.StringComparison.OrdinalIgnoreCase))
            {
                Profiler.BeginSample("PackedMemorySnapshotUtility.LoadFromFile(binary)");
                stopwatch.Start();

                BinaryFormatter binaryFormatter = new BinaryFormatter();
                using (Stream stream = File.Open(filePath, FileMode.Open))
                {
                    result = binaryFormatter.Deserialize(stream) as PackedMemorySnapshot;
                }

                stopwatch.Stop();
                Profiler.EndSample();
            }
            else
            {
                Debug.LogErrorFormat("MemoryProfiler: Unrecognized memory snapshot format '{0}'.", filePath);
                result = null;
            }

            Debug.LogFormat("Loading took {0}ms", stopwatch.ElapsedMilliseconds);
            return(result);
        }
예제 #11
0
        // ------------------------------ HIERARCHY ICON -----------------------------

        public override float Draw(Rect r, GameObject go)
        {
#if H2_DEV
            Profiler.BeginSample("h2_Component.Draw");
#endif

            if (stIdx == -1)
            {
                stIdx = (setting as h2_ComponentSetting).showTransform ? 0 : 1;
            }

            var info = h2_GOCache.Get(go, h2_Selection.Contains(go) ? 1f : 60f);
            var w    = (info.nComponents - stIdx) * 16f;
            if (w > MaxWidth)
            {
                MaxWidth = w;
            }

            var tr       = r.x + r.width;
            var drawRect = new Rect(tr - w, r.y, w, r.height);

            if (h2_Lazy.isMouseDown)
            {
                var mPos = Event.current.mousePosition;

                if (drawRect.Contains(mPos))
                {
                    //Debug.Log(tr + ":" + (tr - mPos.x));
                    var cIdx = Mathf.FloorToInt((tr - mPos.x) / 16f) + stIdx;
                    if (cIdx >= info.components.Count || cIdx < 0)
                    {
                        Debug.LogWarning("cIdx is invalid : " + cIdx + ":" + info.components.Count + ":" + go);
                    }
                    else
                    {
                        var cc = info.components[cIdx];
                        if (cc.type.hasEnableProp)
                        {
                            cc.isEnabled = !cc.isEnabled;

                            Undo.IncrementCurrentGroup();

                            if (h2_Selection.PartOfMuti(go))
                            {
                                var arr    = h2_Selection.gameObjects;
                                var listCC = new List <Component>();
                                for (var i = 0; i < arr.Length; i++)
                                {
                                    var item = h2_GOCache.Get(arr[i], 1f);
                                    for (var j = 0; j < item.components.Count; j++)
                                    {
                                        var cj = item.components[j];

                                        if ((cj.type == cc.type) && (cj.c != null))
                                        {
                                            cj.isEnabled = cc.isEnabled;
                                            listCC.Add(cj.c);
                                        }
                                    }
                                }

                                for (var k = 0; k < listCC.Count; k++)
                                {
                                    h2_ComponentType.SetEnable(listCC[k], cc.isEnabled);
                                }
                            }
                            else
                            {
                                h2_ComponentType.SetEnable(cc.c, cc.isEnabled);
                            }

                            Event.current.Use();
                            h2_Unity.InspectorWindow.Repaint();
                        }
                    }
                }

#if H2_DEV
                Profiler.EndSample();
#endif
                return(w);
            }

            if (h2_Lazy.isRepaint)
            {
                var icoRect = new Rect(tr - 16f, r.y, 16f, r.height);
                for (var i = stIdx; i < info.nComponents; i++)
                {
                    var cc   = info.components[i];
                    var icon = AssetPreview.GetMiniThumbnail(cc.c);
                    if (icon == null)
                    {
                        continue;
                    }

                    if (cc.isEnabled)
                    {
                        GUI.DrawTexture(icoRect, icon);
                    }
                    else
                    {
                        h2_GUI.TextureColor(icoRect, icon, Color.black);
                    }

                    icoRect.x -= 16f;
                }

#if H2_DEV
                Profiler.EndSample();
#endif
                return(w);
            }

#if H2_DEV
            Profiler.EndSample();
#endif
            return(w);
        }
        public bool CopyPositionOnlyToMesh(Mesh.MeshDataArray dataArray, int contentsIndex, int meshIndex, int instanceID, ref JobHandle allJobs, JobHandle dependencies)
        {
            //if (geometryHashValue != meshDescription.geometryHashValue)
            //{
            //geometryHashValue = meshDescription.geometryHashValue;

            /*
             * var positionsArray  = this.positions[contentsIndex].AsArray();
             * var indicesArray    = this.indices[contentsIndex].AsArray();
             * if (positionsArray.Length == 0 ||
             *  indicesArray.Length == 0)
             * {
             *  if (mesh.vertexCount == 0)
             *      return false;
             *  mesh.Clear(keepVertexLayout: true);
             *  return true;
             * }
             *
             * mesh.Clear(keepVertexLayout: true);
             * mesh.SetVertices(positionsArray);
             * mesh.SetIndices(indicesArray, 0, indices[contentsIndex].Length, MeshTopology.Triangles, 0, true);
             *
             * //mesh.SetIndexBufferParams(indices[contentsIndex].Length, UnityEngine.Rendering.IndexFormat.UInt32);
             * //mesh.SetIndexBufferData(indicesArray, 0, 0, indices[contentsIndex].Length, MeshUpdateFlags.Default);
             * mesh.RecalculateBounds();
             * return true;
             *
             * //var subMeshesArray    = this.subMeshes[contentsIndex].AsArray();
             * var positionsArray      = this.positions[contentsIndex].AsArray();
             * var indicesArray        = this.indices[contentsIndex].AsArray();
             *
             * //var vertexCount = positionsArray.Length;
             * var indexCount  = indicesArray.Length;
             */

            var positionsArray = this.positions[contentsIndex].AsArray();
            var indicesArray   = this.indices[contentsIndex].AsArray();

            var indexCount = indicesArray.Length;

            Profiler.BeginSample("Init");
            var data = dataArray[meshIndex];

            data.SetVertexBufferParams(positionsArray.Length, s_PositionOnlyDescriptors);
            data.SetIndexBufferParams(indexCount, IndexFormat.UInt32);
            Profiler.EndSample();

            var copyToMeshJob = new CopyToMeshColliderJob
            {
                subMeshes     = subMeshes,
                indices       = indices,
                positions     = positions,
                contentsIndex = contentsIndex,
                instanceID    = instanceID,
                data          = data
            };
            var copyToMeshJobHandle = copyToMeshJob.Schedule(dependencies);

            allJobs = JobHandle.CombineDependencies(allJobs, copyToMeshJobHandle);
            return(true);
        }
        public bool CopyToMesh(Mesh.MeshDataArray dataArray, int contentsIndex, int meshIndex, ref JobHandle allJobs, JobHandle dependencies)
        {
            /*
             * // TODO: store somewhere else
             * var startIndex  = subMeshSections[contentsIndex].startIndex;
             * var endIndex    = subMeshSections[contentsIndex].endIndex;
             * const long kHashMagicValue = (long)1099511628211ul;
             * UInt64 combinedGeometryHashValue = 0;
             * UInt64 combinedSurfaceHashValue = 0;
             *
             * ref var meshDescriptions = ref vertexBufferContents.meshDescriptions;
             *
             * for (int i = startIndex; i < endIndex; i++)
             * {
             *  var meshDescription = meshDescriptions[i];
             *  if (meshDescription.vertexCount < 3 ||
             *      meshDescription.indexCount < 3)
             *      continue;
             *
             *  combinedGeometryHashValue   = (combinedGeometryHashValue ^ meshDescription.geometryHashValue) * kHashMagicValue;
             *  combinedSurfaceHashValue    = (combinedSurfaceHashValue  ^ meshDescription.surfaceHashValue) * kHashMagicValue;
             * }
             *
             * if (geometryHashValue != combinedGeometryHashValue ||
             *  surfaceHashValue != combinedSurfaceHashValue)
             * {
             *
             *      geometryHashValue = combinedGeometryHashValue;
             *      surfaceHashValue = combinedSurfaceHashValue;
             *
             */

            //var subMeshesArray      = this.subMeshes[contentsIndex].AsArray();
            var positionsArray = this.positions[contentsIndex].AsArray();
            var indicesArray   = this.indices[contentsIndex].AsArray();

            //var vertexCount = positionsArray.Length;
            var indexCount = indicesArray.Length;


            Profiler.BeginSample("Init");
            var data = dataArray[meshIndex];

            data.SetVertexBufferParams(positionsArray.Length, s_FullDescriptors);
            data.SetIndexBufferParams(indexCount, IndexFormat.UInt32);
            Profiler.EndSample();

            var copyToMeshJob = new CopyToMeshJob
            {
                subMeshes     = this.subMeshes,
                indices       = this.indices,
                positions     = this.positions,
                tangents      = this.tangents,
                normals       = this.normals,
                uv0           = this.uv0,
                contentsIndex = contentsIndex,
                data          = data
            };
            var copyToMeshJobHandle = copyToMeshJob.Schedule(dependencies);

            allJobs = JobHandle.CombineDependencies(allJobs, copyToMeshJobHandle);
            return(true);
        }
예제 #14
0
        public override float Draw(Rect r, GameObject go)
        {
            if (!h2_Lazy.isRepaint)
            {
                return(0f);
            }

            if ((r.y < lastDrawY) || (lastDrawY == -1))
            {
                BeforeDraw();
            }

            lastDrawY = r.y;

#if H2_DEV
            Profiler.BeginSample("h2_ParentIndicator.Draw");
#endif
            if (drawEnded)
            {
#if H2_DEV
                Profiler.EndSample();
#endif
                return(MaxWidth);
            }

            if ((drawList == null) || (drawList.Count == 0))
            {
#if H2_DEV
                Debug.LogWarning("Something wrong, drawList should not be null or empty");
#endif
                return(0);
            }

            var t         = go.transform;
            var firstDraw = false;

            if (pIndex == -1)
            {
                firstDraw = true;

                if (t == drawList[0])
                {
                    // new root !
                    pIndex = 0;
                    //drawY[pIndex] = r.y;
                    //dLevel = 0;
                }
                else if (lastDraw == null)
                {
                    var pList = GetParents(t, true, true);

                    lastDraw = t;
                    var dLevel = pList.Count;

                    var max = Mathf.Min(dLevel, drawList.Count);
                    for (var i = 0; i < max; i++)
                    {
                        if (pList[i] != drawList[i])
                        {
                            break;
                        }
                        //Debug.Log(drawList[i] + " ---> " + i);
                        pIndex = i;
                    }

                    //Debug.Log(go.name + " ---> " + pIndex);
                }

                if (pIndex != -1)
                {
                    if ((maxY > 0) && (r.y > maxY) && !lastPOpen)
                    {
#if H2_PI_DEBUG
                        Debug.Log(" --> Early end Draw " + t.name + " pIndex = " + pIndex + " because of y out of range maxY=" + maxY + "\n" + r);
#endif
                        drawEnded = true;
                    }
#if H2_PI_DEBUG
                    else
                    {
                        Debug.Log(" --> First Draw " + t.name + ": pIndex = " + pIndex + " isOpen = " + lastPOpen + " maxY = " + maxY + "\n" + r);
                    }
#endif
                }
            }

            if (pIndex != -1)
            {
                var dNext = pIndex < drawList.Count - 1 ? drawList[pIndex + 1] : null;

                if (!firstDraw)
                {
                    if (t == dNext)
                    {
                        pIndex++;
                        lastPOpen = t != st;
                        //drawY[pIndex] = r.y;
                    }
                    else
                    {
                        var p = t.parent;
                        if (p == lastDraw)
                        {
                            if (lastDraw == drawList[pIndex])
                            {
                                lastPOpen = t != st;
                            }

                            //go-to-child
                        }
                        else if (p == lastDraw.parent)
                        {
                            //sibling
                            if (p == drawList[pIndex].parent)
                            {
#if H2_PI_DEBUG
                                Debug.Log("Cross sibling ! " + pIndex + ":" + p + ":" + drawList[pIndex]);
#endif
                                drawEnded = true;
                                lastPOpen = false; //t == st;
                            }
                        }
                        else //going up or jumps to another root
                        {
                            if (drawMap == null)
                            {
                                RefreshDrawMap();
                            }

                            if (lastDraw == drawList[pIndex])
                            {
                                lastPOpen = false;
                            }

                            //We do need to check from t (t == dNext won't catch the case when t jumps up)
                            p = t;
                            var found = false;

                            while (p != null)
                            {
                                int v;
                                if (drawMap.TryGetValue(p, out v)) //found in map !
                                {
                                    found     = true;
                                    drawEnded = pIndex > v; // draw ends when jumps out (pIndex decrease)
                                    pIndex    = v;
                                    break;
                                }

                                p = p.parent;
                            }

                            if (drawEnded || !found)
                            {
                                drawEnded = true;
                                maxY      = r.y - 1; // important : -1 pixel so that don't draw this object <t>
#if H2_PI_DEBUG
                                Debug.LogWarning("jumps out maxY ---> pIndex = " + pIndex + " : maxY = " + maxY + ":" + t.name + "\n" + r);
#endif
                            }
                        }
                    }
                }

                if (!drawEnded)
                {
                    //Debug.Log(" --> Draw " + pIndex + " --> "+ t.name + "\n" + r);

                    if ((pIndex != 0) || (go.transform != drawList[0]))
                    {
                        DrawLine(go,
                                 t == st
                                ? h2_PILine.horizontal
                                : (t == dNext) || (t == drawList[pIndex]) ? h2_PILine.corner : h2_PILine.vertical,
                                 pIndex, r
                                 );
                    }

                    lastDraw = t;

                    if (t == st)
                    {
                        drawEnded = true;
                        maxY      = r.y - 1; // important : -1 pixel so that don't draw this object <t>
#if H2_PI_DEBUG
                        Debug.LogWarning("special --> maxY ---> " + maxY + ":" + t.name);
#endif
                    }
                }
            }
#if H2_DEV
            Profiler.EndSample();
#endif
            return(MaxWidth);
        }
예제 #15
0
파일: PLua.cs 프로젝트: luankun/hugula
        // private void RegisterFunc()
        // {
        //  Lua.mainState.loaderDelegate = Loader;
        // }

        /// <summary>
        ///  loader
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        private byte[] Loader(string name)
        {
#if DEBUG
            Profiler.BeginSample("PLua Loader " + name);
#endif
            byte[] str = null;
#if UNITY_EDITOR
            string name1 = name.Replace('.', '/');
            string path  = Application.dataPath + "/Lua/" + name1 + ".lua";
            if (!File.Exists(path))
            {
                path = Application.dataPath + "/Config/" + name1 + ".lua";
            }

            if (File.Exists(path))
            {
                str = LuaState.CleanUTF8Bom(File.ReadAllBytes(path));
            }
            else
            {
                Debug.LogWarningFormat("lua({0}) path={1} not exists.", name, path);
                name = name.Replace('.', '+').Replace('/', '+');
                str  = LoadLuaBytes(name);
            }
#else
            name = name.Replace('.', '+').Replace('/', '+');
            string cryName = "";
            if (System.IntPtr.Size == 4)
            {
                cryName = CUtils.GetRightFileName(name);
            }
            else
            {
                cryName = CUtils.GetRightFileName(string.Format("{0}_64", name));
            }

            string abName   = cryName + Common.CHECK_ASSETBUNDLE_SUFFIX;
            bool   isupdate = ManifestManager.CheckIsUpdateFile(abName);

            #if !HUGULA_NO_LOG
            Debug.LogFormat("loader lua {0}={1}", name, cryName);
            #endif

            string path = null;
            if (isupdate && File.Exists(path = CUtils.PathCombine(CUtils.realPersistentDataPath, abName)))
            {
                str = File.ReadAllBytes(path);
            }
            else
            {
                var textAsset = (TextAsset)Resources.Load("luac/" + cryName);
                if (textAsset == null)
                {
                    Debug.LogWarningFormat("lua({0}={1}) bytes error!", name, cryName);
                }
                else
                {
                    str = textAsset.bytes; // --Resources.Load
                }
                Resources.UnloadAsset(textAsset);
            }
#endif
 #if DEBUG
            Profiler.EndSample();
#endif
            return(str);
        }
예제 #16
0
        public override float Draw(Rect r, GameObject go)
        {
#if H2_DEV
            Profiler.BeginSample("h2_Combine.Draw");
#endif

            if (go == null || go.transform.childCount == 0)
            {
#if H2_DEV
                Profiler.EndSample();
#endif
                return(0);
            }

            if (h2_Lazy.isMouseDown)
            {
                var icoRect = h2_Utils.subRectRight(r, MaxWidth);
                h2_GUI.Check(icoRect, go, CombineGO);
#if H2_DEV
                Profiler.EndSample();
#endif
                return(MaxWidth);
            }

            if (h2_Lazy.isRepaint)
            {
                var t = go.transform;
                var n = t.childCount;

#if CACHE_INT
                string lb;
                if (!intCache.TryGetValue(n, out lb))
                {
                    lb = n.ToString();
                    intCache.Add(n, lb);
                }
                ;
#else
                var lb = n.ToString();
#endif

                var v        = isCombined(t);
                var icoRect2 = h2_Utils.subRectRight(r, MaxWidth);

                if (v)
                {
                    var tex = h2_GUI.miniButton.normal.background;
                    //GUI.DrawTexture(new Rect(icoRect2.x, icoRect2.y + 2, tex.width, tex.height), tex);
                    icoRect2.height = tex.height;
                    GUI.Button(icoRect2, lb, h2_GUI.miniButton);
                }
                else
                {
                    var w = h2_GUI.GetMiniLabelWidth(lb);
                    icoRect2.x    += icoRect2.width - w;
                    icoRect2.width = w;
                    GUI.Label(icoRect2, lb, h2_GUI.miniLabel);
                }
            }

#if H2_DEV
            Profiler.EndSample();
#endif
            return(MaxWidth);
        }
예제 #17
0
        private static void HierarchyItemCB(int instID, Rect r)
        {
#if H2_DEV
            Profiler.BeginSample("Hierarchy2.HierarchyItemCB");
#endif

            if (h2_Setting.current == null)
            {
                return;
            }

            var go = (GameObject)EditorUtility.InstanceIDToObject(instID);
            if (go == null)
            {
                return;
            }

            // REFRESH ICON LIST - IF NECESSARY
            if (IconList2 == null)
            {
                Refresh();
            }
            if (h2_Lazy.RESET_STAMP != h2_Setting.RESET_STAMP)
            {
#if H2_DEV
                Profiler.BeginSample("Hierarchy2.HierarchyItemCB-RefreshSettings");
#endif
                for (var i = 0; i < IconList2.Count; i++)
                {
                    IconList2[i].RefreshSettings();
                }
#if H2_DEV
                Profiler.EndSample();
#endif

                h2_Lazy.RESET_STAMP = h2_Setting.RESET_STAMP;
            }

            // REFRESH EVENTS - IF NECCESSARY
#if H2_DEV
            Profiler.BeginSample("Hierarchy2.HierarchyItemCB-RefreshEvent");
#endif

            var cs = h2_Setting.current.Common;
            var e  = Event.current;
            //var isMouse = e.isMouse;

            lastRepaintTime = Time.realtimeSinceStartup;

            if (h2_Lazy.eventType != e.type || (e.type == EventType.Repaint && instID == firstInst))
            {
                h2_Lazy.eventType   = e.type;
                h2_Lazy.isRepaint   = e.type == EventType.Repaint;
                h2_Lazy.isMouseDown = e.type == EventType.MouseDown;
                h2_Lazy.isPlaying   = EditorApplication.isPlaying;
                h2_Lazy.isPro       = EditorGUIUtility.isProSkin;
                h2_Lazy.isFocus     = h2_Unity.focusingHierarchy;

                var lastRename = h2_Lazy.isRenaming;
                h2_Lazy.isRenaming = h2_Unity.IsRenaming;
                if (lastRename != h2_Lazy.isRenaming)
                {
                    h2_Utils.DelayRepaintHierarchy();
                }

                h2_Selection.CheckIfSelectionChanged();



                if (cs.drawBackground)
                {
                    h2_Lazy.bgColor = h2_Color.GetBGColor(false, h2_Lazy.isFocus, h2_Lazy.isPro);

                    if (cs.drawSelectionBackground)
                    {
                        h2_Lazy.bgColorSelected = h2_Color.GetBGColor(true, h2_Lazy.isFocus, h2_Lazy.isPro);
                    }
                }

                if (lastMouseDownOn != 0 && e.type == EventType.MouseUp)
                {
                    lastMouseDownOn = 0;
                }

                if (!h2_Lazy.isRepaint && e.type != EventType.Used)
                {
                    firstInst = instID;
                }

                lastDrawIcon = 0;
                for (var i = 0; i < IconList2.Count; i++)
                {
                    var ic = IconList2[i];
                    if (ic.setting == null || ic.setting.enableIcon)
                    {
                        lastDrawIcon = i + 1;
                    }
                }

                if ((e.isMouse || e.type == EventType.Used) && h2_Unity.HierarchyWindow.wantsMouseMove)
                {
                    h2_Utils.DelayRepaintHierarchy();
                }

                //Debug.Log(instID + ":" + e + ":" + h2_Lazy.isRepaint + ":" + h2_Lazy.isRenaming + ":" + cs.drawBackground);
            }

#if H2_DEV
            Profiler.EndSample();
#endif

#if H2_DEV
            Profiler.BeginSample("Hierarchy2.HierarchyItemCB-DoDraw");
#endif

            if (cs.enableShortcut && !h2_Lazy.isRenaming)
            {
                h2_Shortcut.Api.Check();
            }

            if (!cs.enableIcon)
            {
                _width = 0;
#if H2_DEV
                Profiler.EndSample();
                Profiler.EndSample();
#endif
                return;
            }

            var goW      = GetWidth(instID);
            var bgRect   = new Rect(r.x + r.width - goW, r.y, goW, r.height);
            var isLocked = instID == _inspectorLocked;


            if (h2_Lazy.isRepaint)
            {
                if (isLocked)
                {
                    var rr = new Rect(0, bgRect.y, Screen.width, bgRect.height);
                    h2_GUI.SolidColor(rr, new Color32(255, 0, 0, 64));
                }
                else if (cs.drawBackground)
                {
                    // DRAW CORRECT BACKGROUND FOR ACTIVE ITEM
                    if (!h2_Lazy.isRenaming || h2_Selection.gameObject != go)
                    {
                        if (cs.drawSelectionBackground)
                        {
                            var matched = false;
                            if (lastMouseDownOn != 0)
                            {
                                if (lastMouseDownSingle)
                                {
                                    matched = instID == lastMouseDownOn;
                                }
                                else
                                {
                                    matched = (instID == lastMouseDownOn) || h2_Selection.Contains(go);
                                }
                            }
                            else
                            {
                                matched = h2_Selection.Contains(go);
                            }
                            h2_GUI.SolidColor(bgRect, matched ? h2_Lazy.bgColorSelected : h2_Lazy.bgColor);
                        }
                        else
                        {
                            h2_GUI.SolidColor(bgRect, h2_Lazy.bgColor);
                        }
                    }
                }
            }

            float spc = cs.iconSpace;
            _width   = r.width;
            r.width -= cs.iconOffset;

            var n = lastDrawIcon;

            for (var i = 0; i < n; i++)
            {
                var ico = IconList2[i];
                if (ico.setting != null && !ico.setting.enableIcon)
                {
                    continue;
                }

                var dw = ico.Draw(r, go);

                if (i == n - 1)
                {
                    if (dw > 0)
                    {
                        r.width -= dw + spc;
                    }
                }
                else
                {
                    r.width -= ico.MaxWidth + spc;
                }
            }

            var ww = _width - r.width;
            if (h2_Lazy.isRepaint && (goW != ww))
            {
                SetWidth(instID, (int)ww);
                h2_Utils.DelayRepaintHierarchy();
            }

            _width = ww;

            if (e.type == EventType.MouseDown && (e.button == 0))
            {
                if (bgRect.Contains(e.mousePosition))
                {
                    //Debug.Log("Swallow mouse : ");
                    e.Use();
                }
                else if (cs.drawSelectionBackground)
                {
                    var rowRect = new Rect(0, r.y, r.x + r.width, r.height);
                    if (rowRect.Contains(e.mousePosition))
                    {
                        if (go.transform.childCount > 0)
                        {
                            var arrowRect = new Rect(r.x - 16f, r.y, 16f, 16f);
                            //h2_GUI.SolidColor(arrowRect, Color.white);
                            if (arrowRect.Contains(e.mousePosition))
                            {
                                lastMouseDownOn = 0;
#if H2_DEV
                                Profiler.EndSample();
                                Profiler.EndSample();
#endif

                                return;
                            }
                        }

                        lastMouseDownOn     = instID;
                        lastMouseDownSingle = !e.control && !e.shift;
                    }
                }
            }

#if H2_DEV
            Profiler.EndSample();
            Profiler.EndSample();
#endif

            //Profiler.EndSample();

            //
            //if (IconList == null) Refresh();

            //var info = h3_Info.Get(instID, true);
            //if (info == null) {
            //	// CAN BE NULL AS OF UNITY_5_4 MULTISCENE
            //	//Debug.Log("Info is null !");
            //	return;
            //}


            //var evtType = Event.current.type;
            //var isRepaint = evtType == EventType.Repaint;
            //var s = h3_Setting.Settings;
            //var willRepaint = false;
            //var effectiveRect = h2_Utils.subRectRight(r, info.lastW + s.iconSpacing + s.iconPadding);

            //if (isRepaint && s.clearBackground && !info.inSelection)
            //{
            //	h2_GUI.SolidColor(effectiveRect, h3_Setting.CurrentTheme.BackgroundColor);
            //}

            //r.xMax -= s.iconPadding;
            //var totalW = 0f;

            //for (var i = 0;i < IconList.Count; i++){
            //	var icon = IconList[i];
            //	var oldW = icon.MaxWidth;
            //	var newW = icon.Draw(r, isRepaint, info);
            //	totalW += (i == IconList.Count-1) ? newW : icon.MaxWidth;
            //	r.xMax -= icon.MaxWidth;

            //	if (oldW < icon.MaxWidth && !isRepaint) {
            //		willRepaint = true;
            //	}
            //}

            //if (isRepaint) info.lastW = totalW;

            //if (info.dIndex == 0 && !isRepaint){
            //	_width = info.lastW;
            //} else if (info.lastW > _width) {
            //	_width = info.lastW;
            //}

            //if (willRepaint) h2_Utils.DelayRepaintHierarchy();
        }
예제 #18
0
        private static h2_ScriptState GetState(GameObject go, float expire)
        {
#if H2_DEV
            Profiler.BeginSample("h2_Script.GetState");
#endif

            if (stateMap == null)
            {
                stateMap = new Dictionary <GameObject, h2_ScriptInfo>();
            }

            h2_ScriptInfo info;
            if (stateMap.TryGetValue(go, out info))
            {
                var dTime = Time.realtimeSinceStartup - info.time;
                if (dTime < expire)
                {
#if H2_DEV
                    Profiler.EndSample();
#endif

                    return(info.state);
                }
                stateMap.Remove(go);

                //Debug.Log("Force refresh : " + go + ":" + expire + ":" + dTime);
            }

            //scan for missing reference
            info = new h2_ScriptInfo {
                state = h2_ScriptState.None
            };

            var components = go.GetComponents <Component>();
            for (var i = 0; i < components.Length; i++)
            {
                var c = components[i];

                //Debug.Log(i + ":" + c);
                if (c == null)
                {
                    info.state = h2_ScriptState.Missing;
                    //Debug.Log("Missing : " + i);
                    break;
                }

                if (info.state != h2_ScriptState.Script)
                {
                    if (c is MonoBehaviour && isValidScript(c))
                    {
                        info.state = h2_ScriptState.Script;
                    }
                }
            }

            stateMap.Add(go, info);

#if H2_DEV
            Profiler.EndSample();
#endif
            return(info.state);
        }
예제 #19
0
 internal int EndProfileReturn(int value)
 {
     Profiler.EndSample();
     return(value);
 }
예제 #20
0
        /// <summary>
        /// finish asset or http request
        /// </summary>
        /// <param name="operation"></param>
        internal static void ProcessFinishedOperation(ResourcesLoadOperation operation)
        {
            HttpLoadOperation httpLoad;
            var req = operation.cRequest;

            operation.Done();

            if (operation is LoadAssetBundleInternalOperation)
            {
#if DEBUG
                Profiler.BeginSample("ProcessFinishedOperation AssetbundleDone " + req.assetName);
#endif
                CallOnAssetBundleComplete(req, ((LoadAssetBundleInternalOperation)operation).assetBundle);
                downloadingBundles.Remove(req.key);
                if (req.isShared)
                {
                    req.ReleaseToPool();
                }
                operation.ReleaseToPool();
                LoadingBundleQueue();
#if DEBUG
                Profiler.EndSample();
#endif
            }
            else if ((httpLoad = operation as HttpLoadOperation) != null)
            {
                bool isError = !string.IsNullOrEmpty(httpLoad.error);
                if (isError && CUtils.IsResolveHostError(httpLoad.error) && !CUtils.IsHttps(req.url))   // http dns
                {
                    // req.error = httpLoad.error;
                    Debug.LogFormat("dns resolve error url={0} ", req.url);
                    // httpLoad.error = string.Format ("dns resolve error url={0} ", req.url);
                    var httpDnsOp = OperationPools <HttpDnsResolve> .Get(); // HttpDnsResolve.Get();

                    httpDnsOp.SetRequest(req);
                    httpDnsOp.SetOriginalOperation(httpLoad);
                    inProgressOperations.Add(httpDnsOp);
                    httpDnsOp.Start();
                }
                else
                {
#if DEBUG
                    Profiler.BeginSample("ProcessFinishedOperation HttpDone " + req.url);
#endif
                    operation.ReleaseToPool();
                    try {
                        if (isError)
                        {
                            req.DispatchEnd();
                        }
                        else
                        {
                            req.DispatchComplete();
                        }
                    } catch (System.Exception e) {
                        Debug.LogError(e);
                    }

                    if (req.group != null)
                    {
                        req.group.Complete(req, isError);
                    }

                    req.ReleaseToPool();
#if DEBUG
                    Profiler.EndSample();
#endif
                }
            }
            else
            {
#if DEBUG
                Profiler.BeginSample("ProcessFinishedOperation AssetDone " + req.assetName);
#endif
                loadingTasks.Remove(req);
                operation.ReleaseToPool();

                DispatchReqAssetOperation(req, req.error != null);
#if DEBUG
                Profiler.EndSample();
#endif
                CheckAllComplete();
            }
        }
예제 #21
0
 public static void EndSample()
 {
                 #if DEV_MODE || PROFILE_POWER_INSPECTOR
     UnityProfiler.EndSample();
                 #endif
 }