/// <summary>
        /// Postprocesses materials while you are importing a SpeedTree 8 asset. Call from OnPostprocessSpeedTree in a MaterialPostprocessor.
        /// </summary>
        /// <param name="speedtree">The GameObject Unity creates from this imported SpeedTree.</param>
        /// <param name="stImporter">The asset importer used to import this SpeedTree asset.</param>
        /// <param name="finalizer">Render pipeline-specific material finalizer.</param>
        public static void PostprocessSpeedTree8Materials(GameObject speedtree, SpeedTreeImporter stImporter, MaterialFinalizer finalizer = null)
        {
            LODGroup lg = speedtree.GetComponent <LODGroup>();

            LOD[] lods = lg.GetLODs();
            for (int l = 0; l < lods.Length; l++)
            {
                LOD  lod         = lods[l];
                bool isBillboard = stImporter.hasBillboard && (l == lods.Length - 1);
                int  wq          = Mathf.Min(stImporter.windQualities[l], stImporter.bestWindQuality);
                foreach (Renderer r in lod.renderers)
                {
                    // Override default motion vector generation mode pending
                    // proper motion vector integration in SRPs.
                    r.motionVectorGenerationMode = MotionVectorGenerationMode.Camera;
                    foreach (Material m in r.sharedMaterials)
                    {
                        float cutoff = stImporter.alphaTestRef;
                        ImportNewSpeedTree8Material(m, wq, isBillboard);
                        if (finalizer != null)
                        {
                            finalizer(m);
                        }
                    }
                }
            }
        }
Exemple #2
0
        void Test()
        {
            int numLodgroups = 0;
            int numActive    = 0;

            foreach (Transform tfm in parent)
            {
                foreach (Transform child in tfm)
                {
                    if (!child.gameObject.activeSelf)
                    {
                        continue;
                    }
                    LODGroup lodGroup = child.GetComponent <LODGroup>();
                    if (lodGroup == null)
                    {
                        continue;
                    }

                    numLodgroups++;
                    if (lodGroup.enabled)
                    {
                        numActive++;
                    }
                }
            }

            Debug.Log("Num Lodgroups:" + numLodgroups + " Active:" + numActive + " Disabled:" + (numLodgroups - numActive));
        }
Exemple #3
0
        private void Awake()
        {
            m_modelSkeleton = new ModelSkeleton(this.gameObject, m_rootBoneName);
            m_LODGroup      = this.gameObject.GetComponent <LODGroup>();
            if (m_LODGroup != null)
            {
                m_maxLODLevel = m_LODGroup.GetLODs().Length;
            }
            else
            {
                m_maxLODLevel = 1;
            }

            if (m_defaultParts != null)
            {
                if (m_defaultParts.Count > 0)
                {
                    var e = m_defaultParts.GetEnumerator();
                    while (e.MoveNext())
                    {
                        CreateDefaultPart(e.Current);
                    }
                    e.Dispose();
                    RefreshLODGroup();
                }
            }
        }
 private void Awake()
 {
     lodGroup = GetComponent <LODGroup>();
     //LOD[] lods = new LOD[] { lodGroup.GetLODs()[0] };
     //lodGroup.SetLODs(lods);
     lodGroup.ForceLOD(1);
 }
