コード例 #1
0
 private void HandleMeshFilterInfo(GameObject go, ref int vertices, ref int meshTriangles, ref int meshCount)
 {
     Component[] componentsInChildren = go.GetComponentsInChildren(typeof(MeshFilter));
     for (int i = 0; i < componentsInChildren.Length; i++)
     {
         MeshFilter filter = componentsInChildren[i];
         vertices      += filter.get_sharedMesh().get_vertexCount();
         meshTriangles += filter.get_sharedMesh().get_triangles().Length / 3;
         meshCount++;
     }
 }
コード例 #2
0
    public static void GetRangeIndex(GameObject obj, out int[] rangeIndex)
    {
        rangeIndex = (int[])null;
        if (Object.op_Equality((Object)null, (Object)obj))
        {
            return;
        }
        List <int> intList    = new List <int>();
        MeshFilter meshFilter = new MeshFilter();
        MeshFilter component1 = obj.GetComponent(typeof(MeshFilter)) as MeshFilter;

        if (Object.op_Inequality((Object)null, (Object)component1))
        {
            for (int index = 0; index < component1.get_sharedMesh().get_colors().Length; ++index)
            {
                if (component1.get_sharedMesh().get_colors()[index].r == 1.0)
                {
                    intList.Add(index);
                }
            }
        }
        else
        {
            SkinnedMeshRenderer skinnedMeshRenderer = new SkinnedMeshRenderer();
            SkinnedMeshRenderer component2          = obj.GetComponent(typeof(SkinnedMeshRenderer)) as SkinnedMeshRenderer;
            if (Object.op_Implicit((Object)component2))
            {
                for (int index = 0; index < component2.get_sharedMesh().get_colors().Length; ++index)
                {
                    if (component2.get_sharedMesh().get_colors()[index].r == 1.0)
                    {
                        intList.Add(index);
                    }
                }
            }
        }
        if (intList.Count != 0)
        {
            rangeIndex = new int[intList.Count];
            for (int index = 0; index < intList.Count; ++index)
            {
                rangeIndex[index] = intList[index];
            }
        }
        else
        {
            rangeIndex = (int[])null;
        }
    }
コード例 #3
0
 private void ApplyColorAndTint()
 {
     //IL_0012: Unknown result type (might be due to invalid IL or missing references)
     //IL_0018: Unknown result type (might be due to invalid IL or missing references)
     //IL_001d: Unknown result type (might be due to invalid IL or missing references)
     m_font.ChangeMeshColor(m_meshFilter.get_sharedMesh(), m_color, Color.op_Implicit(m_tint));
 }
コード例 #4
0
    public static void GetNormalData(GameObject obj, List <Vector3> normal)
    {
        if (Object.op_Equality((Object)null, (Object)obj))
        {
            return;
        }
        MeshFilter meshFilter = new MeshFilter();
        MeshFilter component1 = obj.GetComponent(typeof(MeshFilter)) as MeshFilter;

        if (Object.op_Inequality((Object)null, (Object)component1))
        {
            foreach (Vector3 normal1 in component1.get_sharedMesh().get_normals())
            {
                normal.Add(normal1);
            }
        }
        else
        {
            SkinnedMeshRenderer skinnedMeshRenderer = new SkinnedMeshRenderer();
            SkinnedMeshRenderer component2          = obj.GetComponent(typeof(SkinnedMeshRenderer)) as SkinnedMeshRenderer;
            if (!Object.op_Implicit((Object)component2))
            {
                return;
            }
            foreach (Vector3 normal1 in component2.get_sharedMesh().get_normals())
            {
                normal.Add(normal1);
            }
        }
    }
コード例 #5
0
    public static ResourceObject Get(RESOURCE_CATEGORY category, string name, Object obj)
    {
        //IL_00a5: Unknown result type (might be due to invalid IL or missing references)
        //IL_00aa: Unknown result type (might be due to invalid IL or missing references)
        //IL_00af: Expected O, but got Unknown
        //IL_00d8: Unknown result type (might be due to invalid IL or missing references)
        //IL_00dd: Expected O, but got Unknown
        //IL_0101: Unknown result type (might be due to invalid IL or missing references)
        //IL_0106: Expected O, but got Unknown
        ResourceObject resourceObject = rymTPool <ResourceObject> .Get();

        resourceObject._refCount = 0;
        resourceObject.category  = category;
        resourceObject.obj       = obj;
        resourceObject.name      = name;
        switch (resourceObject.category)
        {
        case RESOURCE_CATEGORY.EFFECT_TEX:
        case RESOURCE_CATEGORY.PLAYER_HIGH_RESO_TEX:
        case RESOURCE_CATEGORY.SOUND_VOICE:
            willReleaseList.Add(resourceObject.obj);
            break;

        case RESOURCE_CATEGORY.PLAYER_ARM:
        case RESOURCE_CATEGORY.PLAYER_BDY:
        case RESOURCE_CATEGORY.PLAYER_FACE:
        case RESOURCE_CATEGORY.PLAYER_HEAD:
        case RESOURCE_CATEGORY.PLAYER_LEG:
        case RESOURCE_CATEGORY.PLAYER_WEAPON:
        {
            GameObject val = resourceObject.obj as GameObject;
            if (val != null)
            {
                Renderer componentInChildren = val.GetComponentInChildren <Renderer>();
                willReleaseList.Add(componentInChildren.get_sharedMaterial().get_mainTexture());
                if (componentInChildren is MeshRenderer)
                {
                    MeshFilter component = componentInChildren.GetComponent <MeshFilter>();
                    if (component != null)
                    {
                        willReleaseList.Add(component.get_sharedMesh());
                    }
                }
                else if (componentInChildren is SkinnedMeshRenderer)
                {
                    SkinnedMeshRenderer val2 = componentInChildren as SkinnedMeshRenderer;
                    willReleaseList.Add(val2.get_sharedMesh());
                }
            }
            break;
        }
        }
        if (willReleaseList.Count > 0)
        {
            resourceObject.willReleaseObjs = willReleaseList.ToArray();
            willReleaseList.Clear();
        }
        return(resourceObject);
    }
