コード例 #1
0
ファイル: DecalEditor.cs プロジェクト: lickey10/Bowling
    //Used to process DecalDecorator changes.
    private void OnSceneGUI()
    {
        //Selected instance.
        Decal decal = (Decal)target;

        //Will only calculate changes and process the new Decal
        //on Repaint and MouseDrag events.
        //MouseDrag will allow us to handle changes made to scene gizmos, while
        //Repaint will allow us to handle changes made to the Inspector.

        //If the user want the objects to be updated, let's do it.
        bool hasChanged = decal.HasChanged();

        if (!hasChanged && ((Event.current.type != EventType.MouseDrag && Event.current.type != EventType.Repaint) || Event.current.modifiers != 0))
        {
            return;
        }

        //On the editor, we'll use only MeshFilter.
        decal.decalMode = DecalMode.MESH_FILTER;

        if (hasChanged)
        {
            decal.ClearDecals();

            if (decal.checkAutomatically)
            {
                GetAffectedObjects(decal);
            }

            decal.CalculateDecal();

            GenerateUV(decal);
        }
    }