コード例 #1
0
        private void HandleDragAndDropGUI(Rect dragdropArea, EditorWindow w)
        {
            Event evt = Event.current;

            switch (evt.type)
            {
            case EventType.DragUpdated:
            case EventType.DragPerform:
                if (!dragdropArea.Contains(evt.mousePosition))
                {
                    return;
                }

                DragAndDrop.visualMode = DragAndDropVisualMode.Copy;

                if (evt.type == EventType.DragPerform)
                {
                    DragAndDrop.AcceptDrag();

                    foreach (Object obj in DragAndDrop.objectReferences)
                    {
                        VariantOperation.GetOperation().CreateObjectVariantInfo(obj);
                    }
                }
                break;
            }
        }
コード例 #2
0
        private static bool Load()
        {
            bool loaded = false;

            try {
//                var dbPath = kDATAPATH;
//
//                if(File.Exists(dbPath))
//                {
//                    VariantOperation op = AssetDatabase.LoadAssetAtPath<VariantOperation>(dbPath);
//
//                    if(op != null) {
//                        s_operation = op;
//                        loaded = true;
//                    }
//                }
                VariantOperation op = Resources.Load <VariantOperation>("VO");
                if (op != null)
                {
                    s_operation = op;
                    loaded      = true;
                }
            } catch (System.Exception e) {
                Debug.LogException(e);
            }

            return(loaded);
        }
コード例 #3
0
        public bool HandleChildDelete(VariantInfo child)
        {
            m_Children.Remove(child);
            VariantOperation.GetOperation().RemoveVariantFromVariantAxis(child.AssignedVariant, AssignedAxis);

            return(true);
        }
コード例 #4
0
 public void SetRemapConfig(ObjectVariantDestinationInfo info)
 {
     if (info.DstObject != null)
     {
         VariantOperation.GetOperation().AddVariantMapping(info.CreateTagFromSelection(), m_obj, info.DstObject);
     }
     else
     {
         RemoveRemapConfig(info);
     }
 }
コード例 #5
0
        void ApplyAll()
        {
            VariantOperation.GetOperation().ResetRemap();

            VariantOperation.GetOperation().RemoveVariantMapping();

            foreach (var objInfo in VariantOperation.Objects)
            {
                objInfo.SetAllRemapConfig();
            }

            VariantOperation.GetOperation().ApplyRemap();
        }
コード例 #6
0
        private void DrawContent(Rect r)
        {
            var tex = AssetPreview.GetAssetPreview(m_obj);

            GUILayout.Label(tex, GUILayout.Width(100f), GUILayout.Height(100f));
            GUILayout.Label(m_obj.name, "BoldLabel", GUILayout.Width(100f));

            GUILayout.Space(8f);

            if (GUILayout.Button("Add Variant"))
            {
                m_destinations.Add(new ObjectVariantDestinationInfo());
            }

            if (GUILayout.Button("Delete Config"))
            {
                VariantOperation.GetOperation().RemoveObjectVariantInfo(m_obj);
            }
        }
コード例 #7
0
        public static VariantOperation GetOperation()
        {
            if (s_operation == null)
            {
                if (!Load())
                {
                    #if UNITY_EDITOR
                    // Create vanilla db
                    s_operation           = ScriptableObject.CreateInstance <VariantOperation>();
                    s_operation.m_axis    = CreateDefaultAxis();
                    s_operation.m_objects = new List <ObjectVariantInfo>();

                    AssetDatabase.CreateAsset(s_operation, kDATAPATH);
                    #else
                    Debug.LogError("Failed To Load from disk...");
                    #endif
                }
            }

            return(s_operation);
        }