コード例 #6
0
    public static List <ServerGib> CreateGibs(
        string entityToCreatePath,
        GameObject creator,
        GameObject gibSource,
        Vector3 inheritVelocity,
        float spreadVelocity)
    {
        List <ServerGib> serverGibList = new List <ServerGib>();

        foreach (MeshRenderer componentsInChild in (MeshRenderer[])gibSource.GetComponentsInChildren <MeshRenderer>(true))
        {
            MeshFilter component1         = (MeshFilter)((Component)componentsInChild).GetComponent <MeshFilter>();
            Vector3    localPosition1     = ((Component)componentsInChild).get_transform().get_localPosition();
            Vector3    normalized         = ((Vector3) ref localPosition1).get_normalized();
            Matrix4x4  localToWorldMatrix = creator.get_transform().get_localToWorldMatrix();
            Vector3    pos    = Vector3.op_Addition(((Matrix4x4) ref localToWorldMatrix).MultiplyPoint(((Component)componentsInChild).get_transform().get_localPosition()), Vector3.op_Multiply(normalized, 0.5f));
            Quaternion rot    = Quaternion.op_Multiply(creator.get_transform().get_rotation(), ((Component)componentsInChild).get_transform().get_localRotation());
            BaseEntity entity = GameManager.server.CreateEntity(entityToCreatePath, pos, rot, true);
            if (Object.op_Implicit((Object)entity))
            {
                ServerGib component2 = (ServerGib)((Component)entity).GetComponent <ServerGib>();
                ((Component)component2).get_transform().set_position(pos);
                ((Component)component2).get_transform().set_rotation(rot);
                component2._gibName = ((Object)componentsInChild).get_name();
                component2.PhysicsInit(component1.get_sharedMesh());
                Vector3 localPosition2 = ((Component)componentsInChild).get_transform().get_localPosition();
                Vector3 vector3_1      = Vector3.op_Multiply(((Vector3) ref localPosition2).get_normalized(), spreadVelocity);
                component2.rigidBody.set_velocity(Vector3.op_Addition(inheritVelocity, vector3_1));
                Rigidbody rigidBody = component2.rigidBody;
                Vector3   vector3_2 = Vector3Ex.Range(-1f, 1f);
                Vector3   vector3_3 = Vector3.op_Multiply(((Vector3) ref vector3_2).get_normalized(), 1f);
                rigidBody.set_angularVelocity(vector3_3);
                component2.rigidBody.WakeUp();
                component2.Spawn();
                serverGibList.Add(component2);
            }
        }
        foreach (ServerGib serverGib1 in serverGibList)
        {
            foreach (ServerGib serverGib2 in serverGibList)
            {
                if (!Object.op_Equality((Object)serverGib1, (Object)serverGib2))
                {
                    Physics.IgnoreCollision((Collider)serverGib2.GetCollider(), (Collider)serverGib1.GetCollider(), true);
                }
            }
        }
        return(serverGibList);
    }
コード例 #7
0
 public static void DrawMeshes(Transform transform)
 {
     foreach (MeshRenderer componentsInChild in (MeshRenderer[])((Component)transform).GetComponentsInChildren <MeshRenderer>())
     {
         if (((Renderer)componentsInChild).get_enabled())
         {
             MeshFilter component = (MeshFilter)((Component)componentsInChild).GetComponent <MeshFilter>();
             if (Object.op_Implicit((Object)component))
             {
                 Transform transform1 = ((Component)componentsInChild).get_transform();
                 Gizmos.DrawMesh(component.get_sharedMesh(), transform1.get_position(), transform1.get_rotation(), transform1.get_lossyScale());
             }
         }
     }
 }
コード例 #8
0
    private void Start()
    {
        FadeInOutShaderFloat component1 = (FadeInOutShaderFloat)((Component)this).GetComponent <FadeInOutShaderFloat>();

        if (Object.op_Equality((Object)component1, (Object)null))
        {
            return;
        }
        Transform           parent     = ((Component)this).get_transform().get_parent();
        SkinnedMeshRenderer component2 = (SkinnedMeshRenderer)((Component)parent).GetComponent <SkinnedMeshRenderer>();
        Mesh sharedMesh;

        if (Object.op_Inequality((Object)component2, (Object)null))
        {
            sharedMesh = component2.get_sharedMesh();
        }
        else
        {
            MeshFilter component3 = (MeshFilter)((Component)parent).GetComponent <MeshFilter>();
            if (Object.op_Equality((Object)component3, (Object)null))
            {
                return;
            }
            sharedMesh = component3.get_sharedMesh();
        }
        if (!sharedMesh.get_isReadable())
        {
            component1.MaxFloat = 0.0f;
        }
        else
        {
            int length = sharedMesh.get_triangles().Length;
            if (length >= 1000)
            {
                return;
            }
            if (length > 500)
            {
                component1.MaxFloat = (float)((double)length / 1000.0 - 0.5);
            }
            else
            {
                component1.MaxFloat = 0.0f;
            }
        }
    }