Exemple #5
0
    static void RecursiveTran(Transform tran, string sHierarchyPath, bool bCount)
    {
        sHierarchyPath += "/";
        sHierarchyPath += tran.name;

        if (tran.name.Contains(":") || tran.name.Contains("?") || tran.name.Contains("<") || tran.name.Contains(">") || tran.name.Contains("="))
        {
            m_PathList.Add(sHierarchyPath + "-----命名不正确");
        }
        if (!tran.gameObject.activeSelf)
        {
            m_PathList.Add(sHierarchyPath + "-----被设置为隐藏");
        }

        var script = tran.GetComponent <MonoBehaviour>();

        if (script != null)
        {
            //if(script.GetType()!= typeof(MaterialSound))
            //m_PathList.Add(sHierarchyPath + "-----存在脚本");
        }

        if (bCount)
        {
            MeshCollider collider = tran.GetComponent <MeshCollider>();
            if (collider != null)
            {
                MeshFilter   parentMeshFilter = tran.parent.GetComponent <MeshFilter>();
                MeshRenderer meshRenderer     = tran.GetComponent <MeshRenderer>();
                if (parentMeshFilter == null && meshRenderer == null)
                {
                    m_PathList.Add(sHierarchyPath + "-----MeshCollider要作为MeshFilter子节点。");
                }
                else if (parentMeshFilter == null && meshRenderer != null && meshRenderer.enabled == false)
                {
                    m_PathList.Add(sHierarchyPath + "-----MeshCollider要作为MeshFilter子节点。");
                }
            }

            MeshFilter meshFilter = tran.GetComponent <MeshFilter>();
            LODGroup   lODGroup   = tran.GetComponent <LODGroup>();
            if (meshFilter != null || lODGroup != null || tran.name.IndexOf("Object_") == 0)
            {
                //if (Mathf.Abs(tran.localScale.x) < 0.1f ||Mathf.Abs(tran.localScale.y) < 0.1f ||Mathf.Abs(tran.localScale.z) < 0.1f)
                //m_PathList.Add(sHierarchyPath + "-----缩放系数太低");

                ms_PrefabCount++;
                bCount = false;
            }
            else
            {
                bCount = true;
            }
        }

        for (int i = 0; i < tran.childCount; i++)
        {
            RecursiveTran(tran.GetChild(i), sHierarchyPath, bCount);
        }
    }
Exemple #6
0
    public static void LOD_Generator()
    {
        //        0-1 == 0 - 100%
        //float culled_distance = 0.06f;
        //float lod1_distance = 0.4f;
        float culled_distance = SettingLOD.culled_distance;
        float lod1_distance   = SettingLOD.lod1_distance;

        GameObject[] objectArray = Selection.gameObjects;
        for (int i = 0; i < objectArray.Length; i++)
        {
            LOD[]      lods = new LOD[2];
            Renderer[] rend = new Renderer[1];
            rend[0] = objectArray[i].GetComponent <MeshRenderer>();
            lods[1] = new LOD(culled_distance, rend);
            int        childrenCount = objectArray[i].transform.childCount;
            Renderer[] rend2         = new Renderer[childrenCount];
            for (int j = 0; j < childrenCount; j++)
            {
                rend2[j] = objectArray[i].transform.GetChild(j).GetComponent <MeshRenderer>();
            }
            lods[0] = new LOD(lod1_distance, rend2);
            LODGroup lg = objectArray[i].AddComponent <LODGroup>();
            lg.SetLODs(lods);
            lg.fadeMode           = LODFadeMode.CrossFade;
            lg.animateCrossFading = true;
        }
    }
    /// <summary>
    /// Updates the material of the station depending on its state.
    /// </summary>
    /// <param name="isOutOfService">True if the station is out of service.</param>
    public void UpdateStationMaterial(bool isOutOfService)
    {
        LODGroup lodgroup = this.gameObject.GetComponent <LODGroup>();

        LOD[] lods;

        if (lodgroup != null && materialForOpenStation != null && materialForCloseStation != null)
        {
            lods = lodgroup.GetLODs();

            foreach (LOD L in lods)
            {
                Renderer[] renderers = L.renderers;
                foreach (Renderer R in renderers)
                {
                    if (!isOutOfService)
                    {
                        R.material = materialForOpenStation;
                    }
                    else
                    {
                        R.material = materialForCloseStation;
                    }
                }
            }
        }
    }
Exemple #8
0
        public void AddLODGroupsToChildren()
        {
            // Debug.Log("Add Lod Groups");
            Transform       t            = transform;
            List <LODGroup> lodGroupList = new List <LODGroup>();

            for (int i = 0; i < t.childCount; i++)
            {
                Transform child = t.GetChild(i);
                // Debug.Log(child.name);
                LODGroup lodGroup = child.GetComponent <LODGroup>();

                if (lodGroup == null)
                {
                    lodGroup = child.gameObject.AddComponent <LODGroup>();
                    LOD[] lods = new LOD[1];
                    lods[0] = new LOD(0, child.GetComponentsInChildren <MeshRenderer>());
                    lodGroup.SetLODs(lods);
                }

                lodGroupList.Add(lodGroup);
            }

            lodGroups = lodGroupList.ToArray();
        }
        public void setLabel()
        {
            LODGroup group = GameObject.AddComponent <LODGroup>();

            // Add 4 LOD levels
            LOD[] lods = new LOD[1];
            txtMeshGl = GameObject.Instantiate(LinksManager.Get.r3DProvinceTextPrefab);
            Transform txtMeshTransform = txtMeshGl.transform;

            txtMeshTransform.SetParent(GameObject.transform, false);
            Renderer[] renderers = new Renderer[1];
            renderers[0] = txtMeshTransform.GetComponent <Renderer>();
            lods[0]      = new LOD(0.25F, renderers);

            var position = Position;

            position.z -= 0.003f;
            txtMeshTransform.position = position;

            TextMesh txtMesh = txtMeshTransform.GetComponent <TextMesh>();

            txtMesh.text  = ToString();
            txtMesh.color = Color.black; // Set the text's color to red

            //renderers[0].material.shader = Shader.Find("3DText");


            group.SetLODs(lods);
            //#if UNITY_WEBGL
            group.size = 20; //was 30 for webgl
                             //#else
                             //group.size = 20; // for others
                             //#endif
                             //group.RecalculateBounds();
        }
