void CheckUnityLight(ZippyLights2D t)
 {
     if (t.unityLight && t.unityLight.renderMode != LightRenderMode.ForceVertex)
     {
         EditorGUILayout.HelpBox("RenderMode slow on mobile. \nSet to light RenderMode to [Not Important] for mobile.", MessageType.Warning);
     }
 }
Exemple #2
0
    void CheckIdle(ZippyLights2D t)
    {
        if (!Application.isPlaying)
        {
            return;
        }
        if (t.idle)
        {
            GUI.color = Color.green;
        }
        else
        {
            GUI.color = Color.gray;
        }
        EditorGUILayout.BeginHorizontal("Box");
        GUILayout.Label("ZippyLight2D is idle: \nUsing less resources.", lab);
        EditorGUILayout.EndHorizontal();
        GUI.color = Color.white;


        if (!t.lightEnabled)
        {
            GUI.color = Color.green;
        }
        else
        {
            GUI.color = Color.gray;
        }
        EditorGUILayout.BeginHorizontal("Box");
        GUILayout.Label("ZippyLight2D not rendered: \nDisabled and using very few resources.", lab);
        EditorGUILayout.EndHorizontal();
        GUI.color = Color.white;
    }
Exemple #3
0
    // Start is called before the first frame update
    void Start()
    {
        light2D = GetComponentInChildren <ZippyLights2D>();

        light2D.observations.OnAdd    += Observations_OnAdd;
        light2D.observations.OnRemove += Observations_OnRemove;
    }
    void CheckIdle(ZippyLights2D t)
    {
        if (!Application.isPlaying)
        {
            return;
        }


        if (!t.lightEnabled)
        {
            EditorGUILayout.HelpBox("ZippyLight2D not rendered: \nDisabled and using very few resources.", MessageType.Info);
        }
        else
        {
            if (!t.idle)
            {
                GUI.color = Color.clear;
            }
            EditorGUILayout.HelpBox("ZippyLight2D is idle: \nUsing less resources.", MessageType.Info);
        }



        GUI.color = Color.white;
    }
 void CheckResolution(ZippyLights2D t)
 {
     if (t.resolution <= 360)
     {
         return;
     }
     EditorGUILayout.HelpBox("ZippyLight2D resolution set high: \nResolution not suitable for mobile.", MessageType.Warning);
 }
Exemple #6
0
 void CheckUnityLight(ZippyLights2D t)
 {
     if (t.unityLight && t.unityLight.renderMode != LightRenderMode.ForceVertex)
     {
         GUI.color = Color.red;
         EditorGUILayout.BeginHorizontal("Box");
         GUILayout.Label(t.unityLight + "<b>\nRenderMode slow on mobile.</b> \nSet to [Not Important] for mobile.", lab);
         EditorGUILayout.EndHorizontal();
         GUI.color = Color.white;
     }
 }
Exemple #7
0
 void CheckResolution(ZippyLights2D t)
 {
     if (t.resolution <= 360)
     {
         return;
     }
     GUI.color = Color.red;
     EditorGUILayout.BeginHorizontal("Box");
     GUILayout.Label("ZippyLight2D resolution set high: \nResolution not suitable for mobile.", lab);
     EditorGUILayout.EndHorizontal();
     GUI.color = Color.white;
 }
    public void DrawCustomInspector()
    {
        ZippyLights2D t = (ZippyLights2D)target;

        if (!Application.isPlaying)
        {
            if (GUILayout.Button("Update"))
            {
                t.ForceUpdate();
            }
        }
        lab          = new GUIStyle();
        lab.richText = true;
        CheckIdle(t);
        CheckUnityLight(t);
        CheckResolution(t);
    }