コード例 #9
0
    public static void GetMeshInfo(GameObject selObj, bool bInChildren, out int nVertices, out int nTriangles, out int nMeshCount)
    {
        nVertices  = 0;
        nTriangles = 0;
        nMeshCount = 0;
        if (selObj == null)
        {
            return;
        }
        Component[] array;
        Component[] array2;
        if (bInChildren)
        {
            array  = selObj.GetComponentsInChildren(typeof(SkinnedMeshRenderer));
            array2 = selObj.GetComponentsInChildren(typeof(MeshFilter));
        }
        else
        {
            array  = selObj.GetComponents(typeof(SkinnedMeshRenderer));
            array2 = selObj.GetComponents(typeof(MeshFilter));
        }
        ArrayList arrayList = new ArrayList(array2.Length + array.Length);

        for (int i = 0; i < array2.Length; i++)
        {
            MeshFilter meshFilter = (MeshFilter)array2[i];
            arrayList.Add(meshFilter.get_sharedMesh());
        }
        for (int j = 0; j < array.Length; j++)
        {
            SkinnedMeshRenderer skinnedMeshRenderer = (SkinnedMeshRenderer)array[j];
            arrayList.Add(skinnedMeshRenderer.get_sharedMesh());
        }
        for (int k = 0; k < arrayList.get_Count(); k++)
        {
            Mesh mesh = (Mesh)arrayList.get_Item(k);
            if (mesh != null)
            {
                nVertices  += mesh.get_vertexCount();
                nTriangles += mesh.get_triangles().Length / 3;
                nMeshCount++;
            }
        }
    }
コード例 #10
0
    public void Update()
    {
        MeshFilter meshFilter = new MeshFilter();
        MeshFilter component  = ((Component)this).get_gameObject().GetComponent(typeof(MeshFilter)) as MeshFilter;
        Mesh       sharedMesh;

        if (Object.op_Implicit((Object)component))
        {
            sharedMesh = component.get_sharedMesh();
        }
        else
        {
            SkinnedMeshRenderer skinnedMeshRenderer = new SkinnedMeshRenderer();
            sharedMesh = (((Component)this).get_gameObject().GetComponent(typeof(SkinnedMeshRenderer)) as SkinnedMeshRenderer).get_sharedMesh();
        }
        if (!Object.op_Inequality((Object)null, (Object)sharedMesh))
        {
            return;
        }
        sharedMesh.RecalculateNormals();
    }
コード例 #11
0
 public void GetUpdateMesh()
 {
     for (int index = 0; index < 2; ++index)
     {
         if (!Object.op_Equality((Object)null, (Object)this.objUpdate[index]))
         {
             MeshFilter meshFilter = new MeshFilter();
             MeshFilter component1 = this.objUpdate[index].GetComponent(typeof(MeshFilter)) as MeshFilter;
             if (Object.op_Implicit((Object)component1))
             {
                 this.meshUpdate[index] = component1.get_sharedMesh();
             }
             else
             {
                 SkinnedMeshRenderer skinnedMeshRenderer = new SkinnedMeshRenderer();
                 SkinnedMeshRenderer component2          = this.objUpdate[index].GetComponent(typeof(SkinnedMeshRenderer)) as SkinnedMeshRenderer;
                 this.meshUpdate[index] = component2.get_sharedMesh();
             }
         }
     }
 }