Exemple #10
0
        static bool WithinBounds(LODGroup lodGroup, Bounds bounds)
        {
            // Use this approach if we are not going to split meshes and simply put the object in one volume or another
            Vector3 v = lodGroup.transform.TransformPoint(lodGroup.localReferencePoint);

            return(Mathf.Approximately(bounds.size.magnitude, 0f) || bounds.Contains(lodGroup.transform.TransformPoint(lodGroup.localReferencePoint)));
        }
	private bool SamePrefab(GameObject a, GameObject b)
	{
		LOD_Base component = a.GetComponent<LOD_Base>();
		LOD_Base component2 = b.GetComponent<LOD_Base>();
		LODGroup component3 = a.GetComponent<LODGroup>();
		LODGroup component4 = b.GetComponent<LODGroup>();
		if (component != null && component2 != null)
		{
			return component.High == component2.High && component.Mid == component2.Mid && component.Low == component2.Low && component.billboard == component2.billboard;
		}
		if (component3 != null && component4 != null)
		{
			return this.CompareLODs(component3, component4);
		}
		MeshFilter[] componentsInChildren = a.GetComponentsInChildren<MeshFilter>();
		MeshFilter[] componentsInChildren2 = b.GetComponentsInChildren<MeshFilter>();
		if (componentsInChildren.Length != componentsInChildren2.Length)
		{
			return false;
		}
		for (int i = 0; i < componentsInChildren.Length; i++)
		{
			if (componentsInChildren[i].sharedMesh != componentsInChildren2[i].sharedMesh)
			{
				return false;
			}
		}
		return true;
	}
Exemple #12
0
            public static void MakePrefab_LOD0(string directory, string objName, Mesh mesh, Material[] mats)
            {
                string     path   = directory + "/" + objName;
                GameObject prefab = AssetDatabase.LoadAssetAtPath <GameObject>(path);

                if (prefab != null)
                {
                    if (!EditorUtility.DisplayDialog("Warning!!!!", "Prefab 已经存在,事发选择覆盖", "YES", "No"))
                    {
                        return;
                    }
                }

                GameObject gameObject = new GameObject(objName);
                LODGroup   group      = gameObject.AddComponent <LODGroup>();
                GameObject lod0       = new GameObject("LOD0");

                lod0.transform.SetParent(gameObject.transform);
                MeshRenderer mrNew = lod0.AddComponent <MeshRenderer>();
                MeshFilter   mfNew = lod0.AddComponent <MeshFilter>();

                mfNew.sharedMesh      = mesh;
                mrNew.sharedMaterials = mats;

                Renderer[] renderers = lod0.GetComponents <Renderer>();
                LOD        lod       = new LOD(0.05f, renderers);

                LOD[] lods = new LOD[1];
                lods[0] = lod;
                group.SetLODs(lods);

                PrefabUtility.SaveAsPrefabAsset(gameObject, path + ".prefab");
            }
Exemple #13
0
        private void AddTerrainMeshRenderer(GameObject go, List <MeshRenderer> meshRenderers)
        {
            if (IsSingleMeshTerrain(go))
            {
                MeshRenderer mr = go.GetComponent <MeshRenderer>();
                if (mr != null)
                {
                    if (!meshRenderers.Contains(mr) && !m_allTerrainMeshRenderers.Contains(mr))
                    {
                        meshRenderers.Add(mr);
                    }
                }
                return;
            }

            if (IsMeshLODTerrain(go))
            {
                LODGroup lg = go.GetComponent <LODGroup>();
                foreach (LOD lod in lg.GetLODs())
                {
                    foreach (Renderer renderer in lod.renderers)
                    {
                        if (renderer != null && renderer.GetType() == typeof(MeshRenderer))
                        {
                            MeshRenderer mr = (MeshRenderer)renderer;

                            if (!meshRenderers.Contains(mr))
                            {
                                meshRenderers.Add((MeshRenderer)mr);
                            }
                        }
                    }
                }
            }
        }
        internal static Vector3 CalculateWorldReferencePoint(LODGroup group)
        {
            Vector3 vector;

            INTERNAL_CALL_CalculateWorldReferencePoint(group, out vector);
            return(vector);
        }
