예제 #1
0
        private void createInstance(System.Windows.Forms.DragEventArgs e)
        {
            _assetPaths = CSharpFramework.Contexts.IDropContext.GetAssetPaths(e);
            _assetTypes = CSharpFramework.Contexts.IDropContext.GetAssetTypes(e);
            _assetNames = CSharpFramework.Contexts.IDropContext.GetAssetNames(e);

            Debug.Assert(_assetPaths.Length == _assetTypes.Length && _assetPaths.Length == _assetNames.Length);
            if (_assetPaths.Length == 0)
            {
                return;
            }

            if (_assetTypes[0] == "Model")
            {
                _instance = new EngineInstanceEntity("VisBaseEntity_cl", _assetPaths[0], null, null, true);
            }
            else if (_assetTypes[0] == "StaticMesh")
            {
                EngineInstanceStaticMesh instance = new EngineInstanceStaticMesh();
                LODEntry lodEntry = new LODEntry();
                lodEntry._filename = _assetPaths[0];
                List <LODEntry> lodEntries = new List <LODEntry>();
                lodEntries.Add(lodEntry);
                instance.SetLODChain(lodEntries);
                _instance = instance;
            }
            else if (_assetTypes[0] == "Prefab")
            {
                EngineInstancePrefab instance = new EngineInstancePrefab();
                instance.SetFilename(_assetPaths[0]);
                _instance = instance;
            }
        }
예제 #2
0
        public LODEntry GetEntry(GameObject gameObject)
        {
            int numEntries = lodEntries.Count;

            for (int entryIndex = 0; entryIndex < numEntries; ++entryIndex)
            {
                LODEntry entry = lodEntries[entryIndex];
                if (entry.gameObject == gameObject)
                {
                    return(entry);
                }
            }
            return(null);
        }
        private void createInstance(System.Windows.Forms.DragEventArgs e)
        {
            _assetPaths = CSharpFramework.Contexts.IDropContext.GetAssetPaths(e);
              _assetTypes = CSharpFramework.Contexts.IDropContext.GetAssetTypes(e);
              _assetNames = CSharpFramework.Contexts.IDropContext.GetAssetNames(e);

              Debug.Assert(_assetPaths.Length == _assetTypes.Length && _assetPaths.Length == _assetNames.Length);
              if (_assetPaths.Length == 0)
            return;

              if (_assetTypes[0] == "Model")
              {
            _instance = new EngineInstanceEntity("VisBaseEntity_cl", _assetPaths[0], null, null, true);
              }
              else if (_assetTypes[0] == "StaticMesh")
              {
            EngineInstanceStaticMesh instance = new EngineInstanceStaticMesh();
            LODEntry lodEntry = new LODEntry();
            lodEntry._filename = _assetPaths[0];
            List<LODEntry> lodEntries = new List<LODEntry>();
            lodEntries.Add(lodEntry);
            instance.SetLODChain(lodEntries);
            _instance = instance;
              }
              else if (_assetTypes[0] == "Prefab")
              {
            EngineInstancePrefab instance = new EngineInstancePrefab();
            instance.SetFilename(_assetPaths[0]);
            _instance = instance;
              }
        }
예제 #4
0
    void _ActivateLOD(int lodIndex)
    {
        toHide.Clear();
        toShow.Clear();

        if (activeLOD >= 0 && activeLOD < LODs.Count)
        {
            LODSet set        = LODs[activeLOD];
            int    numEntries = set.LODEntries.Count;
            for (int entryIndex = 0; entryIndex < numEntries; ++entryIndex)
            {
                LODEntry entry = set.LODEntries[entryIndex];
                if (entry.gameObject)
                {
                    toHide.Add(entry.gameObject);
                }
            }
        }

        if (lodIndex >= 0 && lodIndex < LODs.Count)
        {
            LODSet set        = LODs[lodIndex];
            int    numEntries = set.LODEntries.Count;
            for (int entryIndex = 0; entryIndex < numEntries; ++entryIndex)
            {
                LODEntry entry = set.LODEntries[entryIndex];
                if (entry.gameObject)
                {
                    toHide.Remove(entry.gameObject);
                    toShow.Add(entry);
                }
            }
        }

        int numHidden = toHide.Count;

        for (int hiddenIndex = 0; hiddenIndex < numHidden; ++hiddenIndex)
        {
            toHide[hiddenIndex].SetActive(false);
        }

        int numShown = toShow.Count;

        for (int showIndex = 0; showIndex < numShown; ++showIndex)
        {
            LODEntry entry = toShow[showIndex];
            entry.gameObject.SetActive(true);
            if (entry.lightmapSource)
            {
                Renderer entryRenderer = entry.gameObject.GetComponent <Renderer>();
                if (entryRenderer)
                {
                    entryRenderer.lightmapIndex = entry.lightmapSource.lightmapIndex;
#if UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6
                    entryRenderer.lightmapTilingOffset = entry.lightmapSource.lightmapTilingOffset;
#else
                    entryRenderer.lightmapScaleOffset = entry.lightmapSource.lightmapScaleOffset;
#endif
                }
            }
        }

        activeLOD = lodIndex;

        if (CullSiblings != 0 &&
            ((activeLOD == -1 && !siblingsDisabled) || (activeLOD != -1 && siblingsDisabled)))
        {
            siblingsDisabled = (activeLOD == -1);

            if ((CullSiblings & SiblinglFlags.Behaviors) != 0)
            {
                MonoBehaviour[] siblingBehaviors = gameObject.GetComponents <MonoBehaviour>();
                int             numBehaviors     = siblingBehaviors.Length;
                for (int behaviorIndex = 0; behaviorIndex < numBehaviors; ++behaviorIndex)
                {
                    MonoBehaviour behavior = siblingBehaviors[behaviorIndex];
                    if (behavior != this && behavior != cachedMember)
                    {
                        behavior.enabled = !siblingsDisabled;
                    }
                }
            }

            if ((CullSiblings & SiblinglFlags.Renderers) != 0)
            {
                Renderer[] siblingRenderers = gameObject.GetComponents <Renderer>();
                int        numRenderers     = siblingRenderers.Length;
                for (int rendererIndex = 0; rendererIndex < numRenderers; ++rendererIndex)
                {
                    siblingRenderers[rendererIndex].enabled = !siblingsDisabled;
                }
            }

            if ((CullSiblings & SiblinglFlags.Lights) != 0)
            {
                Light[] siblingLights = gameObject.GetComponents <Light>();
                int     numLights     = siblingLights.Length;
                for (int lightIndex = 0; lightIndex < numLights; ++lightIndex)
                {
                    siblingLights[lightIndex].enabled = !siblingsDisabled;
                }
            }

            if ((CullSiblings & SiblinglFlags.Colliders) != 0)
            {
                Collider[] siblingColliders = gameObject.GetComponents <Collider>();
                int        numColliders     = siblingColliders.Length;
                for (int colliderIndex = 0; colliderIndex < numColliders; ++colliderIndex)
                {
                    siblingColliders[colliderIndex].enabled = !siblingsDisabled;
                }
            }

            if ((CullSiblings & SiblinglFlags.RigidBodies) != 0)
            {
                Rigidbody[] siblingRBs = gameObject.GetComponents <Rigidbody>();
                int         numRBs     = siblingRBs.Length;
                for (int rbIndex = 0; rbIndex < numRBs; ++rbIndex)
                {
                    if (siblingsDisabled)
                    {
                        siblingRBs[rbIndex].Sleep();
                    }
                    else
                    {
                        siblingRBs[rbIndex].WakeUp();
                    }
                }
            }
        }

        cachedMember.ForceUpdate(true);
    }