Exemple #9
0
    public void DrawCustomInspector()
    {
        ZippyLights2D t = (ZippyLights2D)target;

        if (!Application.isPlaying)
        {
            if (GUILayout.Button("Update"))
            {
                t.ForceUpdate();
                Debug.Log(t.GetComponent <MeshRenderer>().sortingLayerName);
                Debug.Log(t.GetComponent <MeshRenderer>().sortingOrder);
            }
        }
        lab          = new GUIStyle();
        lab.richText = true;
        CheckIdle(t);
        CheckUnityLight(t);
        CheckResolution(t);
    }
    void CheckTexture(ZippyLights2D t)
    {
        if (!t.CreateUV)
        {
            return;
        }
        MeshRenderer r = t.GetComponent <MeshRenderer>();

        if (r == null)
        {
            return;
        }
        Material m = r.sharedMaterial;

        if (m == null || m != null && m.GetTexture("_MainTex") == null)
        {
            EditorGUILayout.HelpBox("UV enabled but no Texture in Material.", MessageType.Error);
        }
    }
    public void DrawCustomInspector()
    {
        serializedObject.Update();
        ZippyLights2D t = (ZippyLights2D)target;

        if (t.hiddenChildren)
        {
            if (GUIButton("Show Child Objects"))
            {
                t.hiddenChildren = !t.hiddenChildren;
                t.HideChildren();
            }
        }
        else
        {
            if (GUIButton("Hide Child Objects"))
            {
                t.hiddenChildren = !t.hiddenChildren;
                t.HideChildren();
            }
        }

        GUIBeginBox();
        if (GUILayout.Button(GUIButtoneText("Light", t.showLightSettings), EditorStyles.boldLabel))
        {
            t.showLightSettings = !t.showLightSettings;
        }
        if (t.showLightSettings)
        {
            GUIBeginBox("", true, 2);
            EditorGUILayout.PropertyField(staticLight);
            EditorGUILayout.PropertyField(resolution);
            EditorGUILayout.PropertyField(degrees);
            EditorGUILayout.PropertyField(offset);
            EditorGUILayout.PropertyField(offsetSpherify);
            if (t.offset < 0 || t.offsetSpherify < 0)
            {
                EditorGUILayout.HelpBox("Negative offsets can cause bugs if light is too close to a collider.\nMake sure to create a buffer collider between the light and other colliders.", MessageType.Warning);
            }
            EditorGUILayout.PropertyField(moveToUpdate);
            EditorGUILayout.PropertyField(layers);
            EditorGUILayout.PropertyField(unityLight);
            EditorGUILayout.PropertyField(follow);
            EditorGUILayout.PropertyField(meshTransform);
            GUIEndBox();
        }
        GUIEndBox();

        GUIBeginBox();
        if (GUILayout.Button(GUIButtoneText("Duplicate Lights", t.showDuplicate), EditorStyles.boldLabel))
        {
            t.showDuplicate = !t.showDuplicate;
        }
        if (t.showDuplicate)
        {
            GUIBeginBox("", true, 2);
            if (GUIButton("Create Dupe"))
            {
                GameObject   go       = new GameObject("LightMesh Dupe " + t.duplicatedLights.Count, typeof(MeshRenderer), typeof(MeshFilter));
                Transform    tr       = go.transform;
                MeshRenderer parentMr = t.meshTransform.GetComponent <MeshRenderer>();
                MeshFilter   parentMf = t.meshTransform.GetComponent <MeshFilter>();
                MeshFilter   mf       = tr.GetComponent <MeshFilter>();
                MeshRenderer mr       = tr.GetComponent <MeshRenderer>();
                tr.parent         = t.meshTransform;
                tr.localPosition  = Vector3.zero;
                tr.localRotation  = Quaternion.identity;
                mr.sharedMaterial = parentMr.sharedMaterial;
                mr.receiveShadows = false;
                mr.castShadows    = false;
                EditorUtility.SetSelectedWireframeHidden(mr, true);
                mf.sharedMesh = parentMf.sharedMesh;
                t.duplicatedLights.Add(mf);
            }
            GUILayout.Space(2);
            if (t.duplicatedLights.Count == 0)
            {
                GUI.enabled = false;
            }
            if (GUIButton("Remove Dupe"))
            {
                DestroyImmediate(t.duplicatedLights[t.duplicatedLights.Count - 1].gameObject);
                t.duplicatedLights.RemoveAt(t.duplicatedLights.Count - 1);
            }
            //if (t.duplicatedLights.Count == 0)
            GUI.enabled = true;
            GUILayout.Space(2);
            EditorGUILayout.HelpBox("Duplicated lights can be rotated, moved or scaled after creation to create special effects.\nChanging to a different material can also improve the look and feel of the lights.", MessageType.Info);
            EditorGUILayout.PropertyField(duplicatedLights, true);
            GUIEndBox();
        }
        GUIEndBox();


        GUIBeginBox();
        if (GUILayout.Button(GUIButtoneText("Range", t.showRange), EditorStyles.boldLabel))
        {
            t.showRange = !t.showRange;
        }
        if (t.showRange)
        {
            GUIBeginBox("", true, 2);
            EditorGUILayout.PropertyField(range);
            EditorGUILayout.PropertyField(animateRange);
            EditorGUILayout.PropertyField(rangeAnimation);
            EditorGUILayout.PropertyField(animateRangeSpeed);
            EditorGUILayout.PropertyField(animateRangeScale);
            GUIEndBox();
        }
        GUIEndBox();

        GUIBeginBox();
        if (GUILayout.Button(GUIButtoneText("Falloff", t.showFalloff), EditorStyles.boldLabel))
        {
            t.showFalloff = !t.showFalloff;
        }
        if (t.showFalloff)
        {
            GUIBeginBox("", true, 2);
            EditorGUILayout.HelpBox("Experimental, can have bugs in mobile or other builds.", MessageType.Warning);
            EditorGUILayout.PropertyField(falloff);
            EditorGUILayout.PropertyField(falloffAfterglow);
            EditorGUILayout.PropertyField(falloffMobileFix);
            if (GUIButton("Mobile Mode Toggle (Fix)"))
            {
                t.ForceUpdate();
                t.falloffMobileFix = !t.falloffMobileFix;
            }
            GUIEndBox();
        }
        GUIEndBox();

        GUIBeginBox();
        if (GUILayout.Button(GUIButtoneText("Color", t.showColor), EditorStyles.boldLabel))
        {
            t.showColor = !t.showColor;
        }
        if (t.showColor)
        {
            GUIBeginBox("", true, 2);
            EditorGUILayout.PropertyField(enableVertexColors);
            EditorGUILayout.PropertyField(vertexFade);
            EditorGUILayout.PropertyField(vertexColor);
            EditorGUILayout.PropertyField(enableOuterColor);
            EditorGUILayout.PropertyField(vertexColorOuter);
            EditorGUILayout.PropertyField(ColorCycleEnabled);
            EditorGUILayout.PropertyField(ColorCycle);
            EditorGUILayout.PropertyField(ColorCycleSpeed);
            EditorGUILayout.PropertyField(ColorCycleOuterEnabled);
            EditorGUILayout.PropertyField(ColorCycleOuter);
            EditorGUILayout.PropertyField(ColorCycleSpeedOuter);
            GUIEndBox();
        }
        GUIEndBox();

        GUIBeginBox();
        if (GUILayout.Button(GUIButtoneText("UV", t.showUV), EditorStyles.boldLabel))
        {
            t.showUV = !t.showUV;
        }
        if (t.showUV)
        {
            GUIBeginBox("", true, 2);
            EditorGUILayout.PropertyField(CreateUV);
            EditorGUILayout.PropertyField(UVScale);
            GUIEndBox();
        }
        GUIEndBox();

        GUIBeginBox();
        if (GUILayout.Button(GUIButtoneText("Noise", t.showNoise), EditorStyles.boldLabel))
        {
            t.showNoise = !t.showNoise;
        }
        if (t.showNoise)
        {
            GUIBeginBox("", true, 2);
            EditorGUILayout.PropertyField(noise);
            EditorGUILayout.PropertyField(noiseDelay);
            GUIEndBox();
        }
        GUIEndBox();

        GUIBeginBox();
        if (GUILayout.Button(GUIButtoneText("Sort", t.showSort), EditorStyles.boldLabel))
        {
            t.showSort = !t.showSort;
        }
        if (t.showSort)
        {
            GUIBeginBox("", true, 2);
            EditorGUILayout.PropertyField(sortingOrder);
            EditorGUILayout.PropertyField(sortingLayer);
            GUIEndBox();
        }
        GUIEndBox();

        GUIBeginBox();
        if (GUILayout.Button(GUIButtoneText("Particles", t.showParticle), EditorStyles.boldLabel))
        {
            t.showParticle = !t.showParticle;
        }
        if (t.showParticle)
        {
            GUIBeginBox("", true, 2);
            EditorGUILayout.PropertyField(particles);
            EditorGUILayout.PropertyField(particleEmitDelay);
            EditorGUILayout.PropertyField(particleRayAmount);
            EditorGUILayout.PropertyField(particleEmitAmount);
            EditorGUILayout.PropertyField(particleRangeLimitMin);
            EditorGUILayout.PropertyField(particleRangeLimitMax);
            GUIEndBox();
        }
        GUIEndBox();

        GUIBeginBox();
        if (GUILayout.Button(GUIButtoneText("Functions", t.showFunctions), EditorStyles.boldLabel))
        {
            t.showFunctions = !t.showFunctions;
        }
        if (t.showFunctions)
        {
            GUIBeginBox("", true, 2);
            if (!Application.isPlaying)
            {
                if (GUIButton("Update"))
                {
                    t.ForceUpdate();
                    //Debug.Log(t.GetComponent<MeshRenderer>().sortingLayerName);
                    //Debug.Log(t.GetComponent<MeshRenderer>().sortingOrder);
                }
                GUILayout.Space(2);
                if (GUIButton("Force New Mesh"))
                {
                    t.ForceNewMesh();
                }
                GUILayout.Space(2);
                if (GUIButton("Create Material Instances\n(ignore error)"))
                {
                    MeshRenderer r = t.GetComponent <MeshRenderer>();
                    for (int i = 0; i < r.materials.Length; i++)
                    {
                        r.materials[i] = new Material(r.materials[i]);
                    }
                }
            }
            EditorGUILayout.HelpBox("Tip : Use [Unity Menu > GameObject > Break Prefab Instance] to improve performance in editor.\nApply changes to connect scene object to prefab again.\nTip2 : Improve inspector lag by copying Zippy Light component, removing it, then paste it back as new.", MessageType.Info);
            GUIEndBox();
        }
        GUIEndBox();
        CheckIdle(t);
        CheckUnityLight(t);
        CheckResolution(t);
        CheckTexture(t);


        if (GUI.changed)
        {
            EditorUtility.SetDirty(t);
            serializedObject.ApplyModifiedProperties();
        }
    }
    public void DrawCustomInspector()
    {
        ZippyLights2D t = (ZippyLights2D)target;

        GUIBeginBox();
        if (GUILayout.Button(GUIButtoneText("Light", t.showLightSettings), EditorStyles.boldLabel))
        {
            t.showLightSettings = !t.showLightSettings;
        }
        if (t.showLightSettings)
        {
            GUIBeginBox("", true, 2);
            EditorGUILayout.PropertyField(staticLight);
            EditorGUILayout.PropertyField(resolution);
            EditorGUILayout.PropertyField(degrees);
            EditorGUILayout.PropertyField(offset);
            EditorGUILayout.PropertyField(offsetSpherify);
            EditorGUILayout.PropertyField(moveToUpdate);
            EditorGUILayout.PropertyField(layers);
            EditorGUILayout.PropertyField(unityLight);
            EditorGUILayout.PropertyField(follow);
            GUIEndBox();
        }
        GUIEndBox();

        GUIBeginBox();
        if (GUILayout.Button(GUIButtoneText("Range", t.showRange), EditorStyles.boldLabel))
        {
            t.showRange = !t.showRange;
        }
        if (t.showRange)
        {
            GUIBeginBox("", true, 2);
            EditorGUILayout.PropertyField(range);
            EditorGUILayout.PropertyField(animateRange);
            EditorGUILayout.PropertyField(rangeAnimation);
            EditorGUILayout.PropertyField(animateRangeSpeed);
            EditorGUILayout.PropertyField(animateRangeScale);
            GUIEndBox();
        }
        GUIEndBox();

        GUIBeginBox();
        if (GUILayout.Button(GUIButtoneText("Color", t.showColor), EditorStyles.boldLabel))
        {
            t.showColor = !t.showColor;
        }
        if (t.showColor)
        {
            GUIBeginBox("", true, 2);
            EditorGUILayout.PropertyField(enableVertexColors);
            EditorGUILayout.PropertyField(vertexFade);
            EditorGUILayout.PropertyField(vertexColor);
            EditorGUILayout.PropertyField(enableOuterColor);
            EditorGUILayout.PropertyField(vertexColorOuter);
            EditorGUILayout.PropertyField(ColorCycleEnabled);
            EditorGUILayout.PropertyField(ColorCycle);
            EditorGUILayout.PropertyField(ColorCycleSpeed);
            EditorGUILayout.PropertyField(ColorCycleOuterEnabled);
            EditorGUILayout.PropertyField(ColorCycleOuter);
            EditorGUILayout.PropertyField(ColorCycleSpeedOuter);
            GUIEndBox();
        }
        GUIEndBox();

        GUIBeginBox();
        if (GUILayout.Button(GUIButtoneText("UV", t.showUV), EditorStyles.boldLabel))
        {
            t.showUV = !t.showUV;
        }
        if (t.showUV)
        {
            GUIBeginBox("", true, 2);
            EditorGUILayout.PropertyField(CreateUV);
            EditorGUILayout.PropertyField(UVScale);
            GUIEndBox();
        }
        GUIEndBox();

        GUIBeginBox();
        if (GUILayout.Button(GUIButtoneText("Noise", t.showNoise), EditorStyles.boldLabel))
        {
            t.showNoise = !t.showNoise;
        }
        if (t.showNoise)
        {
            GUIBeginBox("", true, 2);
            EditorGUILayout.PropertyField(noise);
            EditorGUILayout.PropertyField(noiseDelay);
            GUIEndBox();
        }
        GUIEndBox();

        GUIBeginBox();
        if (GUILayout.Button(GUIButtoneText("Sort", t.showSort), EditorStyles.boldLabel))
        {
            t.showSort = !t.showSort;
        }
        if (t.showSort)
        {
            GUIBeginBox("", true, 2);
            EditorGUILayout.PropertyField(sortingOrder);
            EditorGUILayout.PropertyField(sortingLayer);
            GUIEndBox();
        }
        GUIEndBox();

        GUIBeginBox();
        if (GUILayout.Button(GUIButtoneText("Particles", t.showParticle), EditorStyles.boldLabel))
        {
            t.showParticle = !t.showParticle;
        }
        if (t.showParticle)
        {
            GUIBeginBox("", true, 2);
            EditorGUILayout.PropertyField(particles);
            EditorGUILayout.PropertyField(particleEmitDelay);
            EditorGUILayout.PropertyField(particleRayAmount);
            EditorGUILayout.PropertyField(particleEmitAmount);
            EditorGUILayout.PropertyField(particleRangeLimitMin);
            EditorGUILayout.PropertyField(particleRangeLimitMax);
            GUIEndBox();
        }
        GUIEndBox();

        GUIBeginBox();
        if (GUILayout.Button(GUIButtoneText("Functions", t.showFunctions), EditorStyles.boldLabel))
        {
            t.showFunctions = !t.showFunctions;
        }
        if (t.showFunctions)
        {
            GUIBeginBox("", true, 2);
            if (!Application.isPlaying)
            {
                if (GUIButton("Update"))
                {
                    t.ForceUpdate();
                    //Debug.Log(t.GetComponent<MeshRenderer>().sortingLayerName);
                    //Debug.Log(t.GetComponent<MeshRenderer>().sortingOrder);
                }
                GUILayout.Space(2);
                if (GUIButton("Force New Mesh"))
                {
                    t.ForceNewMesh();
                }
                GUILayout.Space(2);
                if (GUIButton("Create Material Instances\n(ignore error)"))
                {
                    MeshRenderer r = t.GetComponent <MeshRenderer>();
                    for (int i = 0; i < r.materials.Length; i++)
                    {
                        r.materials[i] = new Material(r.materials[i]);
                    }
                }
            }
            EditorGUILayout.HelpBox("Tip : Use [Unity Menu > GameObject > Break Prefab Instance] to improve performance in editor.\nApply changes to connect scene object to prefab again.\n(For reasons unknown, Unity behaves this way)", MessageType.Info);
            GUIEndBox();
        }
        GUIEndBox();
        CheckIdle(t);
        CheckUnityLight(t);
        CheckResolution(t);
        CheckTexture(t);
        if (GUI.changed)
        {
            EditorUtility.SetDirty(t);
            serializedObject.ApplyModifiedProperties();
        }
    }
 void SetLight(ZippyLights2D light, float degree)
 {
     light.degrees = degree;
 }
 void TweenLight(ZippyLights2D light, float origin_degree, float degree)
 {
     DOTween.To(x => light.degrees = x, origin_degree, degree, 1).SetUpdate(true);
 }