Exemple #15
0
    void OnGUI()
    {
        GUILayout.BeginHorizontal();
        value = EditorGUILayout.Slider(value, 0, 1);
        PlayerPrefs.SetFloat("LOD Value", value);
        if (GUILayout.Button("设置"))
        {
            foreach (var it in Selection.gameObjects)
            {
                LODGroup lod = it.GetComponent <LODGroup>();
                if (lod != null)
                {
                    LOD[] lods = lod.GetLODs();

                    if (lods.Length >= 2)
                    {
                        lods[1].screenRelativeTransitionHeight = value;
                    }

                    lod.SetLODs(lods);
                }
            }
        }
        GUILayout.EndHorizontal();
    }
Exemple #16
0
 public void Start()
 {
     _lodGroup     = GetComponent <LODGroup>();
     _meshFilter   = GetComponent <MeshFilter>();
     _meshRenderer = GetComponent <MeshRenderer>();
     _meshCollider = GetComponent <MeshCollider>();
 }
Exemple #17
0
    /// <summary>
    ///  This function makes disabled all subobjects and/or associated renderers. It disables the objects so that they are no longer drawn on the screen. This can be undone by calling the Cull() Function.
    /// </summary>
    private void Cull(LODGroup lodGroup)
    {
        if (lodGroup.culled)
        {
            return;
        }

        lodGroup.culled = true;

        if (disableRendererOnly)
        {
            Renderer currentRenderer;
            for (int childCount = lodGroup.childRenderers.Length; childCount-- > 0;)
            {
                currentRenderer = lodGroup.childRenderers[childCount];
                if (currentRenderer.enabled)
                {
                    currentRenderer.enabled = false;
                }
            }
        }
        else
        {
            GameObject currentChild;
            for (int childCount = lodGroup.childObjects.Length; childCount-- > 0;)
            {
                currentChild = lodGroup.childObjects[childCount];
                if (currentChild.activeInHierarchy)
                {
                    currentChild.SetActive(false);
                }
            }
        }
    }
Exemple #18
0
    void Start()
    {
        group = gameObject.AddComponent <LODGroup>();
        LOD[] lods = new LOD[4];
        int   i    = 0;

        while (i < 4)
        {
            PrimitiveType primType = PrimitiveType.Cube;
            if (i == 1)
            {
                primType = PrimitiveType.Capsule;
            }
            if (i == 2)
            {
                primType = PrimitiveType.Sphere;
            }
            if (i == 3)
            {
                primType = PrimitiveType.Cylinder;
            }
            GameObject go = GameObject.CreatePrimitive(primType);
            go.transform.parent = gameObject.transform;
            Renderer[] renderers = new Renderer[1];
            renderers[0] = go.renderer;
            lods[i]      = new LOD(1.0F / (i + 1), renderers);
            i++;
        }
        group.SetLODS(lods);
        group.RecalculateBounds();
    }
