Exemple #1
0
    public new void OnDestroy()
    {
        base.OnDestroy();

        SGT_Helper.DestroyGameObject(skysphereGameObject);
        SGT_Helper.DestroyObject(skysphereMaterial);
    }
    public new void OnDestroy()
    {
        base.OnDestroy();

        SGT_Helper.DestroyGameObject(starfieldGameObject);
        SGT_Helper.DestroyObject(starfieldMaterial);
        SGT_Helper.DestroyObjects(meshes);
    }
Exemple #3
0
    public new void OnDestroy()
    {
        base.OnDestroy();

        SGT_Helper.DestroyGameObject(dust);
        SGT_Helper.DestroyObject(dustMaterial);
        SGT_Helper.DestroyObject(generatedMesh);
    }
Exemple #4
0
    public new void OnDestroy()
    {
        base.OnDestroy();

        SGT_Helper.DestroyGameObject(atmosphereGameObject);
        SGT_Helper.DestroyGameObject(oblatenessGameObject);
        SGT_Helper.DestroyObject(lightingTexture);
        SGT_Helper.DestroyObject(atmosphereMaterial);
    }
Exemple #5
0
    public new void OnDestroy()
    {
        base.OnDestroy();

        SGT_Helper.DestroyGameObject(surfaceGameObject);
        SGT_Helper.DestroyGameObject(oblatenessGameObject);
        SGT_Helper.DestroyGameObject(atmosphereGameObject);
        SGT_Helper.DestroyObjects(surfaceMaterials);
        SGT_Helper.DestroyObject(atmosphereMaterial);
        SGT_Helper.DestroyObject(atmosphereTexture);
        SGT_Helper.DestroyObject(atmosphereSurfaceTexture);
    }
Exemple #6
0
    public new void OnDestroy()
    {
        base.OnDestroy();

        SGT_Helper.DestroyGameObject(surfaceGameObject);
        SGT_Helper.DestroyGameObject(atmosphereGameObject);
        SGT_Helper.DestroyGameObject(cloudsGameObject);

        SGT_Helper.DestroyObjects(surfaceMaterials);
        SGT_Helper.DestroyObject(atmosphereMaterial);
        SGT_Helper.DestroyObjects(cloudsMaterials);

        SGT_Helper.DestroyObject(surfaceLightingTexture);
        SGT_Helper.DestroyObject(atmosphereTexture);
        SGT_Helper.DestroyObject(atmosphereSurfaceTexture);
        SGT_Helper.DestroyObject(cloudsLightingTexture);
    }
Exemple #7
0
    public void Remove(int index)
    {
        if (index >= 0)
        {
            if (meshes != null && index < meshes.Count)
            {
                meshes.RemoveAt(index);
            }

            if (meshGameObjects != null && index < meshGameObjects.Count)
            {
                SGT_Helper.DestroyGameObject(meshGameObjects[index]);

                meshGameObjects.RemoveAt(index);
            }
        }
    }
Exemple #8
0
    private void UpdateDebris()
    {
        if (debrisCentre != null)
        {
            if (debrisList != null)
            {
                var centre         = debrisCentre.transform.position;
                var sqrOuterRadius = DebrisContainerOuterRadius * DebrisContainerOuterRadius;

                for (var i = debrisList.Count - 1; i >= 0; i--)
                {
                    var debris = debrisList[i];

                    if (debris != null)
                    {
                        if ((debris.transform.position - centre).sqrMagnitude > sqrOuterRadius)
                        {
                            if (debrisList.Count > debrisCountMax)
                            {
                                debrisList[i] = SGT_Helper.DestroyGameObject(debris);
                            }
                            else
                            {
                                debris.transform.position = RandomEdgePosition;

                                debris.SendMessage("ResetDebrisPosition", SendMessageOptions.DontRequireReceiver);
                            }
                        }
                    }
                    else
                    {
                        debrisList.RemoveAt(i);
                    }
                }
            }

            for (var i = DebrisCount; i < debrisCountMax; i++)
            {
                SpawnDebris(true);
            }
        }
    }
    public override void OnInspector()
    {
        var mbs = (SGT_MonoBehaviour[])Object.FindObjectsOfType(typeof(SGT_MonoBehaviour));

        SGT_EditorGUI.HelpBox("This tool allows you to cleanup any hidden game objects that have been orphaned by SGT.", MessageType.Info);
        SGT_EditorGUI.HelpBox("If a game object is still visible after showing it, then it's still in use by SGT.", MessageType.Info);

        SGT_EditorGUI.Separator();

        if (SGT_EditorGUI.Button("Show All Hidden Game Objects") == true)
        {
            foreach (var mb in mbs)
            {
                if (mb != null)
                {
                    foreach (Transform t in mb.transform)
                    {
                        if (Check(t) == true)
                        {
                            t.hideFlags = 0;
                        }
                    }
                }
            }

            Repaint();
        }

        SGT_EditorGUI.Separator();

        if (SGT_EditorGUI.Button("Delete All Hidden Game Objects") == true)
        {
            foreach (var mb in mbs)
            {
                if (mb != null)
                {
                    foreach (Transform t in mb.transform)
                    {
                        if (Check(t) == true)
                        {
                            SGT_Helper.DestroyGameObject(t);
                        }
                    }
                }
            }

            Repaint();
        }

        SGT_EditorGUI.Separator();

        var totalHiddenCount = 0;

        for (var i = 0; i < mbs.Length; i++)
        {
            var mb = mbs[i];

            if (mb != null)
            {
                var hiddenCount = 0;

                foreach (Transform t in mb.transform)
                {
                    if (Check(t) == true)
                    {
                        hiddenCount      += 1;
                        totalHiddenCount += 1;
                    }
                }

                if (hiddenCount > 0)
                {
                    SGT_EditorGUI.BeginGroup("SGT Component (" + mb.name + ")");
                    {
                        for (var j = 0; j < mb.transform.childCount; j++)
                        {
                            var t = mb.transform.GetChild(j);

                            if (Check(t) == true)
                            {
                                if (SGT_EditorGUI.TextWithButton("Hidden GameObject (" + t.name + ")", "Show", 50.0f) == true)
                                {
                                    t.hideFlags = 0;

                                    GUI.changed = true;
                                    EditorUtility.SetDirty(mb);
                                    EditorApplication.RepaintHierarchyWindow();
                                    Repaint();
                                }
                            }
                        }
                    }
                    SGT_EditorGUI.EndGroup();

                    SGT_EditorGUI.Separator();
                }
            }
        }

        if (totalHiddenCount == 0)
        {
            SGT_EditorGUI.HelpBox("This scene contains no hidden children of SGT components.", MessageType.Info);
        }
    }