コード例 #12
0
    private IEnumerator DoInitialize()
    {
        eventData = (SectionEventData)GameSection.GetEventData();
        FieldMapTable.PortalTableData portal = Singleton <FieldMapTable> .I.GetPortalData(MonoBehaviourSingleton <FieldManager> .I.currentPortalID);

        FieldMapTable.FieldMapTableData mapA = Singleton <FieldMapTable> .I.GetFieldMapData(portal.srcMapID);

        FieldMapTable.FieldMapTableData mapB = Singleton <FieldMapTable> .I.GetFieldMapData(portal.dstMapID);

        fromRegionID = mapA.regionId;
        toRegionID   = mapB.regionId;
        LoadingQueue loadQueue            = new LoadingQueue(this);
        LoadObject   loadedWorldMap       = loadQueue.Load(RESOURCE_CATEGORY.WORLDMAP, "WorldMap", false);
        LoadObject   loadedRegionSpotRoot = loadQueue.Load(RESOURCE_CATEGORY.WORLDMAP, "RegionSpotRoot", false);
        LoadObject   loadedRegionSpot     = loadQueue.Load(RESOURCE_CATEGORY.WORLDMAP, "RegionSpot", false);
        LoadObject   loadedPlayerMarker   = loadQueue.Load(RESOURCE_CATEGORY.WORLDMAP, "PlayerMarker", false);
        LoadObject   loadedMapGlowEffectA = loadQueue.Load(RESOURCE_CATEGORY.WORLDMAP, "MapGlowEffectA", false);
        LoadObject   loadedMapGlowEffectB = loadQueue.Load(RESOURCE_CATEGORY.WORLDMAP, "MapGlowEffectB", false);
        LoadObject   loadedTelop          = loadQueue.Load(RESOURCE_CATEGORY.WORLDMAP, "TelopOpenRegion", false);

        loadQueue.CacheSE(SE_ID_LOGO, null);
        loadQueue.CacheSE(SE_ID_SMOKE, null);
        uint[] openedRegionids = MonoBehaviourSingleton <WorldMapManager> .I.GetOpenRegionIdListInWorldMap();

        if (openedRegionids.Length == 0)
        {
            openedRegionids = new uint[1];
        }
        LoadObject[] regionAreaLOs    = new LoadObject[openedRegionids.Length];
        string       newRegionIcon    = ResourceName.GetRegionIcon(0);
        string       passedRegionIcon = ResourceName.GetRegionIcon(1);
        int          lastIndex        = openedRegionids.Length - 1;

        openedRegionInfo = new OpendRegionInfo[openedRegionids.Length];
        for (int j = 0; j < openedRegionids.Length; j++)
        {
            RegionTable.Data data = Singleton <RegionTable> .I.GetData(openedRegionids[j]);

            if (!data.hasParentRegion())
            {
                string iconName = passedRegionIcon;
                if (lastIndex == j)
                {
                    iconName = newRegionIcon;
                }
                LoadObject loadedObj = loadQueue.Load(RESOURCE_CATEGORY.REGION_ICON, iconName, false);
                openedRegionInfo[j] = new OpendRegionInfo(data, loadedObj);
                if (j != 0)
                {
                    regionAreaLOs[j] = loadQueue.Load(RESOURCE_CATEGORY.WORLDMAP, "WorldMapPart" + openedRegionids[j].ToString("D3"), false);
                }
            }
        }
        LoadObject loadedMaterial = null;

        if (!eventData.IsOnlyCameraMoveEvent())
        {
            loadedMaterial = loadQueue.Load(RESOURCE_CATEGORY.WORLDMAP, "WorldMapPartGlow" + toRegionID.ToString("D3"), false);
        }
        if (loadQueue.IsLoading())
        {
            yield return((object)loadQueue.Wait());
        }
        worldMapUIRoot = ResourceUtility.Realizes(loadedWorldMap.loadedObject, MonoBehaviourSingleton <AppMain> .I._transform, -1).get_gameObject();
        worldMapCamera = worldMapUIRoot.get_transform().Find("Camera").GetComponent <WorldMapCameraController>();
        worldMapCamera.isInteractive = false;
        worldMapObject = worldMapUIRoot.get_transform().FindChild("Map");
        spots          = new SpotManager(loadedRegionSpotRoot.loadedObject as GameObject, loadedRegionSpot.loadedObject as GameObject, worldMapCamera._camera);
        spots.CreateSpotRoot();
        GameObject bg = spots.spotRootTransform.Find("BG").get_gameObject();

        bg.get_gameObject().SetActive(true);
        bgEventListener = UIEventListener.Get(bg);
        spots.spotRootTransform.Find("TaptoSkip").get_gameObject().SetActive(true);
        mapGlowEffectA = ResourceUtility.Realizes(loadedMapGlowEffectA.loadedObject, worldMapObject, -1);
        mapGlowEffectA.get_gameObject().SetActive(false);
        mapGlowEffectParticleA = mapGlowEffectA.GetComponent <ParticleSystem>();
        mapGlowEffectB         = ResourceUtility.Realizes(loadedMapGlowEffectB.loadedObject, worldMapObject, -1);
        mapGlowEffectB.get_gameObject().SetActive(false);
        mapGlowEffectParticleB = mapGlowEffectB.GetComponent <ParticleSystem>();
        playerMarker           = ResourceUtility.Realizes(loadedPlayerMarker.loadedObject, base._transform, -1);
        playerMarker.get_gameObject().SetActive(false);
        if (loadedMaterial != null)
        {
            glowMaterial = (loadedMaterial.loadedObject as Material);
        }
        regionAreas = (Transform[])new Transform[regionAreaLOs.Length];
        for (int i = 0; i < regionAreaLOs.Length; i++)
        {
            LoadObject areaLO = regionAreaLOs[i];
            if (areaLO != null && null != areaLO.loadedObject)
            {
                Transform regionArea = ResourceUtility.Realizes(areaLO.loadedObject, worldMapObject, -1);
                if (i == toRegionID)
                {
                    if (eventData.IsOnlyCameraMoveEvent())
                    {
                        regionArea.get_gameObject().SetActive(true);
                    }
                    else
                    {
                        regionArea.get_gameObject().SetActive(false);
                    }
                    mapGlowEffectA.SetParent(regionArea);
                    mapGlowEffectA.set_localPosition(new Vector3(0f, 0f, 0f));
                    mapGlowEffectB.SetParent(regionArea);
                    mapGlowEffectB.set_localPosition(new Vector3(0f, 0f, 0f));
                    ShapeModule module     = mapGlowEffectParticleB.get_shape();
                    MeshFilter  meshFilter = regionArea.GetComponent <MeshFilter>();
                    module.set_mesh(meshFilter.get_sharedMesh());
                    glowRegionTop = ResourceUtility.Realizes(areaLO.loadedObject, worldMapObject, -1);
                    glowRegionTop.get_gameObject().SetActive(false);
                    glowRegionTop.set_localPosition(glowRegionTop.get_localPosition() + new Vector3(0f, 0f, 0.001f));
                    glowRegionTop.set_localScale(new Vector3(1.1f, 1.1f, 1.1f));
                    glowRegionTop.GetComponent <Renderer>().set_material(glowMaterial);
                }
                else
                {
                    regionArea.get_gameObject().SetActive(true);
                }
                regionAreas[i] = regionArea;
            }
        }
        telop = ResourceUtility.Realizes(loadedTelop.loadedObject, spots.spotRootTransform, -1);
        Transform closeBtn = Utility.Find(spots.spotRootTransform, "CLOSE_BTN");

        if (null != closeBtn)
        {
            closeBtn.get_gameObject().SetActive(false);
        }
        if (MonoBehaviourSingleton <GameSceneManager> .I.GetCurrentSceneName() == "InGameScene")
        {
            MonoBehaviourSingleton <ScreenOrientationManager> .I.OnScreenRotate += InitMapSprite;
        }
        base.Initialize();
    }