Exemple #19
0
    void Awake()
    {
        Physics.gravity = new Vector3(0, -10.0F, 0);

        Tail0  = this.transform.Find("Anky/root/pelvis/tail0");
        Tail1  = this.transform.Find("Anky/root/pelvis/tail0/tail1");
        Tail2  = this.transform.Find("Anky/root/pelvis/tail0/tail1/tail2");
        Tail3  = this.transform.Find("Anky/root/pelvis/tail0/tail1/tail2/tail3");
        Tail4  = this.transform.Find("Anky/root/pelvis/tail0/tail1/tail2/tail3/tail4");
        Tail5  = this.transform.Find("Anky/root/pelvis/tail0/tail1/tail2/tail3/tail4/tail5");
        Spine0 = this.transform.Find("Anky/root/spine0");
        Spine1 = this.transform.Find("Anky/root/spine0/spine1");
        Spine2 = this.transform.Find("Anky/root/spine0/spine1/spine2");
        Neck0  = this.transform.Find("Anky/root/spine0/spine1/spine2/spine3/spine4/neck0");
        Neck1  = this.transform.Find("Anky/root/spine0/spine1/spine2/spine3/spine4/neck0/neck1");
        Neck2  = this.transform.Find("Anky/root/spine0/spine1/spine2/spine3/spine4/neck0/neck1/neck2");
        Neck3  = this.transform.Find("Anky/root/spine0/spine1/spine2/spine3/spine4/neck0/neck1/neck2/neck3");
        Head   = this.transform.Find("Anky/root/spine0/spine1/spine2/spine3/spine4/neck0/neck1/neck2/neck3/head");
        Jaw    = this.transform.Find("Anky/root/spine0/spine1/spine2/spine3/spine4/neck0/neck1/neck2/neck3/head/jaw0");

        source = GetComponent <AudioSource>();
        anim   = GetComponent <Animator>();
        lods   = GetComponent <LODGroup>();
        rend   = GetComponentsInChildren <SkinnedMeshRenderer>();

        m_Movement = GetComponent <Movement>();
    }
Exemple #20
0
    void Start()
    {
        // LOD-related statics, for reference if nothing else
        //LODGroup.crossFadeAnimationDuration = 0.1f;
        //QualitySettings.lodBias = 1;
        //QualitySettings.maximumLODLevel = 0;

        lodGroup                    = gameObject.GetOrAddComponent <LODGroup>();
        lodGroup.fadeMode           = LODFadeMode.CrossFade;
        lodGroup.animateCrossFading = true;

        // NOTE: QualitySettings.lodBias factors into the final calculations
        LOD[] lods = new LOD[3];
        lods[0].screenRelativeTransitionHeight = 0.6f;
        lods[1].screenRelativeTransitionHeight = 0.3f;
        lods[2].screenRelativeTransitionHeight = 0.1f;

        var renderers = gameObject.GetComponentsInChildren <Renderer>();

        lods[0].renderers = new Renderer[1] {
            renderers[0]
        };
        lods[1].renderers = new Renderer[1] {
            renderers[1]
        };
        lods[2].renderers = new Renderer[1] {
            renderers[2]
        };
        lodGroup.SetLODs(lods);
    }
Exemple #21
0
        void ClearAllExcept(Component comp)
        {
            if (!typeof(Collider).IsAssignableFrom(comp.GetType()))
            {
                collider = null;
            }

            if (!typeof(Cloth).IsAssignableFrom(comp.GetType()))
            {
                cloth = null;
            }

            if (!typeof(LODGroup).IsAssignableFrom(comp.GetType()))
            {
                lodGroup = null;
            }

            if (!typeof(Renderer).IsAssignableFrom(comp.GetType()))
            {
                renderer = null;
            }

            if (!typeof(Behaviour).IsAssignableFrom(comp.GetType()))
            {
                behaviour = null;
            }
        }
Exemple #22
0
    private GameObject GetColliderForPrototype(int hash)
    {
        TreeSystemPrototypeData data = m_OwnerSystem.m_ManagedPrototypesIndexed[hash];

        if (m_Cache.ContainsKey(hash) == false)
        {
            // If we don't contain the key create and add it

            // If we don't have a tree with a collider, like a bush or something, just add a null mapping
            if (data.m_TreePrototype.GetComponentInChildren <Collider>() == null)
            {
                m_Cache.Add(hash, null);
                return(null);
            }
            else
            {
                // Create the collider prototype and remove all it's mesh renderers and stuff
                GameObject colliderPrototype = Instantiate(data.m_TreePrototype, m_ColliderHolder.transform);
                colliderPrototype.name = "ColliderPrototype_" + data.m_TreePrototype.name;

                // Clear the lod group
                LODGroup lod = colliderPrototype.GetComponent <LODGroup>();
                if (lod)
                {
                    DestroyImmediate(lod);
                }

                // Clear any owned GObjects that don't have colliders
                for (int i = colliderPrototype.transform.childCount - 1; i >= 0; i--)
                {
                    GameObject owned = colliderPrototype.transform.GetChild(i).gameObject;

                    if (owned.GetComponent <Collider>() == null)
                    {
                        DestroyImmediate(owned);
                    }
                }

                // Deactivate it
                colliderPrototype.SetActive(false);

                // Create the cache entry
                TreeCollisionCache cache = new TreeCollisionCache(colliderPrototype, m_ColliderHolder);

                // Add the collision cache to our dictionary
                m_Cache.Add(hash, cache);
                return(cache.RetrieveInstance());
            }
        }
        else if (m_Cache[hash] != null)
        {
            // We contain the cache, just retrieve an object
            return(m_Cache[hash].RetrieveInstance());
        }
        else
        {
            // If we contain the hash but it doesn't have anything in it, it means than it's a tree without collisions, like a bush or something
            return(null);
        }
    }
