Exemplo n.º 1
0
        protected Component(ComponentGroup componentGroup, Vector2 position, Vector2 size)
        {
            // Create a gameobject with the CanvasRenderer component, so we can render as GUI
            GameObject = new GameObject();
            GameObject.AddComponent <CanvasRenderer>();
            // Make sure game object persists
            Object.DontDestroyOnLoad(GameObject);

            // Create a RectTransform with the desired size
            _transform = GameObject.AddComponent <RectTransform>();

            position = new Vector2(
                position.x / 1920f,
                position.y / 1080f
                );
            _transform.anchorMin = _transform.anchorMax = position;

            _transform.sizeDelta = size;

            GameObject.transform.SetParent(UiManager.UiGameObject.transform, false);

            _activeSelf = true;

            _componentGroup = componentGroup;
            componentGroup?.AddComponent(this);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 测量两个组件集之间的距离
        /// </summary>
        /// <param name="measureManager"></param>
        /// <param name="components1">组件集1</param>
        /// <param name="components2">组件集2</param>
        /// <returns>距离值</returns>
        public static double MeasureDistance(this MeasureManager measureManager, Component[] components1, Component[] components2)
        {
            NXOpen.Unit lengthUnit = WorkPart.UnitCollection.FindObject("MilliMeter");

            ComponentGroup group1 = WorkPart.ComponentGroups.CreateComponentGroup(System.DateTime.Now.ToLongTimeString() + "_1");

            for (int i = 0; i < components1.Length; i++)
            {
                group1.AddComponent(components1[i], false);
            }

            ComponentGroup group2 = WorkPart.ComponentGroups.CreateComponentGroup(System.DateTime.Now.ToLongTimeString() + "_2");

            for (int i = 0; i < components2.Length; i++)
            {
                group2.AddComponent(components2[i], false);
            }

            double distanceValue = measureManager.NewDistance(lengthUnit, group1, group2).Value;

            group1.Delete();
            group2.Delete();

            return(distanceValue);
        }
Exemplo n.º 3
0
 private void OnComponentAdded(MEntity entity, int componentType, MComponent component)
 {
     _componentGroup.AddComponent(component, componentType);
 }