コード例 #13
0
    public static void GetUVData(GameObject obj, List <Vector2> uv, int index)
    {
        if (Object.op_Equality((Object)null, (Object)obj))
        {
            return;
        }
        MeshFilter meshFilter = new MeshFilter();
        MeshFilter component1 = obj.GetComponent(typeof(MeshFilter)) as MeshFilter;

        if (Object.op_Inequality((Object)null, (Object)component1))
        {
            switch (index)
            {
            case 0:
                foreach (Vector2 vector2 in component1.get_sharedMesh().get_uv())
                {
                    uv.Add(vector2);
                }
                break;

            case 1:
                foreach (Vector2 vector2 in component1.get_sharedMesh().get_uv2())
                {
                    uv.Add(vector2);
                }
                break;

            case 2:
                foreach (Vector2 vector2 in component1.get_sharedMesh().get_uv3())
                {
                    uv.Add(vector2);
                }
                break;

            case 3:
                foreach (Vector2 vector2 in component1.get_sharedMesh().get_uv4())
                {
                    uv.Add(vector2);
                }
                break;
            }
        }
        else
        {
            SkinnedMeshRenderer skinnedMeshRenderer = new SkinnedMeshRenderer();
            SkinnedMeshRenderer component2          = obj.GetComponent(typeof(SkinnedMeshRenderer)) as SkinnedMeshRenderer;
            if (!Object.op_Implicit((Object)component2))
            {
                return;
            }
            switch (index)
            {
            case 0:
                foreach (Vector2 vector2 in component2.get_sharedMesh().get_uv())
                {
                    uv.Add(vector2);
                }
                break;

            case 1:
                foreach (Vector2 vector2 in component2.get_sharedMesh().get_uv2())
                {
                    uv.Add(vector2);
                }
                break;

            case 2:
                foreach (Vector2 vector2 in component2.get_sharedMesh().get_uv3())
                {
                    uv.Add(vector2);
                }
                break;

            case 3:
                foreach (Vector2 vector2 in component2.get_sharedMesh().get_uv4())
                {
                    uv.Add(vector2);
                }
                break;
            }
        }
    }