Exemple #23
0
    // Use this for initialization
    void Start()
    {
        transPanelBrush = this.transform.Find("PanelBrush");
        if (transPanelBrush != null)
        {
            InitBrushes();
        }
        InitColors();
        //
        transPanelTool = this.transform.Find("PanelTools");
        if (transPanelTool == null)
        {
            return;
        }
        //
        InitBtnBrush();
        Transform transBtnConfirm = transPanelTool.Find("BtnConfirm");

        InitBtns("BtnClear", HandleBtnClear);
        InitBtns("BtnConfirm", HandlerBtnConfirm);
        //
        goCar = GameObject.FindGameObjectWithTag("Player");
        if (goCar == null)
        {
            return;
        }
        LODGroup lodGroup = goCar.GetComponent <LODGroup>();

        arrLOD = lodGroup.GetLODs();
        //
    }
        public void AwakeMe()
        {
            if (gameObject.activeInHierarchy)
            {
                if (sparseRemove.Length < 10)
                {
                    System.Array.Resize(ref sparseRemove, 10);
                }
                if (sparseRandom.Length < 10)
                {
                    System.Array.Resize(ref sparseRandom, 10);
                }

                for (int i = 0; i < numberOfModifiers; i++)
                {
                    iteration = i;
                    if (rooftopElements[0] != null)
                    {
                        if (useAdvertising)
                        {
                            bmComponent    = gameObject.GetComponent <BuildingModifier>();
                            roofTopsObject = null;
                            // rooftopHolder = null;
                            if (rooftopHolder[iteration] == null)
                            {
                                rooftopHolder[iteration] = new GameObject(gameObject.transform.name + "_Detail");
#if UNITY_EDITOR
                                if (rooftopHolder[iteration].GetComponent <LODGroup>() == null)
                                {
                                    lodComponent = rooftopHolder[iteration].AddComponent <LODGroup>();
                                    UnityEditor.SerializedObject obj = new UnityEditor.SerializedObject(lodComponent);

                                    UnityEditor.SerializedProperty valArrProp = obj.FindProperty("m_LODs.Array");
                                    for (int j = 0; valArrProp.arraySize > j; j++)
                                    {
                                        UnityEditor.SerializedProperty sHeight = obj.FindProperty("m_LODs.Array.data[" + i.ToString() + "].screenRelativeHeight");

                                        if (j == 0)
                                        {
                                            sHeight.doubleValue = 0.8;
                                        }
                                        if (j == 1)
                                        {
                                            sHeight.doubleValue = 0.5;
                                        }
                                        if (j == 2)
                                        {
                                            sHeight.doubleValue = 0.1;
                                        }
                                    }
                                    obj.ApplyModifiedProperties();
                                }
#endif
                            }
                            UpdateElements();
                        }
                    }
                }
            }
        }
