Exemplo n.º 1
0
    public override void OnInspectorGUI()
    {
        SgtHelper.BaseRect    = SgtHelper.Reserve(0.0f);
        SgtHelper.BaseRectSet = true;

        SgtHelper.BeginUndo("Changes to " + typeof(T).Name, targets);

        EditorGUI.BeginChangeCheck();
        {
            serializedObject.UpdateIfDirtyOrScript();

            Target  = (T)target;
            Targets = targets.Select(t => (T)t).ToArray();

            Separator();

            OnInspector();

            Separator();

            serializedObject.ApplyModifiedProperties();
        }
        if (EditorGUI.EndChangeCheck() == true)
        {
            GUI.changed = true; Repaint();

            foreach (var t in Targets)
            {
                SgtHelper.SetDirty(t);
            }
        }

        SgtHelper.BaseRectSet = false;
    }
Exemplo n.º 2
0
    public SgtCustomBelt MakeEditableCopy(int layer, Transform parent, Vector3 localPosition, Quaternion localRotation, Vector3 localScale)
    {
#if UNITY_EDITOR
        SgtHelper.BeginUndo("Create Editable Belt Copy");
#endif
        var gameObject = SgtHelper.CreateGameObject("Editable Belt Copy", layer, parent, localPosition, localRotation, localScale);
        var customBelt = SgtHelper.AddComponent <SgtCustomBelt>(gameObject, false);
        var quads      = new List <SgtBeltAsteroid>();
        var quadCount  = BeginQuads();

        for (var i = 0; i < quadCount; i++)
        {
            var asteroid = SgtClassPool <SgtBeltAsteroid> .Pop() ?? new SgtBeltAsteroid();

            NextQuad(ref asteroid, i);

            quads.Add(asteroid);
        }

        EndQuads();

        // Copy common settings
        if (Lights != null)
        {
            customBelt.Lights = new List <Light>(Lights);
        }

        if (Shadows != null)
        {
            customBelt.Shadows = new List <SgtShadow>(Shadows);
        }

        customBelt.Color         = Color;
        customBelt.Brightness    = Brightness;
        customBelt.MainTex       = MainTex;
        customBelt.HeightTex     = HeightTex;
        customBelt.Layout        = Layout;
        customBelt.LayoutColumns = LayoutColumns;
        customBelt.LayoutRows    = LayoutRows;

        if (Rects != null)
        {
            customBelt.Rects = new List <Rect>(Rects);
        }

        customBelt.RenderQueue       = RenderQueue;
        customBelt.RenderQueueOffset = RenderQueueOffset;
        customBelt.OrbitOffset       = OrbitOffset;
        customBelt.OrbitSpeed        = OrbitSpeed;

        // Copy custom settings
        customBelt.Asteroids = quads;

        // Update
        customBelt.UpdateMaterial();
        customBelt.UpdateMeshesAndModels();

        return(customBelt);
    }
    public SgtCustomStarfield MakeEditableCopy(int layer, Transform parent, Vector3 localPosition, Quaternion localRotation, Vector3 localScale)
    {
#if UNITY_EDITOR
        SgtHelper.BeginUndo("Create Editable Starfield Copy");
#endif

        var gameObject      = SgtHelper.CreateGameObject("Editable Starfield Copy", layer, parent, localPosition, localRotation, localScale);
        var customStarfield = SgtHelper.AddComponent <SgtCustomStarfield>(gameObject, false);
        var stars           = default(List <SgtStarfieldStar>);
        var pool            = default(bool);

        CalculateStars(out stars, out pool);

        if (stars != null)
        {
            if (pool == true)
            {
                customStarfield.Stars = stars;
            }
            else
            {
                for (var i = 0; i < stars.Count; i++)
                {
                    var star = stars[i];

                    if (star != null)
                    {
                        var newStar = SgtClassPool <SgtStarfieldStar> .Pop() ?? new SgtStarfieldStar(); customStarfield.Stars.Add(star);

                        newStar.CopyFrom(star);
                    }
                }
            }
        }

        customStarfield.Color             = Color;
        customStarfield.Brightness        = Brightness;
        customStarfield.RenderQueue       = RenderQueue;
        customStarfield.RenderQueueOffset = RenderQueueOffset;
        customStarfield.Age                = Age;
        customStarfield.TimeScale          = TimeScale;
        customStarfield.Softness           = Softness;
        customStarfield.AutoRegenerate     = AutoRegenerate;
        customStarfield.StretchToObservers = StretchToObservers;
        customStarfield.StretchOverride    = StretchOverride;
        customStarfield.StretchVector      = StretchVector;
        customStarfield.StretchScale       = StretchScale;
        customStarfield.FadeNear           = FadeNear;
        customStarfield.FadeNearRadius     = FadeNearRadius;
        customStarfield.FadeNearThickness  = FadeNearThickness;
        customStarfield.FadeFar            = FadeFar;
        customStarfield.FadeFarRadius      = FadeFarRadius;
        customStarfield.FadeFarThickness   = FadeFarThickness;
        customStarfield.FollowObservers    = FollowObservers;
        customStarfield.AllowPulse         = AllowPulse;

        return(customStarfield);
    }
