Beispiel #1
0
        private void OnEnable()
        {
            m_PreviewPosition       = 0;
            m_ObjectMovingAlongPath = target as ObjectMovingAlongPath;

            if (!EditorApplication.isPlayingOrWillChangePlaymode)
            {
                ObjectMovingAlongPathPreview.CreateNewPreview(m_ObjectMovingAlongPath);
            }
        }
        static public void DestroyPreview()
        {
            if (preview == null)
            {
                return;
            }

            Object.DestroyImmediate(preview);
            preview = null;
            ObjectMovingAlongPath = null;
        }
        static public void CreateNewPreview(ObjectMovingAlongPath origin)
        {
            if (preview != null)
            {
                Object.DestroyImmediate(preview);
            }

            ObjectMovingAlongPath = origin;

            preview           = Object.Instantiate(origin.gameObject);
            preview.hideFlags = HideFlags.DontSave;
            ObjectMovingAlongPath plt = preview.GetComponentInChildren <ObjectMovingAlongPath>();

            Object.DestroyImmediate(plt);


            Color c = new Color(0.2f, 0.2f, 0.2f, 0.4f);

            SpriteRenderer[] rends = preview.GetComponentsInChildren <SpriteRenderer>();
            for (int i = 0; i < rends.Length; ++i)
            {
                rends[i].color = c;
            }
        }