Exemple #25
0
    void Awake()
    {
        //adjust speed to the model's scale
        Scale = this.transform.localScale.x;
        //adjust gravity to the model's scale
        //Physics.gravity = new Vector3(0, -Scale*40.0f, 0);
        //rg.mass = rg.mass * Scale;


        Root  = this.transform.Find("Ptera/root");
        WingR = this.transform.Find("Ptera/root/spine0/spine1/spine2/right wing0");
        WingL = this.transform.Find("Ptera/root/spine0/spine1/spine2/left wing0");
        Neck0 = this.transform.Find("Ptera/root/spine0/spine1/spine2/neck0");
        Neck1 = this.transform.Find("Ptera/root/spine0/spine1/spine2/neck0/neck1");
        Neck2 = this.transform.Find("Ptera/root/spine0/spine1/spine2/neck0/neck1/neck2");
        Neck3 = this.transform.Find("Ptera/root/spine0/spine1/spine2/neck0/neck1/neck2/neck3");
        Neck4 = this.transform.Find("Ptera/root/spine0/spine1/spine2/neck0/neck1/neck2/neck3/neck4");
        Neck5 = this.transform.Find("Ptera/root/spine0/spine1/spine2/neck0/neck1/neck2/neck3/neck4/neck5");
        Neck6 = this.transform.Find("Ptera/root/spine0/spine1/spine2/neck0/neck1/neck2/neck3/neck4/neck5/neck6");
        Head  = this.transform.Find("Ptera/root/spine0/spine1/spine2/neck0/neck1/neck2/neck3/neck4/neck5/neck6/head");
        Jaw   = this.transform.Find("Ptera/root/spine0/spine1/spine2/neck0/neck1/neck2/neck3/neck4/neck5/neck6/head/jaw0");

        rg     = GetComponent <Rigidbody>();
        source = GetComponent <AudioSource>();
        anim   = GetComponent <Animator>();
        lods   = GetComponent <LODGroup>();
        rend   = GetComponentsInChildren <SkinnedMeshRenderer>();

        m_ConstForce = GetComponent <ConstantForce>();
    }
        /// <summary>
        /// Render a gameobject hierarchy. In case of LOD use the one with the specified level
        /// </summary>
        /// <param name="go"></param>
        /// <param name="sourceLODLevel"></param>
        public static void RenderGameObjectNow(GameObject go, int sourceLODLevel)
        {
            GameObject root = go;

            LODGroup lodGroup = go.GetComponent <LODGroup>();

            if (lodGroup && lodGroup.lodCount > 0)
            {
                root = lodGroup.GetLODs()[sourceLODLevel].renderers[0].gameObject;
            }

            MeshRenderer[] renderers = root.GetComponentsInChildren <MeshRenderer>();
            for (int i = 0; i < renderers.Length; i++)
            {
                MeshFilter meshFilter = renderers[i].gameObject.GetComponent <MeshFilter>();
                if (meshFilter)
                {
                    Matrix4x4 matrix = Matrix4x4.TRS(
                        renderers[i].transform.position,
                        renderers[i].transform.rotation,
                        renderers[i].transform.lossyScale);

                    Mesh mesh = meshFilter.sharedMesh;

                    for (int j = 0; j < renderers[i].sharedMaterials.Length; j++)
                    {
                        Material material = renderers[i].sharedMaterials[j];
                        material.SetPass(0);
                        Graphics.DrawMeshNow(mesh, matrix, j);
                    }
                }
            }
        }
//***********************************************************************************************************************************************************************************************************
//STARTUP VALUES
    void Start()
    {
        manager = Camera.main.GetComponent <manager>();
        regime  = transform.GetChild(0).tag;
        specie  = transform.GetChild(0).name;
        lod     = GetComponent <LODGroup>();
        anm     = GetComponent <Animator>();
        body    = GetComponent <Rigidbody>();
        body.maxDepenetrationVelocity = 1.0f;
        rend = GetComponentsInChildren <SkinnedMeshRenderer>();
        SetScale(transform.localScale.x);
        SetMaterials(BodySkin.GetHashCode(), EyesSkin.GetHashCode());
        loop = Random.Range(0, 100);
        if (anm.parameters[0].name == "Attack")
        {
            CanAttack = true;
        }
        if (anm.parameters[1].name.Equals("Pitch"))
        {
            CanFly = true;
        }
        else if (anm.parameters[2].name.Equals("Pitch"))
        {
            CanSwim = true;
        }
        else if (anm.parameters[1].name.Equals("OnGround"))
        {
            CanJump = true;
        }
    }
Exemple #28
0
        /// <summary>
        /// Loops through and copys lightmap index and offset from LOD0 to LOD1+2
        /// </summary>
        void CopyLightmapSettings()
        {
            _lodGrp = GetComponent <LODGroup>();
            LOD[] lods = _lodGrp.GetLODs();
            _main = lods[0].renderers;
            _LOD1 = lods[1].renderers;
            _LOD2 = lods[2].renderers;

            int[]     lmIndex       = new int[_main.Length];
            Vector4[] lmScaleOffset = new Vector4[_main.Length];

            for (var i = 0; i < _main.Length; i++)
            {
                lmIndex[i]       = _main[i].lightmapIndex;
                lmScaleOffset[i] = _main[i].lightmapScaleOffset;
            }

            for (var i = 0; i < _main.Length; i++)
            {
                _LOD1[i].lightmapIndex       = lmIndex[i];
                _LOD1[i].lightmapScaleOffset = lmScaleOffset[i];
                _LOD2[i].lightmapIndex       = lmIndex[i];
                _LOD2[i].lightmapScaleOffset = lmScaleOffset[i];
            }
        }