Exemplo n.º 4
0
    public SgtCustomStarfield MakeEditableCopy(int layer, Transform parent, Vector3 localPosition, Quaternion localRotation, Vector3 localScale)
    {
#if UNITY_EDITOR
        SgtHelper.BeginUndo("Create Editable Starfield Copy");
#endif
        var gameObject      = SgtHelper.CreateGameObject("Editable Starfield Copy", layer, parent, localPosition, localRotation, localScale);
        var customStarfield = SgtHelper.AddComponent <SgtCustomStarfield>(gameObject, false);
        var quads           = new List <SgtPointStar>();
        var starCount       = BeginQuads();

        for (var i = 0; i < starCount; i++)
        {
            var quad = SgtClassPool <SgtPointStar> .Pop() ?? new SgtPointStar();

            NextQuad(ref quad, i);

            quads.Add(quad);
        }

        EndQuads();

        // Copy common settings
        customStarfield.Color             = Color;
        customStarfield.Brightness        = Brightness;
        customStarfield.MainTex           = MainTex;
        customStarfield.Layout            = Layout;
        customStarfield.LayoutColumns     = LayoutColumns;
        customStarfield.LayoutRows        = LayoutRows;
        customStarfield.RenderQueue       = RenderQueue;
        customStarfield.RenderQueueOffset = RenderQueueOffset;
        customStarfield.FollowCameras     = FollowCameras;
        customStarfield.Softness          = Softness;
        customStarfield.Wrap              = Wrap;
        customStarfield.WrapSize          = WrapSize;
        customStarfield.Stretch           = Stretch;
        customStarfield.StretchVector     = StretchVector;
        customStarfield.StretchScale      = StretchScale;
        customStarfield.FadeNear          = FadeNear;
        customStarfield.FadeNearRadius    = FadeNearRadius;
        customStarfield.FadeNearThickness = FadeNearThickness;
        customStarfield.FadeNearTex       = FadeNearTex;
        customStarfield.FadeFar           = FadeFar;
        customStarfield.FadeFarRadius     = FadeFarRadius;
        customStarfield.FadeFarThickness  = FadeFarThickness;
        customStarfield.FadeFarTex        = FadeFarTex;
        customStarfield.Pulse             = Pulse;
        customStarfield.PulseOffset       = PulseOffset;
        customStarfield.PulseSpeed        = PulseSpeed;

        // Copy custom settings
        customStarfield.Stars = quads;

        // Update
        customStarfield.UpdateMaterial();
        customStarfield.UpdateMeshesAndModels();

        return(customStarfield);
    }
Exemplo n.º 5
0
    public SgtCustomStarfield MakeEditableCopy(Transform parent, Vector3 localPosition, Quaternion localRotation, Vector3 localScale)
    {
#if UNITY_EDITOR
        SgtHelper.BeginUndo("Create Editable Starfield Copy");
#endif

        var gameObject      = SgtHelper.CreateGameObject("Editable Starfield Copy", parent, localPosition, localRotation, localScale);
        var customStarfield = SgtHelper.AddComponent <SgtCustomStarfield>(gameObject, false);
        var stars           = default(List <SgtStarfieldStar>);
        var pool            = default(bool);

        CalculateStars(out stars, out pool);

        if (stars != null)
        {
            if (pool == true)
            {
                customStarfield.Stars = stars;
            }
            else
            {
                for (var i = 0; i < stars.Count; i++)
                {
                    var star = stars[i];

                    if (star != null)
                    {
                        var newStar = SgtClassPool <SgtStarfieldStar> .Pop() ?? new SgtStarfieldStar(); customStarfield.Stars.Add(star);

                        newStar.CopyFrom(star);
                    }
                }
            }
        }

        customStarfield.Color           = Color;
        customStarfield.Brightness      = Brightness;
        customStarfield.FollowObservers = FollowObservers;

        return(customStarfield);
    }
Exemplo n.º 6
0
    public SgtCustomBelt MakeEditableCopy(int layer, Transform parent, Vector3 localPosition, Quaternion localRotation, Vector3 localScale)
    {
#if UNITY_EDITOR
        SgtHelper.BeginUndo("Create Editable Belt Copy");
#endif
        var gameObject = SgtHelper.CreateGameObject("Editable Belt Copy", layer, parent, localPosition, localRotation, localScale);
        var customBelt = SgtHelper.AddComponent <SgtCustomBelt>(gameObject, false);
        var asteroids  = default(List <SgtBeltAsteroid>);
        var pool       = default(bool);

        CalculateAsteroids(out asteroids, out pool);

        if (asteroids != null)
        {
            if (pool == true)
            {
                customBelt.Asteroids = asteroids;
            }
            else
            {
                for (var i = 0; i < asteroids.Count; i++)
                {
                    var asteroid = asteroids[i];

                    if (asteroid != null)
                    {
                        var newAsteroid = SgtClassPool <SgtBeltAsteroid> .Pop() ?? new SgtBeltAsteroid(); customBelt.Asteroids.Add(asteroid);

                        newAsteroid.CopyFrom(asteroid);
                    }
                }
            }
        }

        customBelt.Color      = Color;
        customBelt.Brightness = Brightness;

        return(customBelt);
    }