Exemple #10
0
 public void OnDestroy()
 {
     SGT_Helper.DestroyGameObject(thrusterFlameGameObject);
     SGT_Helper.DestroyGameObject(thrusterFlareGameObject);
 }
    private System.Collections.IEnumerator Update_Coroutine()
    {
        for (;;)
        {
            // Swap
            currentVertices = nextVertices;
            nextVertices    = null;

            if (currentVertices != null)
            {
                nextGameObject       = SGT_Helper.CreateGameObject("Collider (Currently Building)", gameObject);
                nextGameObject.layer = gameObject.layer;
                nextGameObject.tag   = gameObject.tag;

                nextCollider                       = new SGT_MultiMesh();
                nextCollider.GameObject            = nextGameObject;
                nextCollider.HasMeshColliders      = true;
                nextCollider.MeshCollidersEnabled  = true;
                nextCollider.SharedPhysicsMaterial = physicsMaterial;

                var vertexCount = currentVertices.Length;
                var copyFrom    = 0;

                while (copyFrom < vertexCount)
                {
                    var copyTo    = Mathf.Min(copyFrom + verticesPerMesh, vertexCount);
                    var copyCount = copyTo - copyFrom;
                    var vertices  = new Vector3[copyCount];
                    var triangles = new int[copyCount];

                    for (var i = 0; i < copyCount; i++)
                    {
                        vertices[i]  = currentVertices[copyFrom + i];
                        triangles[i] = i;
                    }

                    var mesh = new Mesh();

                    mesh.name      = "Tessellator Collider Generated";
                    mesh.vertices  = vertices;
                    mesh.triangles = triangles;
                    mesh.RecalculateBounds();

                    nextCollider.Add(mesh);
                    nextCollider.Update();

                    copyFrom += verticesPerMesh;

                    yield return(new WaitForEndOfFrame());
                }

                // Remove current ones
                if (activeCollider != null)
                {
                    activeCollider.DestroyAllMeshes();
                }

                SGT_Helper.DestroyGameObject(activeGameObject);

                // Swap
                activeCollider        = nextCollider;
                activeGameObject      = nextGameObject;
                activeGameObject.name = "Collider (Active)";

                // Remove old
                nextGameObject = null;
                nextCollider   = null;
            }

            yield return(new WaitForEndOfFrame());
        }
    }
    public void Update()
    {
        if (surfaceGameObject == null)
        {
            var fillSurfaceGameObject = new SGT_FillGameObject();

            SendMessage("FillSurfaceGameObject", fillSurfaceGameObject, SendMessageOptions.DontRequireReceiver);

            surfaceGameObject = fillSurfaceGameObject.GameObject;
        }

        if (activeCollider != null)
        {
            if (activeGameObject == null)
            {
                activeGameObject = SGT_Helper.CreateGameObject("Collider (Active)", gameObject);
            }

            activeCollider.GameObject = activeGameObject;
            activeCollider.Update();
        }
        else
        {
            if (activeGameObject != null)
            {
                SGT_Helper.DestroyGameObject(activeGameObject);
            }
        }

        if (nextCollider != null)
        {
            if (nextGameObject == null)
            {
                nextGameObject = SGT_Helper.CreateGameObject("Collider (Currently Building)", gameObject);
            }

            nextCollider.GameObject = nextGameObject;
            nextCollider.Update();
        }
        else
        {
            if (nextGameObject != null)
            {
                SGT_Helper.DestroyGameObject(nextGameObject);
            }
        }

        if (activeGameObject != null)
        {
            SGT_Helper.SetLocalScale(activeGameObject.transform, surfaceGameObject.transform.localScale);
        }
        if (nextGameObject != null)
        {
            SGT_Helper.SetLocalScale(nextGameObject.transform, surfaceGameObject.transform.localScale);
        }

#if UNITY_EDITOR == true
        if (Application.isEditor == true)
        {
            SGT_Helper.HideGameObject(activeGameObject);
            SGT_Helper.HideGameObject(nextGameObject);
        }
#endif
    }