コード例 #14
0
    private static Mesh[] GenerateBatch()
    {
        List <StaticBatchGroup.Section> sectionList = new List <StaticBatchGroup.Section>(64);
        List <Mesh> meshList = new List <Mesh>();

        for (int index1 = 0; index1 < StaticBatchGroup.mInstances.Count; ++index1)
        {
            MeshRenderer mMeshRenderer = StaticBatchGroup.mInstances[index1].mMeshRenderer;
            if (!Object.op_Equality((Object)mMeshRenderer, (Object)null) && ((Renderer)mMeshRenderer).get_sharedMaterials().Length > 0)
            {
                MeshFilter mMeshFilter = StaticBatchGroup.mInstances[index1].mMeshFilter;
                if (!Object.op_Equality((Object)mMeshFilter, (Object)null) && !Object.op_Equality((Object)mMeshFilter.get_sharedMesh(), (Object)null))
                {
                    for (int index2 = 0; index2 < ((Renderer)mMeshRenderer).get_sharedMaterials().Length; ++index2)
                    {
                        Material sharedMaterial = ((Renderer)mMeshRenderer).get_sharedMaterials()[index2];
                        if (!Object.op_Equality((Object)sharedMaterial, (Object)null))
                        {
                            sectionList.Add(new StaticBatchGroup.Section()
                            {
                                Material     = sharedMaterial,
                                SubMesh      = index2,
                                MeshFilter   = mMeshFilter,
                                MeshRenderer = mMeshRenderer
                            });
                        }
                    }
                }
            }
        }
        for (int index = 0; index < StaticBatchGroup.mInstances.Count; ++index)
        {
            Object.Destroy((Object)StaticBatchGroup.mInstances[index]);
        }
        List <StaticBatchGroup.Section>[] array = (List <StaticBatchGroup.Section>[])null;
        List <Vector3> verts    = new List <Vector3>();
        List <Vector3> normals  = (List <Vector3>)null;
        List <Color32> colors   = (List <Color32>)null;
        List <Vector2> uvs1     = (List <Vector2>)null;
        List <int>     indexMap = new List <int>(1024);

        List <int>[] newIndices = new List <int> [8];
        for (int index = 0; index < newIndices.Length; ++index)
        {
            newIndices[index] = new List <int>(512);
        }
        List <Vector2> uvs  = new List <Vector2>();
        List <Vector2> uvs2 = new List <Vector2>();

        for (int index1 = 0; index1 < sectionList.Count; ++index1)
        {
            if (!sectionList[index1].Merged)
            {
                Material[] sharedMaterials = ((Renderer)sectionList[index1].MeshRenderer).get_sharedMaterials();
                if (array == null)
                {
                    array = new List <StaticBatchGroup.Section> [sharedMaterials.Length * 2];
                }
                else if (array.Length < sharedMaterials.Length)
                {
                    Array.Resize <List <StaticBatchGroup.Section> >(ref array, sharedMaterials.Length + 2);
                }
                for (int index2 = 0; index2 < sharedMaterials.Length; ++index2)
                {
                    if (!Object.op_Equality((Object)sharedMaterials[index2], (Object)null))
                    {
                        if (array[index2] != null)
                        {
                            array[index2].Clear();
                        }
                        else
                        {
                            array[index2] = new List <StaticBatchGroup.Section>(8);
                        }
                        for (int index3 = index1; index3 < sectionList.Count; ++index3)
                        {
                            if (!Object.op_Inequality((Object)sharedMaterials[index2], (Object)sectionList[index3].Material) && !sectionList[index3].Merged)
                            {
                                sectionList[index3].Merged = true;
                                ((Renderer)sectionList[index3].MeshRenderer).set_enabled(false);
                                array[index2].Add(sectionList[index3]);
                            }
                        }
                    }
                }
                int length = sharedMaterials.Length;
                for (int index2 = 0; index2 < length; ++index2)
                {
                    if (array[index2].Count <= 0)
                    {
                        array[index2] = array[length - 1];
                        --length;
                        --index2;
                    }
                }
                if (length <= 0)
                {
                    ((Renderer)sectionList[index1].MeshRenderer).set_enabled(false);
                }
                else
                {
                    Mesh mesh = StaticBatchGroup.MergeMeshes(array, length, verts, normals, colors, uvs, uvs1, uvs2, newIndices, indexMap);
                    sectionList[index1].MeshFilter.set_sharedMesh(mesh);
                    meshList.Add(mesh);
                    Material[] materialArray = new Material[length];
                    for (int index2 = 0; index2 < length; ++index2)
                    {
                        materialArray[index2] = array[index2][0].Material;
                    }
                    LightmapLayout component = (LightmapLayout)((Component)sectionList[index1].MeshRenderer).GetComponent <LightmapLayout>();
                    component.Position = new Vector4(1f, 1f, 0.0f, 0.0f);
                    component.ApplyLayout();
                    ((Renderer)sectionList[index1].MeshRenderer).set_lightmapScaleOffset(new Vector4(1f, 1f, 0.0f, 0.0f));
                    ((Renderer)sectionList[index1].MeshRenderer).set_sharedMaterials(materialArray);
                    ((Renderer)sectionList[index1].MeshRenderer).set_enabled(true);
                }
            }
        }
        return(meshList.ToArray());
    }
