protected virtual void OnEnable()
        {
            stamp = new Stamp();
            wave  = new Wave2D();

            currCameraData = default;
            validator.Reset();
            validator.SetCheckers(() => !transform.hasChanged && currCameraData.Equals(GetCamera()));
            validator.Validation += () => {
                currCameraData = GetCamera();
                if (GetCamera() == null)
                {
                    return;
                }

                Vector2Int reqSize = GetResolution();
                wave.SetSize(reqSize.x, reqSize.y);
                wave.SetBoundary(data.boundary);
                wave.Params = data.paramset;

                transform.hasChanged = false;

                Debug.Log($"{wave}");
            };
            validator.Validated += () => {
                Validated?.Invoke();
            };
        }
Beispiel #2
0
    private void OnEnable()
    {
        stamp = new Stamp();
        wave  = new Wave2D();

        rend = GetComponent <Renderer>();
        col  = GetComponent <Collider>();

        validator.Reset();
        validator.SetCheckers(() => !transform.hasChanged);
        validator.Validation += () => {
            var c          = Camera.main;
            var height     = c.pixelHeight >> data.lod;
            var localScale = transform.localScale;
            var reqSize    = new Vector2Int(Mathf.RoundToInt(height * localScale.x / localScale.y), height);
            wave.SetSize(reqSize.x, reqSize.y);
            wave.SetBoundary(data.boundary);
            wave.Params = data.paramset;

            transform.hasChanged = false;
        };
    }
Beispiel #3
0
    public override void OnInspectorGUI()
    {
        m_object.Update();
        DrawDefaultInspector();

        Wave2D _2dxScript = (Wave2D)target;

        //Texture2D icon = Resources.Load("2dxfxinspector") as Texture2D;
        //if (icon)
        //{
        //    Rect r;
        //    float ih = icon.height;
        //    float iw = icon.width;
        //    float result = ih / iw;
        //    float w = Screen.width;
        //    result = result * w;
        //    r = GUILayoutUtility.GetRect(ih, result);
        //    EditorGUI.DrawTextureTransparent(r, icon);
        //}

        EditorGUILayout.PropertyField(m_object.FindProperty("ActiveUpdate"), new GUIContent("Active Update", "Active Update, for animation / Animator only")); EditorGUILayout.PropertyField(m_object.FindProperty("ForceMaterial"), new GUIContent("Shared Material", "Use a unique material, reduce drastically the use of draw call"));

        if (_2dxScript.ForceMaterial == null)
        {
            _2dxScript.ActiveChange = true;
        }
        else
        {
            if (GUILayout.Button("Remove Shared Material"))
            {
                _2dxScript.ForceMaterial = null;
                _2dxScript.ShaderChange  = 1;
                _2dxScript.ActiveChange  = true;
                _2dxScript.CallUpdate();
            }

            EditorGUILayout.PropertyField(m_object.FindProperty("ActiveChange"), new GUIContent("Change Material Property", "Change The Material Property"));
        }

        if (_2dxScript.ActiveChange)
        {
            EditorGUILayout.BeginVertical("Box");

            Texture2D icone = Resources.Load("2dxfx-icon-clip_left") as Texture2D;

            EditorGUILayout.PropertyField(m_object.FindProperty("_OffsetX"), new GUIContent("Offset X", icone, "Change the offset of X"));
            icone = Resources.Load("2dxfx-icon-clip_right") as Texture2D;
            EditorGUILayout.PropertyField(m_object.FindProperty("_OffsetY"), new GUIContent("Offset Y", icone, "Change the offset of Y"));
            icone = Resources.Load("2dxfx-icon-size_x") as Texture2D;
            EditorGUILayout.PropertyField(m_object.FindProperty("_DistanceX"), new GUIContent("Distance X", icone, "Change the distance of X"));
            icone = Resources.Load("2dxfx-icon-size_y") as Texture2D;
            EditorGUILayout.PropertyField(m_object.FindProperty("_DistanceY"), new GUIContent("Distance Y", icone, "Change the distance of Y"));
            icone = Resources.Load("2dxfx-icon-time") as Texture2D;
            EditorGUILayout.PropertyField(m_object.FindProperty("_WaveTimeX"), new GUIContent("Wave Time X", icone, "Change the time speed of the wave X"));
            icone = Resources.Load("2dxfx-icon-time") as Texture2D;
            EditorGUILayout.PropertyField(m_object.FindProperty("_WaveTimeY"), new GUIContent("Wave Time Y", icone, "Change the time speed of the wave Y"));
            icone = Resources.Load("2dxfx-icon-time") as Texture2D;
            EditorGUILayout.PropertyField(m_object.FindProperty("AutoPlayWaveX"), new GUIContent("Active AutoPlay Wave X", icone, "Active the time speed"));
            if (_2dxScript.AutoPlayWaveX)
            {
                icone = Resources.Load("2dxfx-icon-time") as Texture2D;
                EditorGUILayout.PropertyField(m_object.FindProperty("AutoPlaySpeedX"), new GUIContent("AutoPlay Speed X", icone, "Speed of the auto play X"));
            }
            icone = Resources.Load("2dxfx-icon-time") as Texture2D;
            EditorGUILayout.PropertyField(m_object.FindProperty("AutoPlayWaveY"), new GUIContent("Active AutoPlay Wave Y", icone, "Active the time speed"));
            if (_2dxScript.AutoPlayWaveY)
            {
                icone = Resources.Load("2dxfx-icon-time") as Texture2D;
                EditorGUILayout.PropertyField(m_object.FindProperty("AutoPlaySpeedY"), new GUIContent("AutoPlay Speed Y", icone, "Speed of the auto play Y"));
            }
            icone = Resources.Load("2dxfx-icon-pixel") as Texture2D;
            EditorGUILayout.PropertyField(m_object.FindProperty("AutoRandom"), new GUIContent("Auto Random", icone, "Active the random value"));
            if (_2dxScript.AutoRandom)
            {
                icone = Resources.Load("2dxfx-icon-value") as Texture2D;
                EditorGUILayout.PropertyField(m_object.FindProperty("AutoRandomRange"), new GUIContent("Auto Random Range", icone, "Change the random value"));
            }

            EditorGUILayout.BeginVertical("Box");



            icone = Resources.Load("2dxfx-icon-fade") as Texture2D;
            EditorGUILayout.PropertyField(m_object.FindProperty("_Alpha"), new GUIContent("Fading", icone, "Fade from nothing to showing"));

            EditorGUILayout.EndVertical();
            EditorGUILayout.EndVertical();
        }

        m_object.ApplyModifiedProperties();
    }