CustomHierarchy.DrawRectIcon(UnityEngine.Rect, UnityEngine.GameObject, UnityEngine.Color, ref int, ref UnityEngine.GUIStyle)

Here are the examples of the csharp api CustomHierarchy.DrawRectIcon(UnityEngine.Rect, UnityEngine.GameObject, UnityEngine.Color, ref int, ref UnityEngine.GUIStyle) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

1 Examples 7

19 View Source File : CustomHierarchy.cs
License : MIT License
Project Creator : liangxiegame

static void HierarchWindowOnGui(int instanceId, Rect selectionRect)
    {
        if (!EnableCustomHierarchy) return;
        try
        {
            // CheckBox // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
            var rectCheck = new Rect(selectionRect);
            rectCheck.x += rectCheck.width - 20;
            rectCheck.width = 18;

            // 通过ID获得Obj
            var obj = EditorUtility.InstanceIDToObject(instanceId);
            var go = (GameObject)obj;// as GameObject;

            // 绘制Checkbox 
            go.SetActive(GUI.Toggle(rectCheck, go.activeSelf, string.Empty));

            // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
            // 图标的序列号
            var index = 0;
            GUIStyle style = null;

            // is Static 
            if (go.isStatic)
            {
                index += 1;
                var rectIcon = CreateRect(selectionRect, index);
                GUI.Label(rectIcon, "S");
            }

            // 文字颜色定义 
            var colorMesh = new Color(42 / 255f, 210 / 255f, 235 / 255f);
            var colorSkinMesh = new Color(0.78f, 0.35f, 0.78f);
            var colorLight = new Color(251 / 255f, 244 / 255f, 124 / 255f);
            var colorPhysic = new Color(0.35f, 0.75f, 0f);
            var colorCollider = new Color(0.35f, 0.75f, 0.196f);
            var colorAnimation = new Color(175 / 255f, 175 / 255f, 218 / 255f);
            var colorCamera = new Color(111 / 255f, 121 / 255f, 212 / 255f);
            var colorParticle = new Color(130 / 255f, 124 / 255f, 251 / 255f);
            var colorNav = new Color(217 / 255f, 80 / 255f, 62 / 255f);
            var colorNetwork = new Color(42 / 255f, 129 / 255f, 235 / 255f);
            var colorAudio = new Color(255 / 255f, 126 / 255f, 0f);

            // Draw //  -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
            // 可以在此修改,根据需要删减需要绘制的内容
            // Renderer
            DrawRectIcon<MeshRenderer>(selectionRect, go, colorMesh, ref index, ref style);
            DrawRectIcon<SkinnedMeshRenderer>(selectionRect, go, colorSkinMesh, ref index, ref style);
            // Colliders
            DrawRectIcon<BoxCollider>(selectionRect, go, colorCollider, ref index, ref style);
            DrawRectIcon<SphereCollider>(selectionRect, go, colorCollider, ref index, ref style);
            DrawRectIcon<CapsuleCollider>(selectionRect, go, colorCollider, ref index, ref style);
            DrawRectIcon<MeshCollider>(selectionRect, go, colorCollider, ref index, ref style);
            DrawRectIcon<CharacterController>(selectionRect, go, colorCollider, ref index, ref style);
            // RigidBody
            DrawRectIcon<Rigidbody>(selectionRect, go, colorPhysic, ref index, ref style);
            // Lights
            DrawRectIcon<Light>(selectionRect, go, colorLight, ref index, ref style);
            // Joints

            // Animation / Animator
            DrawRectIcon<Animator>(selectionRect, go, colorAnimation, ref index, ref style);
            DrawRectIcon<Animation>(selectionRect, go, colorAnimation, ref index, ref style);
            // Camera / Projector
            DrawRectIcon<Camera>(selectionRect, go, colorCamera, ref index, ref style);
            DrawRectIcon<Projector>(selectionRect, go, colorCamera, ref index, ref style);
            // NavAgent
            DrawRectIcon<NavMeshAgent>(selectionRect, go, colorNav, ref index, ref style);
            DrawRectIcon<NavMeshObstacle>(selectionRect, go, colorNav, ref index, ref style);
            // Network
            DrawRectIcon<NetworkIdenreplacedy>(selectionRect, go, colorNetwork, ref index, ref style);
            DrawRectIcon<NetworkAnimator>(selectionRect, go, colorNetwork, ref index, ref style);
            DrawRectIcon<NetworkTransform>(selectionRect, go, colorNetwork, ref index, ref style);
            DrawRectIcon<NetworkBehaviour>(selectionRect, go, colorNetwork, ref index, ref style);
            DrawRectIcon<NetworkManager>(selectionRect, go, colorNetwork, ref index, ref style);
            // Particle
            DrawRectIcon<ParticleSystem>(selectionRect, go, colorParticle, ref index, ref style);
            // Audio
            DrawRectIcon<AudioSource>(selectionRect, go, colorAudio, ref index, ref style);

            // 绘制Label来覆盖原有的名字
            if (style != null && go.activeInHierarchy)
            {
                GUI.Label(/*selectionRect*/new Rect(selectionRect.x - 2, selectionRect.y, selectionRect.width, selectionRect.height + 2), go.name, style);
            }
        }
        catch (Exception)
        {
        }
    }