コード例 #15
0
    protected bool CreateCalcInfo(GameObject obj)
    {
        if (Object.op_Equality((Object)null, (Object)obj))
        {
            return(false);
        }
        MorphSetting component1 = (MorphSetting)obj.GetComponent("MorphSetting");

        if (Object.op_Equality((Object)null, (Object)component1))
        {
            return(false);
        }
        this.CalcInfo = (MorphCalcInfo[])null;
        GC.Collect();
        this.CalcInfo = new MorphCalcInfo[component1.MorphDataList.Count];
        int index1 = 0;

        foreach (MorphData morphData in component1.MorphDataList)
        {
            if (!Object.op_Equality((Object)null, (Object)morphData.TargetObj))
            {
                this.CalcInfo[index1]           = new MorphCalcInfo();
                this.CalcInfo[index1].TargetObj = morphData.TargetObj;
                MeshFilter meshFilter = new MeshFilter();
                MeshFilter component2 = morphData.TargetObj.GetComponent(typeof(MeshFilter)) as MeshFilter;
                if (Object.op_Implicit((Object)component2))
                {
                    this.CalcInfo[index1].OriginalMesh   = component2.get_sharedMesh();
                    this.CalcInfo[index1].OriginalPos    = component2.get_sharedMesh().get_vertices();
                    this.CalcInfo[index1].OriginalNormal = component2.get_sharedMesh().get_normals();
                    this.CalcInfo[index1].WeightFlags    = false;
                }
                else
                {
                    SkinnedMeshRenderer skinnedMeshRenderer = new SkinnedMeshRenderer();
                    SkinnedMeshRenderer component3          = morphData.TargetObj.GetComponent(typeof(SkinnedMeshRenderer)) as SkinnedMeshRenderer;
                    this.CalcInfo[index1].OriginalMesh   = component3.get_sharedMesh();
                    this.CalcInfo[index1].OriginalPos    = component3.get_sharedMesh().get_vertices();
                    this.CalcInfo[index1].OriginalNormal = component3.get_sharedMesh().get_normals();
                    this.CalcInfo[index1].WeightFlags    = true;
                }
                int length1;
                if (Object.op_Equality((Object)null, (Object)morphData.MorphArea))
                {
                    length1 = this.CalcInfo[index1].OriginalMesh.get_vertices().Length;
                    this.CalcInfo[index1].UpdateIndex = new int[length1];
                    for (int index2 = 0; index2 < length1; ++index2)
                    {
                        this.CalcInfo[index1].UpdateIndex[index2] = index2;
                    }
                }
                else if (morphData.MorphArea.get_colors().Length != 0)
                {
                    List <int> source = new List <int>();
                    // ISSUE: object of a compiler-generated type is created
                    using (IEnumerator <\u003C\u003E__AnonType10 <Color, int> > enumerator = ((IEnumerable <Color>)morphData.MorphArea.get_colors()).Select <Color, \u003C\u003E__AnonType10 <Color, int> >((Func <Color, int, \u003C\u003E__AnonType10 <Color, int> >)((value, index) => new \u003C\u003E__AnonType10 <Color, int>(value, index))).GetEnumerator())
                    {
                        while (((IEnumerator)enumerator).MoveNext())
                        {
                            // ISSUE: variable of a compiler-generated type
                            \u003C\u003E__AnonType10 <Color, int> current = enumerator.Current;
                            if (Color.op_Equality(current.value, morphData.AreaColor))
                            {
                                source.Add(current.index);
                            }
                        }
                    }
                    this.CalcInfo[index1].UpdateIndex = new int[source.Count];
                    // ISSUE: object of a compiler-generated type is created
                    foreach (\u003C\u003E__AnonType10 <int, int> anonType10 in source.Select <int, \u003C\u003E__AnonType10 <int, int> >((Func <int, int, \u003C\u003E__AnonType10 <int, int> >)((value, index) => new \u003C\u003E__AnonType10 <int, int>(value, index))))
                    {
                        this.CalcInfo[index1].UpdateIndex[anonType10.index] = anonType10.value;
                    }
                    length1 = source.Count;
                }
                else
                {
                    length1 = this.CalcInfo[index1].OriginalMesh.get_vertices().Length;
                    this.CalcInfo[index1].UpdateIndex = new int[length1];
                    for (int index2 = 0; index2 < length1; ++index2)
                    {
                        this.CalcInfo[index1].UpdateIndex[index2] = index2;
                    }
                }
                int length2 = morphData.MorphMesh.Length;
                this.CalcInfo[index1].UpdateInfo = new MorphUpdateInfo[length2];
                for (int index2 = 0; index2 < length2; ++index2)
                {
                    this.CalcInfo[index1].UpdateInfo[index2]         = new MorphUpdateInfo();
                    this.CalcInfo[index1].UpdateInfo[index2].Pos     = new Vector3[length1];
                    this.CalcInfo[index1].UpdateInfo[index2].Normmal = new Vector3[length1];
                    if (Object.op_Equality((Object)null, (Object)morphData.MorphMesh[index2]))
                    {
                        for (int index3 = 0; index3 < length1; ++index3)
                        {
                            this.CalcInfo[index1].UpdateInfo[index2].Pos[index3]     = this.CalcInfo[index1].OriginalMesh.get_vertices()[this.CalcInfo[index1].UpdateIndex[index3]];
                            this.CalcInfo[index1].UpdateInfo[index2].Normmal[index3] = this.CalcInfo[index1].OriginalMesh.get_normals()[this.CalcInfo[index1].UpdateIndex[index3]];
                        }
                    }
                    else
                    {
                        for (int index3 = 0; index3 < length1; ++index3)
                        {
                            this.CalcInfo[index1].UpdateInfo[index2].Pos[index3]     = morphData.MorphMesh[index2].get_vertices()[this.CalcInfo[index1].UpdateIndex[index3]];
                            this.CalcInfo[index1].UpdateInfo[index2].Normmal[index3] = morphData.MorphMesh[index2].get_normals()[this.CalcInfo[index1].UpdateIndex[index3]];
                        }
                    }
                }
                ++index1;
            }
        }
        return(true);
    }