コード例 #8
0
        void DeleteVariant(object b)
        {
            var selectedNodes = b as List <TreeViewItem>;

            if (selectedNodes != null && selectedNodes.Count > 0)
            {
                foreach (var i in selectedNodes)
                {
                    if (i is VariantAxisTreeItem)
                    {
                        VariantAxisTreeItem item = i as VariantAxisTreeItem;
                        VariantOperation.GetOperation().RemoveVariantAxis(item.Info.AssignedAxis);
                    }
                    else if (i is VariantTreeItem)
                    {
                        VariantTreeItem     item = i as VariantTreeItem;
                        VariantAxisTreeItem p    = i.parent as VariantAxisTreeItem;
                        VariantOperation.GetOperation().RemoveVariantFromVariantAxis(item.Info.AssignedVariant, p.Info.AssignedAxis);
                    }
                }
            }
            ForceReloadData(this);
        }
コード例 #9
0
        private void DrawDstContent(Rect r, ObjectVariantDestinationInfo dstInfo, int index)
        {
            var tex = AssetPreview.GetAssetPreview(dstInfo.DstObject);

            GUILayout.Label(tex, GUILayout.Width(100f), GUILayout.Height(100f));

            string name = "<null>";

            if (dstInfo.DstObject != null)
            {
                name = dstInfo.DstObject.name;
            }
            GUILayout.Label(name, "BoldLabel", GUILayout.Width(100f));
            var newObj = EditorGUILayout.ObjectField(dstInfo.DstObject, m_obj.GetType(), false, GUILayout.Width(100f));

            if (newObj != dstInfo.DstObject)
            {
                dstInfo.DstObject = newObj;
                SetRemapConfig(dstInfo);
                VariantOperation.SetDBDirty();
            }

            GUILayout.Space(8f);

            foreach (var ax in VariantOperation.Axis)
            {
                var items = ax.Variants.Select(v => v.Name).ToList();
                items.Insert(0, "<Any>");
                var array = items.ToArray();

                int           popIndex = 0;
                AxisSelection s        = dstInfo.Selections.Find(x => x.axName == ax.Name);
                if (s != null)
                {
                    popIndex = ax.Variants.FindIndex(v => v.ShortName == s.vShortName) + 1;
                }

                var newIndex = EditorGUILayout.Popup(popIndex, array, GUILayout.Width(100f));
                if (newIndex != popIndex)
                {
                    if (newIndex == 0)
                    {
                        dstInfo.Selections.RemoveAll(sel => sel.axName == ax.Name);
                    }
                    else
                    {
                        if (s == null)
                        {
                            s        = new AxisSelection();
                            s.axName = ax.Name;
                            dstInfo.Selections.Add(s);
                        }
                        s.vShortName = (newIndex == 0)? "" : ax.Variants.ElementAt(newIndex - 1).ShortName;
                    }
                    SetRemapConfig(dstInfo);
                    VariantOperation.SetDBDirty();
                }
                GUILayout.Space(2f);
            }

            GUILayout.Space(8f);

            if (GUILayout.Button("Delete Variant"))
            {
                m_removing.Add(dstInfo);
            }
        }
コード例 #10
0
 public void RemoveRemapConfig()
 {
     VariantOperation.GetOperation().RemoveAllVariantMappingForObject(m_obj);
 }
コード例 #11
0
 public void RemoveRemapConfig(ObjectVariantDestinationInfo info)
 {
     VariantOperation.GetOperation().RemoveVariantMapping(info.CreateTagFromSelection(), m_obj);
 }
コード例 #12
0
 public void SelectVariant(Variant v)
 {
     m_currentSelection = v;
     VariantOperation.GetOperation().ApplyRemap();
 }
コード例 #13
0
 public void ResetSelection()
 {
     m_currentSelection = null;
     VariantOperation.GetOperation().ApplyRemap();
 }
コード例 #14
0
        public static void AddNewAxis()
        {
            var newAxis = VariantOperation.GetOperation().CreateNewAxis("New Variant Group");

            m_RootLevelVariant.AddChild(newAxis);
        }
コード例 #15
0
 void ResetAll()
 {
     VariantOperation.GetOperation().ResetRemap();
 }
コード例 #16
0
 public void HandleDelete()
 {
     VariantOperation.GetOperation().RemoveVariantAxis(AssignedAxis);
     m_Children.Clear();
 }