Example #1
0
 public void CloseSelection()
 {
     if (s_openSelection == this)
     {
         s_openSelection = null;
     }
     m_isSelectionOpen = false;
     // hide shown snap prefab previews
     m_animState         = EAnimationState.ZOOM_IN;
     m_zoomAnimationTime = 0f;
 }
Example #2
0
 private void OnDisable()
 {
     if (m_previewRoot != null)
     {
         Destroy(m_previewRoot.gameObject);
         m_previewRoot = null;
     }
     DestroyAllPreviews();
     if (s_openSelection == this)
     {
         s_openSelection = null;
     }
     m_isSelectionOpen   = false;
     m_animState         = EAnimationState.IDLE;
     m_zoomAnimationTime = -1f;
 }
Example #3
0
 public void OpenSelection()
 {
     if (s_openSelection != null)
     {
         s_openSelection.CloseSelection();
     }
     s_openSelection     = this;
     m_isSelectionOpen   = true;
     m_animState         = EAnimationState.ZOOM_OUT;
     m_zoomAnimationTime = 0f;
     // create snap prefab previews
     for (int i = 0; i < m_prefabs.Length; i++)
     {
         CreatePrefabPreview(m_prefabs[i]);
     }
 }
Example #4
0
        public void PlacePrefab(S_SnapToObjectPrefab p_prefab)
        {
            // instantly close selection
            if (m_isSelectionOpen)
            {
                DestroyAllPreviews();
                if (s_openSelection == this)
                {
                    s_openSelection = null;
                }
                m_isSelectionOpen   = false;
                m_animState         = EAnimationState.IDLE;
                m_zoomAnimationTime = -1f;
            }
            // create game object
            Object resource = Resources.Load(p_prefab.PrefabResourcePath);

            if (resource != null)
            {
                GameObject go = (GameObject)Instantiate(resource);
                if (m_isSetNameToResourcePath)
                {
                    go.name = p_prefab.PrefabResourcePath;
                }
                go.transform.localRotation = transform.rotation;
                go.transform.Rotate(p_prefab.LocalEulerRotation);
                go.transform.localScale = Vector3.Scale(p_prefab.LocalScale, transform.lossyScale);
                go.transform.position   = transform.position + go.transform.TransformPoint(p_prefab.LocalPosition);
                IncSnapCounter();
                // notify event listeners
                if (OnGlobalAfterObjectSnapped != null)
                {
                    OnGlobalAfterObjectSnapped(this, new S_SnapToObjectEventArgs(this, go));
                }
                if (OnAfterObjectSnapped != null)
                {
                    OnAfterObjectSnapped(this, new S_SnapToObjectEventArgs(this, go));
                }
            }
            else
            {
                Debug.LogError("S_SnapToObject: PlacePrefabInternal: could not find prefab in resources at '" + p_prefab.PrefabResourcePath + "'!");
            }
        }
 public S_SnapToObjectBeforePlacementEventArgs(S_SnapToObject p_source, S_SnapToObjectPrefab p_snapPrefab)
 {
     m_source     = p_source;
     m_snapPrefab = p_snapPrefab;
 }
 public S_SnapToObjectEventArgs(S_SnapToObject p_source, GameObject p_newInstance)
 {
     m_source      = p_source;
     m_newInstance = p_newInstance;
 }