コード例 #16
0
 public void Init()
 {
     if (Object.op_Equality((Object)null, (Object)this.objUpdate[0]) || Object.op_Equality((Object)null, (Object)this.objUpdate[1]) || Object.op_Equality((Object)null, (Object)this.ObjRange))
     {
         return;
     }
     Mesh[]       meshArray     = new Mesh[2];
     List <int>[] intListArray1 = new List <int> [2];
     for (int index = 0; index < 2; ++index)
     {
         intListArray1[index] = new List <int>();
     }
     List <int>[] intListArray2 = new List <int> [2];
     for (int index1 = 0; index1 < 2; ++index1)
     {
         intListArray2[index1] = new List <int>();
         MeshFilter meshFilter = new MeshFilter();
         MeshFilter component1 = this.objUpdate[index1].GetComponent(typeof(MeshFilter)) as MeshFilter;
         if (Object.op_Implicit((Object)component1))
         {
             meshArray[index1] = component1.get_sharedMesh();
         }
         else
         {
             SkinnedMeshRenderer skinnedMeshRenderer = new SkinnedMeshRenderer();
             SkinnedMeshRenderer component2          = this.objUpdate[index1].GetComponent(typeof(SkinnedMeshRenderer)) as SkinnedMeshRenderer;
             meshArray[index1] = component2.get_sharedMesh();
         }
         if (Object.op_Inequality((Object)null, (Object)meshArray[index1]))
         {
             if (Object.op_Implicit((Object)this.ObjRange))
             {
                 for (int index2 = 0; index2 < meshArray[index1].get_vertexCount(); ++index2)
                 {
                     if ((double)Vector3.Distance(this.ObjRange.get_transform().get_position(), this.objUpdate[index1].get_transform().TransformPoint(meshArray[index1].get_vertices()[index2])) < (double)this.Range)
                     {
                         intListArray2[index1].Add(index2);
                     }
                 }
             }
             else
             {
                 for (int index2 = 0; index2 < meshArray[index1].get_vertexCount(); ++index2)
                 {
                     intListArray2[index1].Add(index2);
                 }
             }
         }
     }
     if (!Object.op_Inequality((Object)null, (Object)meshArray[0]) || !Object.op_Inequality((Object)null, (Object)meshArray[1]))
     {
         return;
     }
     for (int index1 = 0; index1 < intListArray2[0].Count; ++index1)
     {
         for (int index2 = 0; index2 < intListArray2[1].Count; ++index2)
         {
             int index3 = intListArray2[0][index1];
             int index4 = intListArray2[1][index2];
             if (Vector3.op_Equality(this.objUpdate[0].get_transform().TransformPoint(meshArray[0].get_vertices()[index3]), this.objUpdate[1].get_transform().TransformPoint(meshArray[1].get_vertices()[index4])))
             {
                 intListArray1[0].Add(index3);
                 intListArray1[1].Add(index4);
                 break;
             }
         }
     }
     this.calcIndexA = new int[intListArray1[0].Count];
     this.calcIndexB = new int[intListArray1[1].Count];
     for (int index = 0; index < intListArray1[0].Count; ++index)
     {
         this.calcIndexA[index] = intListArray1[0][index];
         this.calcIndexB[index] = intListArray1[1][index];
     }
 }
コード例 #17
0
    private void Start()
    {
        Component[] componentsInChildren = base.GetComponentsInChildren(typeof(MeshFilter));
        Matrix4x4   worldToLocalMatrix   = base.get_transform().get_worldToLocalMatrix();
        Hashtable   hashtable            = new Hashtable();

        for (int i = 0; i < componentsInChildren.Length; i++)
        {
            MeshFilter meshFilter = (MeshFilter)componentsInChildren[i];
            Renderer   renderer   = componentsInChildren[i].get_renderer();
            MeshCombineUtility.MeshInstance meshInstance = default(MeshCombineUtility.MeshInstance);
            meshInstance.mesh = meshFilter.get_sharedMesh();
            if (renderer != null && renderer.get_enabled() && meshInstance.mesh != null)
            {
                meshInstance.transform = worldToLocalMatrix * meshFilter.get_transform().get_localToWorldMatrix();
                Material[] sharedMaterials = renderer.get_sharedMaterials();
                for (int j = 0; j < sharedMaterials.Length; j++)
                {
                    meshInstance.subMeshIndex = Math.Min(j, meshInstance.mesh.get_subMeshCount() - 1);
                    ArrayList arrayList = (ArrayList)hashtable.get_Item(sharedMaterials[j]);
                    if (arrayList != null)
                    {
                        arrayList.Add(meshInstance);
                    }
                    else
                    {
                        arrayList = new ArrayList();
                        arrayList.Add(meshInstance);
                        hashtable.Add(sharedMaterials[j], arrayList);
                    }
                }
                renderer.set_enabled(false);
            }
        }
        using (IDictionaryEnumerator enumerator = hashtable.GetEnumerator())
        {
            while (enumerator.MoveNext())
            {
                DictionaryEntry dictionaryEntry            = (DictionaryEntry)enumerator.get_Current();
                ArrayList       arrayList2                 = (ArrayList)dictionaryEntry.get_Value();
                MeshCombineUtility.MeshInstance[] combines = (MeshCombineUtility.MeshInstance[])arrayList2.ToArray(typeof(MeshCombineUtility.MeshInstance));
                if (hashtable.get_Count() == 1)
                {
                    if (base.GetComponent(typeof(MeshFilter)) == null)
                    {
                        base.get_gameObject().AddComponent(typeof(MeshFilter));
                    }
                    if (!base.GetComponent("MeshRenderer"))
                    {
                        base.get_gameObject().AddComponent("MeshRenderer");
                    }
                    MeshFilter meshFilter2 = (MeshFilter)base.GetComponent(typeof(MeshFilter));
                    meshFilter2.set_mesh(MeshCombineUtility.Combine(combines, this.generateTriangleStrips));
                    base.get_renderer().set_material((Material)dictionaryEntry.get_Key());
                    base.get_renderer().set_enabled(true);
                }
                else
                {
                    GameObject gameObject = new GameObject("Combined mesh");
                    gameObject.get_transform().set_parent(base.get_transform());
                    gameObject.get_transform().set_localScale(Vector3.get_one());
                    gameObject.get_transform().set_localRotation(Quaternion.get_identity());
                    gameObject.get_transform().set_localPosition(Vector3.get_zero());
                    gameObject.AddComponent(typeof(MeshFilter));
                    gameObject.AddComponent("MeshRenderer");
                    gameObject.get_renderer().set_material((Material)dictionaryEntry.get_Key());
                    MeshFilter meshFilter3 = (MeshFilter)gameObject.GetComponent(typeof(MeshFilter));
                    meshFilter3.set_mesh(MeshCombineUtility.Combine(combines, this.generateTriangleStrips));
                }
            }
        }
    }