Exemple #29
0
    void Awake()
    {
        Tail0  = this.transform.Find("Comp/root/pelvis/tail0");
        Tail1  = this.transform.Find("Comp/root/pelvis/tail0/tail1");
        Tail2  = this.transform.Find("Comp/root/pelvis/tail0/tail1/tail2");
        Tail3  = this.transform.Find("Comp/root/pelvis/tail0/tail1/tail2/tail3");
        Tail4  = this.transform.Find("Comp/root/pelvis/tail0/tail1/tail2/tail3/tail4");
        Tail5  = this.transform.Find("Comp/root/pelvis/tail0/tail1/tail2/tail3/tail4/tail5");
        Tail6  = this.transform.Find("Comp/root/pelvis/tail0/tail1/tail2/tail3/tail4/tail5/tail6");
        Tail7  = this.transform.Find("Comp/root/pelvis/tail0/tail1/tail2/tail3/tail4/tail5/tail6/tail7");
        Tail8  = this.transform.Find("Comp/root/pelvis/tail0/tail1/tail2/tail3/tail4/tail5/tail6/tail7/tail8");
        Spine0 = this.transform.Find("Comp/root/spine0");
        Spine1 = this.transform.Find("Comp/root/spine0/spine1");
        Spine2 = this.transform.Find("Comp/root/spine0/spine1/spine2");
        Spine3 = this.transform.Find("Comp/root/spine0/spine1/spine2/spine3");
        Spine4 = this.transform.Find("Comp/root/spine0/spine1/spine2/spine3/spine4");
        Spine5 = this.transform.Find("Comp/root/spine0/spine1/spine2/spine3/spine4/spine5");
        Arm1   = this.transform.Find("Comp/root/spine0/spine1/spine2/spine3/spine4/spine5/left arm0");
        Arm2   = this.transform.Find("Comp/root/spine0/spine1/spine2/spine3/spine4/spine5/right arm0");
        Neck0  = this.transform.Find("Comp/root/spine0/spine1/spine2/spine3/spine4/spine5/neck0");
        Neck1  = this.transform.Find("Comp/root/spine0/spine1/spine2/spine3/spine4/spine5/neck0/neck1");
        Neck2  = this.transform.Find("Comp/root/spine0/spine1/spine2/spine3/spine4/spine5/neck0/neck1/neck2");
        Neck3  = this.transform.Find("Comp/root/spine0/spine1/spine2/spine3/spine4/spine5/neck0/neck1/neck2/neck3");
        Head   = this.transform.Find("Comp/root/spine0/spine1/spine2/spine3/spine4/spine5/neck0/neck1/neck2/neck3/head");
        Jaw    = this.transform.Find("Comp/root/spine0/spine1/spine2/spine3/spine4/spine5/neck0/neck1/neck2/neck3/head/jaw0");

        source = GetComponent <AudioSource>();
        anim   = GetComponent <Animator>();
        lods   = GetComponent <LODGroup>();
        rend   = GetComponentsInChildren <SkinnedMeshRenderer>();
    }
Exemple #30
0
        // Token: 0x060024A9 RID: 9385 RVA: 0x000B3714 File Offset: 0x000B1914
        public void AddLODGroupsToChildren()
        {
            Transform       transform = base.transform;
            List <LODGroup> list      = new List <LODGroup>();

            for (int i = 0; i < transform.childCount; i++)
            {
                Transform child = transform.GetChild(i);
                Debug.Log(child.name);
                LODGroup lodgroup = child.GetComponent <LODGroup>();
                if (lodgroup == null)
                {
                    lodgroup = child.gameObject.AddComponent <LODGroup>();
                    LOD[]      array  = new LOD[1];
                    LOD[]      array2 = array;
                    int        num    = 0;
                    float      screenRelativeTransitionHeight = 0f;
                    Renderer[] componentsInChildren           = child.GetComponentsInChildren <MeshRenderer>();
                    array2[num] = new LOD(screenRelativeTransitionHeight, componentsInChildren);
                    lodgroup.SetLODs(array);
                }
                list.Add(lodgroup);
            }
            this.lodGroups = list.ToArray();
        }